kibana/packages/elastic-safer-lodash-set/index.d.ts

65 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* This file is forked from the DefinitelyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped),
* and may include modifications made by Elasticsearch B.V.
* Elasticsearch B.V. licenses this file to you under the MIT License.
* See `packages/elastic-safer-lodash-set/LICENSE` for more information.
*/
export = SaferLodashSet;
export as namespace SaferLodashSet;
type Many<T> = T | readonly T[];
type PropertyName = string | number | symbol;
type PropertyPath = Many<PropertyName>;
type SetWithCustomizer<T> = (nsValue: any, key: string, nsObject: T) => any;
declare const SaferLodashSet: SaferLodashSet.SaferLoDashStatic;
declare namespace SaferLodashSet {
interface SaferLoDashStatic {
/**
* Sets the value at path of object. If a portion of path doesnt exist its
* created. Arrays are created for missing index properties while objects
* are created for all other missing properties. Use SaferLodashSet.setWith
* to customize path creation.
*
* @param object The object to modify.
* @param path The path of the property to set.
* @param value The value to set.
* @return Returns object.
*/
set<T extends object>(object: T, path: PropertyPath, value: any): T;
/**
* @see SaferLodashSet.set
*/
set<TResult>(object: object, path: PropertyPath, value: any): TResult;
/**
* This method is like SaferLodashSet.set except that it accepts customizer
* which is invoked to produce the objects of path. If customizer returns
* undefined path creation is handled by the method instead. The customizer
* is invoked with three arguments: (nsValue, key, nsObject).
*
* @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.
* @return Returns object.
*/
setWith<T extends object>(
object: T,
path: PropertyPath,
value: any,
customizer?: SetWithCustomizer<T>
): T;
/**
* @see SaferLodashSet.setWith
*/
setWith<T extends object, TResult>(
object: T,
path: PropertyPath,
value: any,
customizer?: SetWithCustomizer<T>
): TResult;
}
}