mazey
    Preparing search index...

    Function isNumber

    • Check whether a value is a number allowed by the supplied options.

      Usage:

      import { isNumber } from "mazey";

      const ret1 = isNumber(123);
      const ret2 = isNumber("123");
      // Default: NaN, Infinity is not Number
      const ret3 = isNumber(Infinity);
      const ret4 = isNumber(Infinity, { isInfinityAsNumber: true });
      const ret5 = isNumber(NaN);
      const ret6 = isNumber(NaN, { isNaNAsNumber: true, isInfinityAsNumber: true });
      console.log(ret1, ret2, ret3, ret4, ret5, ret6);

      Output:

      true false false true false true
      

      Parameters

      • num: unknown

        Value to check.

      • options: IsNumberOptions = {}

        Controls whether NaN, Infinity, or other non-finite values count as numbers.

      Returns boolean

      Whether the value is an allowed number.