chore(helpers): moving type safety check to helpers file

This commit is contained in:
ShaneK
2025-03-06 12:14:54 -08:00
parent fcefcebe56
commit e89ce6b57a
3 changed files with 8 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import { isSafeNumber } from '../type-guards.ts';
import { isSafeNumber } from "@utils/helpers";
export function getDecimalPlaces(n: number) {
if (!isSafeNumber(n)) return 0;

View File

@@ -424,3 +424,10 @@ export const getNextSiblingOfType = <T extends Element>(element: Element): T | n
}
return null;
};
/**
* 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);
};

View File

@@ -1,6 +0,0 @@
/**
* 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);
};