Runtime type checking and assertion library.
@fmartin5/type-checking"">
@fmartin5/type-checking"">
Runtime type checking and type assertion library for Node and the browser
Symbol.toStringTag
property.-0
and NaN
correctly.typeChecking.assert()
(but not .expect()
) for production:
npm install @fmartin5/type-checking
const tc = require("@fmartin5/type-checking");
let x = 0;
tc.isNumber(x); // true
tc.isInteger(x); // true
tc.isPositiveNumber(x); // true
tc.isPositiveInteger(x); // true
tc.isStrictlyPositiveNumber(x); // false
tc.isStrictlyPositiveInteger(x); // false
let map = new Map();
tc.isMap(map); // true
tc.isWeakMap(map); // false
tc.expectMap(map); //
tc.expectWeakMap(map); // TypeError: expected a 'WeaMap' object.
Clone the repo, then do:
npm install
npm test