npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@openinf/util-types

v2.1.3

Published

Fundamental JavaScript type-related utilities

Downloads

330

Readme

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-types

Usage

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:

  • Boolean
  • String
  • Number
  • Symbol
  • BigInt

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:

  • EvalError
  • RangeError
  • ReferenceError
  • SyntaxError
  • TypeError
  • URIError
  • AggregateError
  • InternalError

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:

  • Float32Array
  • Float64Array
  • Int8Array
  • Uint8Array
  • Uint8ClampedArray
  • Int16Array
  • Uint16Array
  • Int32Array
  • Uint32Array

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. |