The @jsopen/objects library provides several utility functions for type checking and identifying various JavaScript structures.
Returns true if the value is a non-null object and NOT an array.
import { isObject } from '@jsopen/objects';
isObject({}); // true
isObject([]); // false
isObject(null); // falseReturns true if the value is a "plain" object (created with {} or new Object()).
import { isPlainObject } from '@jsopen/objects';
isPlainObject({}); // true
isPlainObject(new MyClass()); // falseReturns true if the value is a built-in JavaScript object type such as Date, RegExp, Map, Set, Promise, Error, or typed arrays.
import { isBuiltIn } from '@jsopen/objects';
isBuiltIn(new Date()); // true
isBuiltIn(new Map()); // true
isBuiltIn({}); // falseReturns true if the value is a function that can be used as a constructor.
import { isConstructor } from '@jsopen/objects';
isConstructor(class {}); // true
isConstructor(() => {}); // falseReturns true if the value implements the Symbol.iterator protocol.
import { isIterable } from '@jsopen/objects';
isIterable([]); // true
isIterable(new Map()); // true
isIterable({}); // falseReturns true if the value implements the Symbol.asyncIterator protocol.
import { isAsyncIterable } from '@jsopen/objects';
const asyncGen = async function* () {};
isAsyncIterable(asyncGen()); // true
isAsyncIterable([]); // false