@orbit/utils
Version:
Core utilities for Orbit.
84 lines (83 loc) • 2.53 kB
TypeScript
/**
* Clones a value. If the value is an object, a deeply nested clone will be
* created.
*
* Traverses all object properties (but not prototype properties).
*/
export declare function clone(obj: any): any;
/**
* Expose properties and methods from one object on another.
*
* Methods will be called on `source` and will maintain `source` as the context.
*
* @deprecated since v0.17
*/
export declare function expose(destination: any, source: any): void;
/**
* Extend an object with the properties of one or more other objects.
*
* @deprecated since v0.17
*/
export declare function extend(destination: any, ...sources: any[]): any;
/**
* Converts an object to an `Array` if it's not already.
*
* @export
* @param {*} obj
* @returns {any[]}
*/
export declare function toArray(obj: unknown): any[];
/**
* Checks whether a value is a non-null object
*
* @export
* @param {*} obj
* @returns {boolean}
*/
export declare function isObject(obj: unknown): boolean;
/**
* Checks whether an object is null or undefined
*
* @export
* @param {*} obj
* @returns {boolean}
*/
export declare function isNone(obj: unknown): boolean;
/**
* Merges properties from other objects into a base object. Properties that
* resolve to `undefined` will not overwrite properties on the base object
* that already exist.
*
* @deprecated since v0.17
*/
export declare function merge(object: any, ...sources: any[]): any;
/**
* Merges properties from other objects into a base object, traversing and
* merging any objects that are encountered.
*
* Properties that resolve to `undefined` will not overwrite properties on the
* base object that already exist.
*/
export declare function deepMerge(object: any, ...sources: any[]): any;
/**
* Retrieves a value from a nested path on an object.
*
* Returns any falsy value encountered while traversing the path.
*/
export declare function deepGet(obj: any, path: string[]): any;
/**
* Sets a value on an object at a nested path.
*
* This function will create objects along the path if necessary to allow
* setting a deeply nested value.
*
* Returns `false` only if the current value is already strictly equal to the
* requested `value` argument. Otherwise returns `true`.
*/
export declare function deepSet(obj: any, path: string[], value: any): boolean;
/**
* Find an array of values that correspond to the keys of an object.
*
* This is a ponyfill for `Object.values`, which is still experimental.
*/
export declare function objectValues(obj: any): any[];