A run-time type assertion library for NodeJS.
npm install type-assert> Type assertion library for NodeJS.
```
npm install --save type-assert
`javascript
const assert = require('type-assert');
function foo(id, msg, active, age) {
assert(id).is('Number');
assert(msg).is('String');
assert(active).isOptional('Boolean');
assert(age).is(x => x > 18);
}
try {
foo(5, 5);
} catch (err) {
console.error(err.message);
//=> 5 is not of type String
}
`
Throw TypeError if the input is not of type type.
Throw TypeError if the input is not of type type, only if the input is provided.
#### match
Type: string function
The type-check type or a test function that should return true` if the assertion is successful.
MIT © Sam Verschueren