TypeRight: minimal dynamic typing library
To see its functionality demonstrated, take a look at the tests.
Installation:
npm install type-right
Importing:
;
instanceof
for primitive values
Using Having to choose between typeof
and instanceof
is annoying. TypeRight uses Symbol.hasInstance
to fix this:
console; // trueconsole; // true
Enforcing the types of values
tr; // oktr; // TypeError
If parameters can be missing or undefined
:
tr; // oktr; // ok
Enforcing the types of parameters
{ tr; return Math;}