@barchart/common-js
Version:
Library of common JavaScript utilities
53 lines (52 loc) • 2.33 kB
TypeScript
/**
* Utilities for reading and writing "complex" properties to
* objects. For example, the property "name.first" reads the
* "first" property on the "name" object of the target.
*
* @public
* @module lang/attributes
*/
/**
* Checks to see if an attribute exists on the target object.
*
* @public
* @static
* @param {object} target - The object to check for existence of the property.
* @param {string|string[]} propertyNames - The property to check -- either a string with separators, or an array of strings (already split by separator).
* @param {string=} separator - The separator (defaults to a period character).
* @returns {boolean}
*/
export function has(target: object, propertyNames: string | string[], separator?: string | undefined): boolean;
/**
* Returns a value from the target object. If the property doesn't exist; undefined
* is returned.
*
* @public
* @static
* @param {object} target - The object to read from.
* @param {string|string[]} propertyNames - The property to read -- either a string with separators, or an array of strings (already split by separator).
* @param {string=} separator - The separator (defaults to a period character).
* @returns {*}
*/
export function read(target: object, propertyNames: string | string[], separator?: string | undefined): any;
/**
* Writes a value to the target object.
*
* @public
* @static
* @param {object} target - The object to write to.
* @param {string|string[]} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
* @param {*} value - The value to assign.
* @param {string=} separator - The separator (defaults to a period character).
*/
export function write(target: object, propertyNames: string | string[], value: any, separator?: string | undefined): void;
/**
* Erases a property from the target object.
*
* @public
* @static
* @param {object} target - The object to erase a property from.
* @param {string|string} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
* @param {string=} separator - The separator (defaults to a period character).
*/
export function erase(target: object, propertyNames: string | string, separator?: string | undefined): void;