@suchipi/is
v1.0.0
Published
Functions for testing the types of JS values
Downloads
3
Readme
@suchipi/is
Functions for testing the types of JavaScript values, cross-realm. Has testers for all standard built-in objects/values.
Usage
import { is } from "@suchipi/is";
console.log(is.Object({})); // true
console.log(is.Array([])); // true
console.log(is.String(null)); // false
// etc
Available functions
String
string
(alias ofString
)Number
(does not return true forNaN
)number
(alias ofNumber
)Boolean
boolean
(alias ofBoolean
)BigInt
bigint
(alias ofBigInt
)Symbol
symbol
(alias ofSymbol
)null
undefined
void
Object
(does not return true fornull
)object
(alias ofObject
)Array
Function
function
(alias ofFunction
)tagged
(Object toString tag checker)instanceOf
(same asinstanceof
)Error
(matches Error subclasses, too)Infinity
NegativeInfinity
NaN
Date
RegExp
Map
Set
WeakMap
WeakSet
ArrayBuffer
SharedArrayBuffer
DataView
TypedArray
Int8Array
Uint8Array
Uint8ClampedArray
Int16Array
Uint16Array
Int32Array
Uint32Array
Float32Array
Float64Array
Promise
(matches any thenable)Generator
(only guaranteed to match generators that weren't compiled with Babel or etc)GeneratorFunction
(only guaranteed to match generator functions that weren't compiled with Babel or etc)AsyncFunction
(only guaranteed to match async functions that weren't compiled with Babel or etc)AsyncGenerator
(only guaranteed to match async generators that weren't compiled with Babel or etc)AsyncGeneratorFunction
(only guaranteed to match async generator functions that weren't compiled with Babel or etc)
Notes
Two utility types, TypedArray
and TypedArrayConstructor
, are also exported from this package.
License
MIT