static isNumber()

Checks the provided value of any type whether is an instance of `Number` of any or the given primitive value

Number.isNumber()

The static isNumber() method checks the provided value of any type whether is an instance of Number of any or the given primitive value.

number.class.ts
public static isNumber<Value extends number>(
  value: any,
  numberValue?: Value
): value is Number<Value> {
  return (
    typeof value === 'object' &&
    value instanceof this &&
    (typeof numberValue === 'number' ? value.valueOf() === numberValue : true)
  );
}

Generic type variables

Valueextendsnumber

A generic type variable indicates captured type of the supplied numberValue via the return type.

Parameters

value:any

The value of any type to test against the Number instance.

numberValue?:Value

Optional number of the generic type variable Value to check if it's the primitive value of the given value.

Return type

value is Number<Value>

The return type is a boolean resulting from its statement indicating the value is the Number object that takes the generic type variable Value.

Returns

The return value is a boolean indicating whether the provided value is an instance of Number of any or the given numberValue.

Example usage

// Example usage.
import { Number } from '@angular-package/range';

Last updated