1.0.0 • Published 5 years ago
assert-functions v1.0.0
assert-functions
Assertion functions for basic JS data types. Unopiniated, simple, with no cruft.
Install
npm i assert-functionsUsage
Import any single assertion you need. Available assertions are same as the basic JS data types -- assertArray, assertBigInt, assertBoolean, assertFunction, assertNumber, assertObject, assertString, assertSymbol, assertUndefined.
const { assertNumber, AssertionError } = require('assert-functions');
assertNumber(5);
try {
assertNumber("6");
} catch (e) {
if (e instanceof AssertionError) {
console.log('assertion error!');
}
}License
1.0.0
5 years ago