Remove duplicate code for parsing numbers.

This commit is contained in:
baldo 2022-09-20 19:11:36 +02:00
parent 15d3f45bae
commit b1075aa2ec
6 changed files with 181 additions and 35 deletions
server/shared/types

View file

@ -24,6 +24,15 @@ export function isInteger(arg: unknown): arg is number {
return isNumber(arg) && Number.isInteger(arg);
}
/**
* Type guard checking the given value is a floating point `number`.
*
* @param arg - Value to check.
*/
export function isFloat(arg: unknown): arg is number {
return isNumber(arg) && Number.isFinite(arg);
}
// =====================================================================================================================
// Strings
// =====================================================================================================================