Object
The object module provides a comprehensive set of utility functions for manipulating objects in JavaScript/TypeScript. These functions facilitate common operations such as deep cloning, accessing nested properties, merging objects, structure transformations, and state checks.
Key features:
- Safe manipulation of nested objects
- Structure transformations (flatten/unflatten)
- Immutability operations (freeze/seal)
- Verification and comparison utilities
- Property selection and omission functions
Overview
clone
clone<T>(value: T): TPerforms a deep copy of any value, including objects, arrays, and primitive types.
flattenObj
flattenObj(obj): Record<string, any>Transforms a nested object into a flat object, with full paths as keys.
freeze
freeze(obj: Record<PropertyKey, any>): Record<PropertyKey, any>Recursively freezes an object and all its internal objects, making them immutable.
get
get<T>(obj: T, path: string | string[], defaultValue?: any): anyAccesses the value of a nested property in an object, with support for a default value.
has
has<T>(obj: T, path: string | string[]): booleanChecks if an object has a (nested) property specified by a path.
isEmpty
isEmpty(value): booleanChecks if a value (object, array, string, Map, or Set) is empty.
isEqual
isEqual(value1, value2): booleanCompares two values to determine if they are equivalent in structure and content.
isFrozen
isFrozen(obj): booleanChecks if an object is frozen (immutable).
isNotNullObject
isNotNullObject(value): booleanChecks if a value is a non-null object.
isPlainObject
isPlainObject(value): booleanChecks if a value is a plain object, created by literal or by Object.
isSealed
isSealed(obj): booleanChecks if an object is sealed (cannot add/remove properties).
merge
merge(target, ...sources): objectCombines two or more objects into a new object, performing a deep merge.
omit
omit(obj, keys): objectCreates a copy of an object, excluding the specified properties.
pick
pick(obj, keys): objectCreates a new object containing only the specified properties from the original.
seal
seal(obj): objectRecursively seals an object, preventing addition or removal of properties.
set
set(obj, path, value): objectSets the value of a property in an object, supporting nested paths.
unflattenObj
unflattenObj(obj): objectReconstructs nested objects from a flat object with path keys.
