@barchart/common-js
Version:
Library of common JavaScript utilities
58 lines (57 loc) • 1.67 kB
TypeScript
/**
* Utilities for working with objects.
*
* @public
* @module lang/object
*/
/**
* Performs "deep" equality check on two objects.
*
* Array items are compared, object properties are compared, and
* "primitive" values are checked using strict equality rules.
*
* @static
* @param {object} a
* @param {object} b
* @returns {boolean}
*/
export function equals(a: object, b: object): boolean;
/**
* Performs a "deep" copy.
*
* @static
* @param {object} source - The object to copy.
* @param {Function=} canExtract - An optional function which indicates if the "extractor" can be used.
* @param {Function=} extractor - An optional function which returns a cloned value for a property for assignment to the cloned
* @returns {object}
*/
export function clone(source: object, canExtract?: Function | undefined, extractor?: Function | undefined): object;
/**
* Creates a new object (or array) by performing a deep copy
* of the properties from each If the same property
* exists on both objects, the property value from the
* second object ("b") is preferred.
*
* @static
* @param {object} a
* @param {object} b
* @returns {object}
*/
export function merge(a: object, b: object): object;
/**
* Given an object, returns an array of "own" properties.
*
* @static
* @param {object} target - The object to interrogate.
* @returns {Array<string>}
*/
export function keys(target: object): Array<string>;
/**
* Given an object, returns a boolean value, indicating if the
* object has any "own" properties.
*
* @static
* @param {object} target - The object to interrogate.
* @returns {boolean}
*/
export function empty(target: object): boolean;