@primitive/is-number
v1.1.0
Published
Determine if a value is a number
Downloads
3
Readme
is-number
Determine if a value is a number.
A value is a number if it is of primitive type number
, or is an instance of
reference type Number
.
Usage
npm install @primitive/is-number --save # Install package via NPM
yarn add @primitive/is-number # Install package via Yarn
import { expect } from "chai";
import isNumber from "@primitive/is-number";
expect(isNumber(42)).to.be.true;
expect(isNumber(0))to.be.true;
expect(isNumber(new Number(1000))).to.be.true;
expect(isNumber(undefined)).to.be.false;
expect(isNumber(null)).to.be.false;
expect(isNumber("42").to.be.false;
This package contains TypeScript type declarations. Furthermore, the package uses TypeScript type guards to allow type inference to influence intellisense.
if (isNumber(x)) {
// IntelliSense now knows `x` is a number.
let y: number = x;
}
Build & Test
This package uses Gulp for building, and Chai and Mocha for testing.
npm install # Installs dependencies.
npm run build # Build the project.
npm test # Run tests.
License
Refer to the LICENSE
file for license information.