JSPM

ts-is-number

1.1.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 12
    • Score
      100M100P100Q46281F
    • License MIT

    The ts-is-number a utility npm package that checks if a given input is a valid finite number or a string that can be converted to a valid finite number.

    Package Exports

    • ts-is-number

    Readme

    ts-is-number

    Workflow Codecov NPM Monthly Downloads Install Size Known Vulnerabilities

    The ts-is-number a utility npm package that checks if a given input is a valid finite number or a string that can be converted to a valid finite number.

    Usage:

    Here's how you can import and use the isValidNumber function in your TypeScript or JavaScript project:

    import isValidNumber from 'ts-is-number';
    console.log(isValidNumber(123));

    Overview

    Method:

    isValidNumber(num: string | number | boolean | object | null | undefined): boolean

    Parameters

    • num: The input parameter which can be a string, number, boolean, object, null, or undefined.

    Returns

    Returns true if the input is a valid finite number or a string that can successfully be converted to a valid finite number, otherwise returns false.

    Examples

    console.log(isValidNumber(123)); // returns true
    console.log(isValidNumber('123')); // returns true
    console.log(isValidNumber('123a')); // returns false
    console.log(isValidNumber(NaN)); // returns false
    console.log(isValidNumber(undefined)); // returns false