Skip to content

Commit e89ce6b

Browse files
committed
chore(helpers): moving type safety check to helpers file
1 parent fcefceb commit e89ce6b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

core/src/utils/floating-point/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isSafeNumber } from '../type-guards.ts';
1+
import { isSafeNumber } from "@utils/helpers";
22

33
export function getDecimalPlaces(n: number) {
44
if (!isSafeNumber(n)) return 0;

core/src/utils/helpers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,10 @@ export const getNextSiblingOfType = <T extends Element>(element: Element): T | n
424424
}
425425
return null;
426426
};
427+
428+
/**
429+
* Checks input for usable number. Not NaN and not Infinite.
430+
*/
431+
export const isSafeNumber = (input: unknown): input is number => {
432+
return typeof input === 'number' && !isNaN(input) && isFinite(input);
433+
};

core/src/utils/type-guards.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)