diff --git a/core/src/utils/type-guards.ts b/core/src/utils/type-guards.ts new file mode 100644 index 0000000000..e5ea629954 --- /dev/null +++ b/core/src/utils/type-guards.ts @@ -0,0 +1,6 @@ +/** + * Checks input for usable number. Not NaN and not Infinite. + */ +export const isSafeNumber = (input: unknown): input is number => { + return typeof input === 'number' && !isNaN(input) && isFinite(input); +};