UNPKG

@rxap/utilities

Version:

A collection of utility functions, types and interfaces.

27 lines (26 loc) 1.24 kB
/** * This function is used to assign a specific value to an object's property, based on a given path. * The path is a string of property keys separated by dots, representing a nested structure in the object. * * @export * @function SetToObject * * @param {any} obj - The original object on which a value needs to be set. This can be any JavaScript object. * * @param {string} path - The path is a string of property keys separated by dots ('.'). It represents the * sequence of nested properties leading to the one to which the value needs to be assigned. * For example, in the object `{ a: { b: { c: 0 } } }`, to set a value to the property 'c', * the path would be 'a.b.c'. * * @param {any} value - The value to be assigned to the property at the end of the path in the object. It can be of any type. * * @returns {void} - This function doesn't return anything. It modifies the original object as a side effect. * * @example * * const obj = { a: { b: { c: 0 } } }; * SetToObject(obj, 'a.b.c', 42); * console.log(obj); // logs: { a: { b: { c: 42 } } } * */ export declare function SetToObject(obj: any, path: string, value: any): void;