@openinf/util-types v2.1.3
The high-level goal of @openinf/util-types is to serve as a Node.js
package containing utilities for fundamental JavaScript type-related
operations primarily enabling users to perform native typechecking and
simplify type coercion. As is the case with any software project in continuous
development, omissions and errors may exist, for which contributions are
welcome.
Installation
@openinf/util-types runs on Node.js and is available via npm.
npm install @openinf/util-typesUsage
Import the helper functions based on your platform.
import { isObject } from '@openinf/util-types';
const maybeObject = null;
if (isObject(maybeObject)) {
console.log('The value of `maybeObject` is of type Object.');
} else {
console.log('The value of `maybeObject` is not of type Object.');
}Functions
toString(value) ⇒ string
Returns the ECMAScript [Class] internal property of the passed value.
Kind: global function
Returns: string - A specification-defined classification of objects.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isArray(value) ⇒ boolean
Determines whether the passed value is of type Array.
Kind: global function
Returns: boolean - true if the value is an Array; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
toArray(arrayLike) ⇒ Array.<T>
Converts an array-like object to an array.
Kind: global function
| Param | Type |
|---|---|
| arrayLike | ArrayLike.<T> | string |
isObject(value) ⇒ boolean
Determines whether the passed value is of type Object.
Kind: global function
Returns: boolean - true if the value is an Object; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isFiniteNumber(value) ⇒ boolean
Determines whether the passed value is of number type and finite. NaN and
Infinity are not considered a finite number. String numbers are not
considered numbers.
Kind: global function
Returns: boolean - true if the value is a finite number; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isAnyArrayBuffer(value) ⇒ boolean
Determines whether the passed value is one of either ArrayBuffer or
SharedArrayBuffer.
Kind: global function
Returns: boolean - true if the value is an any array buffer; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isArrayBufferView(value) ⇒ boolean
Determines whether the passed value is an ArrayBufferView.
Kind: global function
Returns: boolean - true if the value is an ArrayBufferView; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isArgumentsObject(value) ⇒ boolean
Determines whether the passed value is of type Arguments object.
Kind: global function
Returns: boolean - true if the value is an Arguments object; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isArrayBuffer(value) ⇒ boolean
Determines whether the passed value is of type ArrayBuffer.
Kind: global function
Returns: boolean - true if the value is an ArrayBuffer; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isAsyncFunction(value) ⇒ boolean
Determines whether the passed value is of type AsyncFunction.
Kind: global function
Returns: boolean - true if the value is an AsyncFunction; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isBigInt64Array(value) ⇒ boolean
Determines whether the passed value is of type BigInt64Array.
Kind: global function
Returns: boolean - true if the value is a BigInt64Array; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isBigUint64Array(value) ⇒ boolean
Determines whether the passed value is of type BigUint64Array.
Kind: global function
Returns: boolean - true if the value is a BigUint64Array; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isBooleanObject(value) ⇒ boolean
Determines whether the passed value is a Boolean object.
Kind: global function
Returns: boolean - true if the value is a Boolean; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isBoxedPrimitive(value) ⇒ boolean
Determines whether the passed value is one of the boxed primitives:
BooleanStringNumberSymbolBigInt
Kind: global function
Returns: boolean - true if the value is one of the boxed primitives;
otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isDataView(value) ⇒ boolean
Determines whether the passed value is of type DataView.
Kind: global function
Returns: boolean - true if the value is a DataView; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isDate(value) ⇒ boolean
Determines whether the passed value is of type Date.
Kind: global function
Returns: boolean - true if the value is a Date; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isFloat32Array(value) ⇒ boolean
Determines whether the passed value is of type Float32Array.
Kind: global function
Returns: boolean - true if the value is a Float32Array; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isFloat64Array(value) ⇒ boolean
Determines whether the passed value is of type Float64Array.
Kind: global function
Returns: boolean - true if the value is a Float64Array; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isOrdinaryFunction(value) ⇒ boolean
Determines whether the passed value is of type Function.
Kind: global function
Returns: boolean - true if the value is a Function; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isGeneratorFunction(value) ⇒ boolean
Determines whether the passed value is of type GeneratorFunction.
Kind: global function
Returns: boolean - true if the value is a GeneratorFunction; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isGeneratorObject(value) ⇒ boolean
Determines whether the passed value is of type Generator object.
Kind: global function
Returns: boolean - true if the value is a Generator; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isInt8Array(value) ⇒ boolean
Determines whether the passed value is of type Int8Array.
Kind: global function
Returns: boolean - true if the value is an Int8Array; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isInt16Array(value) ⇒ boolean
Determines whether the passed value is of type Int16Array.
Kind: global function
Returns: boolean - true if the value is an Int16Array; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isInt32Array(value) ⇒ boolean
Determines whether the passed value is of type Int32Array.
Kind: global function
Returns: boolean - true if the value is an Int32Array; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isMap(value) ⇒ boolean
Determines whether the passed value is of type Map.
Kind: global function
Returns: boolean - true if the value is a Map; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isMapIterator(value) ⇒ boolean
Determines whether the passed value is of type Map Iterator.
Kind: global function
Returns: boolean - true if the value is a Map Iterator; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isModuleNamespaceObject(value) ⇒ boolean
Determines whether the passed value is a Module namespace object.
Kind: global function
Returns: boolean - true if the value is a Module; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isNativeError(value) ⇒ boolean
Determines whether the passed value is a one of the native error types:
EvalErrorRangeErrorReferenceErrorSyntaxErrorTypeErrorURIErrorAggregateErrorInternalError
Kind: global function
Returns: boolean - true if the value is a native error; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isNumberObject(value) ⇒ boolean
Determines if value is actually a Number object.
Kind: global function
Returns: boolean - true if the value is a Number; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isBigIntObject(value) ⇒ boolean
Determines if value is actually a BigInt object.
Kind: global function
Returns: boolean - true if the value is a BigInt; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isPromise(value) ⇒ boolean
Determines whether the passed value is of type Promise.
Kind: global function
Returns: boolean - true if the value is a Promise; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isRegExp(value) ⇒ boolean
Determines whether the passed value is of type RegExp.
Kind: global function
Returns: boolean - true if the value is a RegExp; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isSet(value) ⇒ boolean
Determines whether the passed value is of type Set.
Kind: global function
Returns: boolean - true if the value is a Set; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isSetIterator(value) ⇒ boolean
Determines whether the passed value is of type Set Iterator.
Kind: global function
Returns: boolean - true if the value is a Set Iterator; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isSharedArrayBuffer(value) ⇒ boolean
Determines whether the passed value is of type SharedArrayBuffer.
Kind: global function
Returns: boolean - true if the value is a SharedArrayBuffer; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isStringObject(value) ⇒ boolean
Determines if value is actually a String object.
Kind: global function
Returns: boolean - true if the value is a String; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isSymbolObject(value) ⇒ boolean
Determines if value is actually a Symbol object.
Kind: global function
Returns: boolean - true if the value is a Symbol; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isTypedArray(value) ⇒ boolean
Determines if value is one of the typed arrays:
Float32ArrayFloat64ArrayInt8ArrayUint8ArrayUint8ClampedArrayInt16ArrayUint16ArrayInt32ArrayUint32Array
Kind: global function
Returns: boolean - true if the value is one of the typed arrays; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isUint8Array(value) ⇒ boolean
Determines whether the passed value is of type Uint8Array.
Kind: global function
Returns: boolean - true if the value is a Uint8Array; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isUint8ClampedArray(value) ⇒ boolean
Determines whether the passed value is of type Uint8ClampedArray.
Kind: global function
Returns: boolean - true if the value is a Uint8ClampedArray; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isUint16Array(value) ⇒ boolean
Determines whether the passed value is of type Uint16Array.
Kind: global function
Returns: boolean - true if the value is a Uint16Array; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isUint32Array(value) ⇒ boolean
Determines whether the passed value is of type Uint32Array.
Kind: global function
Returns: boolean - true if the value is a Uint32Array; otherwise,
false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isWeakMap(value) ⇒ boolean
Determines whether the passed value is of type WeakMap.
Kind: global function
Returns: boolean - true if the value is a WeakMap; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |
isWeakSet(value) ⇒ boolean
Determines whether the passed value is of type WeakSet.
Kind: global function
Returns: boolean - true if the value is a WeakSet; otherwise, false.
| Param | Type | Description |
|---|---|---|
| value | unknown | The value to be checked. |