@magic/types
typechecking utilities
install
npm install @magic/types
import single function
import { isArray } from '@magic/types'
isArray([])
import all functions
import is from '@magic/types'
is.array([])
functions
is(ele, ...types)
not(ele, ...types)
type comparisons:
isArray([])
isBoolean(true)
isDefined(undefined)
isUndefined(undefined)
isFunction(() => {})
isNumber(1)
isInteger(1)
isFloat(1.1)
isObject({})
isString('')
isRGBAObject({ r: 1, g: 1, b: 1, a: 1 })
isRGBObject
isHexColor('#333')
isHexAlphaColor('#3333')
isColor('#444')
isDate(new Date())
isRegExp(/regexp/)
isTruthy('true')
isFalsy(0)
isEmpty('')
isError(new Error(''))
isIterable([])
isEmail('a@b.c')
isNull(null)
isUndefinedOrNull(undefined || null)
isBuffer(new Buffer('test'))
isPromise(new Promise())
isArguments(() => return arguments)
isUUID(uuid)
testType(42, 'number')
test(42, ['string', 'object'])
isEq(42, 'number')
isNot = isNeq = is.not(42, 'number')
isDeepEqual([1, 2, 3], [1, 2, 3])
isDeepDifferent([1, 2, 3], [1, 2, 3])
Changelog
0.0.5
added Map, WeakMap, Set and WeakSet
0.1.0
use es6 modules
0.1.1
FIX: add module field to package.json
0.1.2
FIX: is.number no longer errors on node es6 modules and other weird objects
0.1.3
use @magic/deep for is.deep.equal and is.deep.different
0.1.4
is.deep uses @magic/deep now.
this means that is.deep.equal(null, undefined) is returning a function now,
because it expects currying.
0.1.5
minimum node version is 13.5.0
0.1.6
remove @magic/deep dependency
0.1.7
fix erroneous '@magic/types' import in src/deep/equal.mjs
0.1.8 - unreleased
...