From 9717acb7bb0f6254f50e24a0023add016db9a40b Mon Sep 17 00:00:00 2001 From: fudom <143608856+fudom@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:19:11 +0100 Subject: [PATCH] Create type-guards.ts --- core/src/utils/type-guards.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 core/src/utils/type-guards.ts 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); +};