Complete type checking for Node
- 🔒 Useful Type Checking,including Primitive, Standard Object, Node Object
- ✨ Typescript Support
- 🚪 Typescript Type Guard Support
npm install is-type-of
Use ES Module import
import is from 'is-type-of';
import { isArray } from 'is-type-of';
isArray([]); // => true
is.array([]); // => true
Compatible With
const is = require('is-type-of');
is.array([1]); // => true
is.primitive(true); // => true
is.primitive({}); // => false
is.generatorFunction(function * () {}); // => true
is.long(Math.pow(2, 33)); // => true
is.double(0); // => false
Use Type Guard
import { isArray } from 'is-type-of';
function checkArray(arr: string[] | string) {
// => parameter) arr: string | string[]
if (isArray(arr)) {
// => (parameter) arr: string[]
arr.forEach(console.log);
}
}
Returns true if val
is string, not String
object.
See Also is.string
Returns true if val
is number, not Number
object.
See Also is.number
Returns true if val
is boolean, not Boolean
object.
See Also is.boolean
Returns true if val
is bigint.
See Also is.bigInt
Returns true if val
is symbol.
See Also is.symbol
Returns true if val
is undefined.
See Also is.undefined
Returns true if val
is null.
See Also is.null
Returns true if val
is null or undefined.
See Also is.nullable
Returns true if val
is primitive.
See Also is.primitive
Returns true if val
is integer.
See Also is.integer
Returns true if val
is integer, and between -2 ** 31
and 2 ** 31 - 1
.
See Also is.integer32
Returns true if val
is integer, and < -2 ** 31
, and > 2 ** 31 - 1
.
See Also is.long
Returns true if val
is integer, and between -(2 ** 53 - 1)
and 2 ** 53 - 1
.
See Also is.safeInteger
Returns true if val
is Double.
See Also is.double
Returns true if val
is NaN.
See Also is.NaN
Returns true if val
is finite.
See Also is.finite
Returns true if val
is array, it won't check items of array.
See Also is.array
Returns true if val
is function.
See Also is.function
Returns true if val
is generator function.
See Also is.generatorFunction
Returns true if val
is async function.
See Also is.asyncFunction
Returns true if val
is async generator function.
See Also is.asyncGeneratorFunction
Returns true if val
is object.
See Also is.object
Returns true if val
is class.
Note: "class" is supported in ECMAScript 6, and if the code is using some compiler or transpiler, the checking might fail.
See Also is.class
Returns true if val
is regular expression.
See Also is.regExp
Returns true if val
is instance of Date.
See Also is.date
Returns true if val
is instance of Error.
See Also is.error
Returns true if val
is generator.
See Also is.generator
Returns true if val
is promise.
See Also is.promise
Returns true if val
is like promise, if the object has then
property, the checking will pass.
See Also is.promiseLike
Returns true if val
is buffer.
See Also is.buffer
Returns true if val
is stream.
See Also is.stream
Returns true if val
is readable stream.
See Also is.readable
Returns true if val
is write stream.
See Also is.writable
Returns true if val
is duplex stream.
See Also is.duplex
returns true if val is LongObject
LongObject is from npm package long
See Also is.longObject
Made with contributors-img.