Deep object operations including property access, merging, transformation, and key/value manipulation for comprehensive object handling.
Assigns own enumerable string keyed properties of source objects to the destination object.
/**
* Assigns own enumerable string keyed properties of source objects to the
* destination object. Source objects are applied from left to right.
* Subsequent sources overwrite property assignments of previous sources.
* @param object - The destination object
* @param sources - The source objects
* @returns Returns `object`
*/
function assign<TObject, TSource>(object: TObject, source: TSource): TObject & TSource;
function assign<TObject, TSource1, TSource2>(object: TObject, source1: TSource1, source2: TSource2): TObject & TSource1 & TSource2;
function assign<TObject>(object: TObject, ...otherArgs: any[]): any;Like assign except that it iterates over own and inherited source properties.
/**
* This method is like `assign` except that it iterates over own and
* inherited source properties.
* @param object - The destination object
* @param sources - The source objects
* @returns Returns `object`
*/
function assignIn<TObject, TSource>(object: TObject, source: TSource): TObject & TSource;
function assignIn<TObject, TSource1, TSource2>(object: TObject, source1: TSource1, source2: TSource2): TObject & TSource1 & TSource2;
function assignIn<TObject>(object: TObject, ...otherArgs: any[]): any;Like assignIn except that it accepts customizer which is invoked to produce the assigned values.
/**
* This method is like `assignIn` except that it accepts `customizer`
* which is invoked to produce the assigned values.
* @param object - The destination object
* @param sources - The source objects
* @param customizer - The function to customize assigned values
* @returns Returns `object`
*/
function assignInWith<TObject, TSource>(
object: TObject,
source: TSource,
customizer: (objValue: any, srcValue: any, key: string, object: TObject, source: TSource) => any
): TObject & TSource;
function assignInWith<TObject>(object: TObject, ...otherArgs: any[]): any;Like assign except that it accepts customizer which is invoked to produce the assigned values.
/**
* This method is like `assign` except that it accepts `customizer` which
* is invoked to produce the assigned values.
* @param object - The destination object
* @param sources - The source objects
* @param customizer - The function to customize assigned values
* @returns Returns `object`
*/
function assignWith<TObject, TSource>(
object: TObject,
source: TSource,
customizer: (objValue: any, srcValue: any, key: string, object: TObject, source: TSource) => any
): TObject & TSource;
function assignWith<TObject>(object: TObject, ...otherArgs: any[]): any;Creates an object that inherits from the prototype object.
/**
* Creates an object that inherits from the `prototype` object. If a
* `properties` object is given, its own enumerable string keyed properties
* are assigned to the created object.
* @param prototype - The object to inherit from
* @param properties - The properties to assign to the object
* @returns Returns the new object
*/
function create<T>(prototype: T, properties?: PropertyDescriptorMap): T;Assigns own and inherited enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to undefined.
/**
* Assigns own and inherited enumerable string keyed properties of source
* objects to the destination object for all destination properties that
* resolve to `undefined`. Source objects are applied from left to right.
* Once a property is set, additional values of the same property are ignored.
* @param object - The destination object
* @param sources - The source objects
* @returns Returns `object`
*/
function defaults<TObject, TSource>(object: TObject, source: TSource): TSource & TObject;
function defaults<TObject, TSource1, TSource2>(object: TObject, source1: TSource1, source2: TSource2): TSource2 & TSource1 & TObject;
function defaults<TObject>(object: TObject, ...sources: any[]): any;Like defaults except that it recursively assigns default properties.
/**
* This method is like `defaults` except that it recursively assigns
* default properties.
* @param object - The destination object
* @param sources - The source objects
* @returns Returns `object`
*/
function defaultsDeep<TObject, TSource>(object: TObject, source: TSource): TSource & TObject;
function defaultsDeep<TObject>(object: TObject, ...sources: any[]): any;This method is like find except that it returns the key of the first element predicate returns truthy for instead of the element itself.
/**
* This method is like `find` except that it returns the key of the first
* element `predicate` returns truthy for instead of the element itself.
* @param object - The object to inspect
* @param predicate - The function invoked per iteration
* @returns Returns the key of the matched element, else `undefined`
*/
function findKey<T>(
object: T,
predicate?: string | object | ((value: T[keyof T], key: string, object: T) => boolean)
): string | undefined;Like findKey except that it iterates over elements in the opposite order.
/**
* This method is like `findKey` except that it iterates over elements of
* a collection in the opposite order.
* @param object - The object to inspect
* @param predicate - The function invoked per iteration
* @returns Returns the key of the matched element, else `undefined`
*/
function findLastKey<T>(
object: T,
predicate?: string | object | ((value: T[keyof T], key: string, object: T) => boolean)
): string | undefined;Iterates over own and inherited enumerable string keyed properties of an object and invokes iteratee for each property.
/**
* Iterates over own and inherited enumerable string keyed properties of an
* object and invokes `iteratee` for each property. The iteratee is invoked
* with three arguments: (value, key, object). Iteratee functions may exit
* iteration early by explicitly returning `false`.
* @param object - The object to iterate over
* @param iteratee - The function invoked per iteration
* @returns Returns `object`
*/
function forIn<T>(
object: T,
iteratee?: (value: T[keyof T], key: string, object: T) => any
): T;Like forIn except that it iterates over properties in the opposite order.
/**
* This method is like `forIn` except that it iterates over properties of
* `object` in the opposite order.
* @param object - The object to iterate over
* @param iteratee - The function invoked per iteration
* @returns Returns `object`
*/
function forInRight<T>(
object: T,
iteratee?: (value: T[keyof T], key: string, object: T) => any
): T;Iterates over own enumerable string keyed properties of an object and invokes iteratee for each property.
/**
* Iterates over own enumerable string keyed properties of an object and
* invokes `iteratee` for each property. The iteratee is invoked with three
* arguments: (value, key, object). Iteratee functions may exit iteration
* early by explicitly returning `false`.
* @param object - The object to iterate over
* @param iteratee - The function invoked per iteration
* @returns Returns `object`
*/
function forOwn<T>(
object: T,
iteratee?: (value: T[keyof T], key: string, object: T) => any
): T;Like forOwn except that it iterates over properties in the opposite order.
/**
* This method is like `forOwn` except that it iterates over properties of
* `object` in the opposite order.
* @param object - The object to iterate over
* @param iteratee - The function invoked per iteration
* @returns Returns `object`
*/
function forOwnRight<T>(
object: T,
iteratee?: (value: T[keyof T], key: string, object: T) => any
): T;Creates an array of function property names from own enumerable properties of object.
/**
* Creates an array of function property names from own enumerable properties
* of `object`.
* @param object - The object to inspect
* @returns Returns the function names
*/
function functions(object?: any): string[];Creates an array of function property names from own and inherited enumerable properties of object.
/**
* Creates an array of function property names from own and inherited
* enumerable properties of `object`.
* @param object - The object to inspect
* @returns Returns the function names
*/
function functionsIn(object?: any): string[];Gets the value at path of object.
/**
* Gets the value at `path` of `object`. If the resolved value is
* `undefined`, the `defaultValue` is returned in its place.
* @param object - The object to query
* @param path - The path of the property to get
* @param defaultValue - The value returned for `undefined` resolved values
* @returns Returns the resolved value
*/
function get<TObject extends object, TKey extends keyof TObject>(
object: TObject,
path: TKey | [TKey]
): TObject[TKey];
function get<TObject extends object, TKey extends keyof TObject, TDefault>(
object: TObject | null | undefined,
path: TKey | [TKey],
defaultValue: TDefault
): TObject[TKey] | TDefault;
function get<T>(
object: any,
path: PropertyPath,
defaultValue?: T
): T;Checks if path is a direct property of object.
/**
* Checks if `path` is a direct property of `object`.
* @param object - The object to query
* @param path - The path to check
* @returns Returns `true` if `path` exists, else `false`
*/
function has<T>(object: T, path: PropertyPath): boolean;Checks if path is a direct or inherited property of object.
/**
* Checks if `path` is a direct or inherited property of `object`.
* @param object - The object to query
* @param path - The path to check
* @returns Returns `true` if `path` exists, else `false`
*/
function hasIn<T>(object: T, path: PropertyPath): boolean;Creates an object composed of the inverted keys and values of object.
/**
* Creates an object composed of the inverted keys and values of `object`.
* If `object` contains duplicate values, subsequent values overwrite
* property assignments of previous values.
* @param object - The object to invert
* @returns Returns the new inverted object
*/
function invert(object: any): Record<string, string>;Like invert except that the inverted object is generated from the results of running each element of object thru iteratee.
/**
* This method is like `invert` except that the inverted object is generated
* from the results of running each element of `object` thru `iteratee`.
* The corresponding inverted value of each inverted key is an array of keys
* responsible for generating the inverted value.
* @param object - The object to invert
* @param iteratee - The iteratee invoked per element
* @returns Returns the new inverted object
*/
function invertBy<T>(
object: Record<PropertyKey, T>,
iteratee?: string | ((value: T) => PropertyKey)
): Record<string, string[]>;Invokes the method at path of object.
/**
* Invokes the method at `path` of `object`.
* @param object - The object to query
* @param path - The path of the method to invoke
* @param args - The arguments to invoke the method with
* @returns Returns the result of the invoked method
*/
function invoke(object: any, path: PropertyPath, ...args: any[]): any;Creates an array of the own enumerable property names of object.
/**
* Creates an array of the own enumerable property names of `object`.
* @param object - The object to query
* @returns Returns the array of property names
*/
function keys(object?: any): string[];Creates an array of the own and inherited enumerable property names of object.
/**
* Creates an array of the own and inherited enumerable property names of `object`.
* @param object - The object to query
* @returns Returns the array of property names
*/
function keysIn(object?: any): string[];Creates an object with the same values as object and keys generated by running each own enumerable string keyed property of object thru iteratee.
/**
* Creates an object with the same values as `object` and keys generated
* by running each own enumerable string keyed property of `object` thru
* `iteratee`. The iteratee is invoked with three arguments:
* (value, key, object).
* @param object - The object to iterate over
* @param iteratee - The function invoked per iteration
* @returns Returns the new mapped object
*/
function mapKeys<T>(
object: Record<string, T> | undefined,
iteratee?: string | ((value: T, key: string, object: Record<string, T>) => PropertyKey)
): Record<string, T>;Creates an object with the same keys as object and values generated by running each own enumerable string keyed property of object thru iteratee.
/**
* Creates an object with the same keys as `object` and values generated
* by running each own enumerable string keyed property of `object` thru
* `iteratee`. The iteratee is invoked with three arguments:
* (value, key, object).
* @param object - The object to iterate over
* @param iteratee - The function invoked per iteration
* @returns Returns the new mapped object
*/
function mapValues<T, R>(
object: Record<string, T> | undefined,
iteratee: string | ((value: T, key: string, object: Record<string, T>) => R)
): Record<string, R>;
function mapValues<T>(
object: Record<string, T> | undefined,
iteratee?: string
): Record<string, any>;Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object.
/**
* This method is like `assign` except that it recursively merges own and
* inherited enumerable string keyed properties of source objects into the
* destination object. Source properties that resolve to `undefined` are
* skipped if a destination value exists. Array and plain object properties
* are merged recursively.
* @param object - The destination object
* @param sources - The source objects
* @returns Returns `object`
*/
function merge<TObject, TSource>(object: TObject, source: TSource): TObject & TSource;
function merge<TObject, TSource1, TSource2>(object: TObject, source1: TSource1, source2: TSource2): TObject & TSource1 & TSource2;
function merge<TObject>(object: TObject, ...otherArgs: any[]): any;Like merge except that it accepts customizer which is invoked to produce the merged values of the destination and source properties.
/**
* This method is like `merge` except that it accepts `customizer` which
* is invoked to produce the merged values of the destination and source
* properties.
* @param object - The destination object
* @param sources - The source objects
* @param customizer - The function to customize assigned values
* @returns Returns `object`
*/
function mergeWith<TObject, TSource>(
object: TObject,
source: TSource,
customizer: (objValue: any, srcValue: any, key: string, object: TObject, source: TSource, stack: any) => any
): TObject & TSource;
function mergeWith<TObject>(object: TObject, ...otherArgs: any[]): any;Creates an object composed of the own and inherited enumerable property paths of object that are not omitted.
/**
* The opposite of `pick`; this method creates an object composed of the
* own and inherited enumerable property paths of `object` that are not omitted.
* @param object - The source object
* @param paths - The property paths to omit
* @returns Returns the new object
*/
function omit<T, K extends keyof T>(object: T, ...paths: K[]): Omit<T, K>;
function omit<T>(object: T, ...paths: PropertyPath[]): Partial<T>;The opposite of pickBy; this method creates an object composed of the own and inherited enumerable string keyed properties of object that predicate doesn't return truthy for.
/**
* The opposite of `pickBy`; this method creates an object composed of
* the own and inherited enumerable string keyed properties of `object` that
* `predicate` doesn't return truthy for. The predicate is invoked with two
* arguments: (value, key).
* @param object - The source object
* @param predicate - The function invoked per property
* @returns Returns the new object
*/
function omitBy<T>(
object: Record<string, T> | undefined,
predicate?: string | ((value: T, key: string) => boolean)
): Record<string, T>;Creates an object composed of the picked object properties.
/**
* Creates an object composed of the picked `object` properties.
* @param object - The source object
* @param paths - The property paths to pick
* @returns Returns the new object
*/
function pick<T, K extends keyof T>(object: T, ...paths: K[]): Pick<T, K>;
function pick<T>(object: T, ...paths: PropertyPath[]): Partial<T>;Creates an object composed of the object properties predicate returns truthy for.
/**
* Creates an object composed of the `object` properties `predicate` returns
* truthy for. The predicate is invoked with two arguments: (value, key).
* @param object - The source object
* @param predicate - The function invoked per property
* @returns Returns the new object
*/
function pickBy<T>(
object: Record<string, T> | undefined,
predicate?: string | ((value: T, key: string) => boolean)
): Record<string, T>;Gets the value at path of object.
/**
* This method is like `get` except that if the resolved value is a
* function it's invoked with the `this` binding of its parent object and
* its result is returned.
* @param object - The object to query
* @param path - The path of the property to resolve
* @param defaultValue - The value returned for `undefined` resolved values
* @returns Returns the resolved value
*/
function result<T>(object: any, path: PropertyPath, defaultValue?: T): T;Sets the value at path of object.
/**
* Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
* it's created. Arrays are created for missing index properties while objects
* are created for all other missing properties.
* @param object - The object to modify
* @param path - The path of the property to set
* @param value - The value to set
* @returns Returns `object`
*/
function set<T>(object: T, path: PropertyPath, value: any): T;Like set except that it accepts customizer which is invoked to produce the objects of path.
/**
* This method is like `set` except that it accepts `customizer` which is
* invoked to produce the objects of `path`.
* @param object - The object to modify
* @param path - The path of the property to set
* @param value - The value to set
* @param customizer - The function to customize assigned values
* @returns Returns `object`
*/
function setWith<T>(
object: T,
path: PropertyPath,
value: any,
customizer?: (nsValue: any, key: string, nsObject: T) => any
): T;Creates an array of own enumerable string keyed-value pairs for object.
/**
* Creates an array of own enumerable string keyed-value pairs for `object`
* which can be consumed by `fromPairs`. If `object` is a map or set, its
* entries are returned.
* @param object - The object to query
* @returns Returns the key-value pairs
*/
function toPairs<T>(object?: Record<PropertyKey, T>): Array<[string, T]>;Creates an array of own and inherited enumerable string keyed-value pairs for object.
/**
* Creates an array of own and inherited enumerable string keyed-value
* pairs for `object` which can be consumed by `fromPairs`.
* @param object - The object to query
* @returns Returns the key-value pairs
*/
function toPairsIn<T>(object?: Record<PropertyKey, T>): Array<[string, T]>;Converts value to a property path array.
/**
* Converts `value` to a property path array.
* @param value - The value to convert
* @returns Returns the new property path array
*/
function toPath(value: any): string[];An alternative to reduce; this method transforms object to a new accumulator object which is the result of running each of its own enumerable string keyed properties thru iteratee.
/**
* An alternative to `reduce`; this method transforms `object` to a new
* `accumulator` object which is the result of running each of its own
* enumerable string keyed properties thru `iteratee`, with each invocation
* potentially mutating the `accumulator` object.
* @param object - The object to iterate over
* @param iteratee - The function invoked per iteration
* @param accumulator - The custom accumulator value
* @returns Returns the accumulated value
*/
function transform<T, TResult>(
object: Record<string, T>,
iteratee: (accumulator: TResult, value: T, key: string, object: Record<string, T>) => void,
accumulator?: TResult
): TResult;
function transform<T, TResult>(
object: T[],
iteratee: (accumulator: TResult, value: T, index: number, array: T[]) => void,
accumulator?: TResult
): TResult;Removes the property at path of object.
/**
* Removes the property at `path` of `object`.
* @param object - The object to modify
* @param path - The path of the property to unset
* @returns Returns `true` if the property is deleted, else `false`
*/
function unset<T>(object: T, path: PropertyPath): boolean;This method is like set except that accepts updater to produce the value to set.
/**
* This method is like `set` except that accepts `updater` to produce the
* value to set. Use `updateWith` to customize `path` creation.
* @param object - The object to modify
* @param path - The path of the property to set
* @param updater - The function to produce the updated value
* @returns Returns `object`
*/
function update<T>(object: T, path: PropertyPath, updater: (value: any) => any): T;This method is like update except that it accepts customizer which is invoked to produce the objects of path.
/**
* This method is like `update` except that it accepts `customizer` which is
* invoked to produce the objects of `path`.
* @param object - The object to modify
* @param path - The path of the property to set
* @param updater - The function to produce the updated value
* @param customizer - The function to customize assigned values
* @returns Returns `object`
*/
function updateWith<T>(
object: T,
path: PropertyPath,
updater: (value: any) => any,
customizer?: (nsValue: any, key: string, nsObject: T) => any
): T;Creates an array of the own enumerable string keyed property values of object.
/**
* Creates an array of the own enumerable string keyed property values of `object`.
* @param object - The object to query
* @returns Returns the array of property values
*/
function values<T>(object?: Record<PropertyKey, T>): T[];Creates an array of the own and inherited enumerable string keyed property values of object.
/**
* Creates an array of the own and inherited enumerable string keyed property
* values of `object`.
* @param object - The object to query
* @returns Returns the array of property values
*/
function valuesIn<T>(object?: Record<PropertyKey, T>): T[];type PropertyPath = string | number | symbol | Array<string | number | symbol>;
type PropertyKey = string | number | symbol;entries → toPairsentriesIn → toPairsInextend → assignInextendWith → assignInWith