Skip to content

Namespace Object

Object utilities for copying, merging, inspecting, and type-checking JavaScript/TypeScript objects.

Install

Use this namespace only:

bash
npm i @litert/utils-object

Or install the full bundle:

bash
npm i @litert/utils

And then import from it.

ts
import * as LibUtils from '@litert/utils';
LibUtils.Object.deepMerge(a, b);

// or
import { Object as LibObject } from '@litert/utils';
LibObject.deepMerge(a, b);

Exports

Classes

NameDescription
PropertyPathParserParses a property path string (e.g. $.a.b[0]) into an array of property names and array indices.

Functions

NameDescription
copyPropertiesCopies specified properties from a source object to a destination object.
deepMergeRecursively merges two objects into a new object.
getPropertyByPathExtracts the value at a given property path from an object.
getConstructorReturns the constructor function of an object.
getPropertyNamesReturns all own property names and symbols of an object.
hasPropertiesChecks whether all specified properties exist on an object.
isClassConstructorChecks whether a value is a native ES2015 class constructor.
isSubclassOfChecks whether a class is a subclass of another.
pickPropertiesCreates a new object with only the specified properties.