type-assert
Type assertion library for NodeJS.
Installation
npm install --save type-assert
Usage
const assert = ; { ; ; ; ;} try ; catch err console; //=> 5 is not of type String
API
is(match)
Throw TypeError
if the input is not of type type
.
isOptional(match)
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.
License
MIT © Sam Verschueren