Install
npm install --save type-func
About
This is a collection of functions that return functions that return certain types of values.
The signature is:
typeFunc
is one of these types.
boolean(func|boolean, default|undefined) -> fn(...args)
integer(func|integer, default|undefined) -> fn(...args)
string(func|string, default|undefined) -> fn(...args)
The fn
function returned by one of the above type functions returns the value of that type.
Example:
;let bool1 = ; let bool2 = ;
The variables bool1, and bool2 in the above example are functions that return a boolean.
All returned types are converted from the input to the respective type.
Example:
;let zero1 = ;console;// prints falselet zero2 = ;console;// also prints false
When undefined
is passed a default value is used. If there is no default value set then undefined
will be converted as needed.
; let defaultToFalse = console;// prints falselet undef = ;console; // prints false
What's this good for?
Default options. Examples:
; { thisopt = ;}
; { thisopt = ;}
; { thisopt = ;}
About
Just some helper functions that return consistent types.