@magic/types
typechecking utilities
install
npm install @magic/types
import single function
const { isArray } = require('@magic/types')
isArray([])
import all functions
const is = require('@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])