0.0.8 • Published 2 years ago
@magic-libraries/is v0.0.8
@magic-libraries/is
typechecking client lib for @magic
installation
npm install --save-exact @magic-libraries/isusage
in a page/component, just use the LIB.JSON functions.
export const View = () => [
div(LIB.IS('a string', 'string') ? '"a string" is a string' : '"a string" is not a string'),
div(LIB.IS(0, 'string') ? '0 is a string' : '0 is not a string'),
]renders
<div>"a string" is a string</div>
<div>0 is not a string</div>supported types
by default, magic will test for type equality using typeof.
is('a string', 'string') // true
is({}, 'object') // true
is([], 'object') // trueif typeof would fail, is uses a number of builtin functions to determine the type of the value
is([], 'array') // true
is(0, 'number') // true
is(1.1, 'float') // true
is(10, 'integer') // true
is(new Date(), 'date') // true
is(/regexp/, 'regexp') // true
is(new Error(), 'error') // true
is(null, 'null') // true
is(new Promise(), 'promise') // true
is({}, 'objectNative') //truefor convenience, @magic-libraries/is also exports the alias functions it uses
is.number(0) // true
is.integer(1) // true
is.float(1.1) // true
is.array([]) // true
is.regexp(/t/) // true
is.date(new Date()) // true
is.error(new Error()) // true
is.null(null) // true
is.promise(new Promise()) // true
is.objectNative({}) //truechangelog
0.0.1
first release
0.0.2
update readme
0.0.3
update readme
0.0.4
require node 13.5.0
0.0.5
bump required node version
0.0.6
bump required node version to 14.15.4
0.0.7
update dependencies
0.0.8
update dependencies add is.objectNative
0.0.9 - unreleased
...