Skip to content

object-utils

Contains utility functions for Objects.

InterfaceDescription
SetNestedPropertyValueParamsParameters for setNestedPropertyValue.
ToJsonOptionsOptions for toJson.
FunctionDescription
assignWithNonEnumerablePropertiesAssigns properties from one or more source objects to a target object, including non-enumerable properties.
castToCasts a value to a specific type.
cloneWithNonEnumerablePropertiesClones an object, including non-enumerable properties.
deepEqualCompares two values to determine if they are deeply equal.
deletePropertiesDeletes multiple properties from an object.
deletePropertyDeletes a property from an object.
extractDefaultExportInteropExtracts the default export from a module. Useful to handle incorrect default export interop between ESM and CJS.
getAllEntriesGets all entries of an object.
getAllKeysGets all keys of an object. Includes fields and properties.
getNestedPropertyValueGets the value of a nested property from an object.
getPrototypeOfGets the prototype of the specified object.
nameofRetrieves the name of a property of a given type T.
normalizeOptionalPropertiesNormalizes optional properties to allow undefined assignment in strict mode. This utility provides a workaround for the exactOptionalPropertyTypes TypeScript flag, which prohibits directly assigning undefined to optional properties when the type explicitly omits undefined. Example: typescript // With `exactOptionalPropertyTypes: true` const x: \{ prop?: string \} = \{ prop: undefined \}; // Compiler error // Using this utility: const y: \{ prop?: string \} = normalizeOptionalProperties<\{ prop?: string \}>(\{ prop: undefined \}); // Works
removeUndefinedPropertiesRemoves all undefined properties from an object.
setNestedPropertyValueSets the value of a nested property in an object.
toJsonConverts a given value to a JSON string.
EnumDescription
FunctionHandlingModeSpecifies how functions should be handled in the JSON output.