Library API
    Preparing search index...

    Function ifNumeric

    • Returns the value as a Number or BigInt if possible, otherwise returns the original string.

      Parameters

      • str: string | number | bigint

        The string, number, or bigint to process

      • stripZero: boolean = false

        Whether to strip leading zeros when evaluating numeric strings

      Returns string | number | bigint

      The numeric coercion or the original string

      const num = ifNumeric('123'); // 123