UNPKG

@rxap/utilities

Version:

A collection of utility functions, types and interfaces.

23 lines (22 loc) 1.15 kB
/** * Removes a property from a nested object based on a dot-separated path. * * This function mutates the original object by deleting the property specified by the `path`. * If the path is invalid or does not exist in the object, no action is taken. * * @param obj The object from which the property will be removed. This should be a valid object. * @param path A dot-separated string indicating the nested path to the property that should be removed. * For example, "user.name" would target the `name` property inside the `user` object. * * @example * let myObj = { user: { name: "John", age: 30 } }; * RemoveFromObject(myObj, "user.name"); * // myObj now equals { user: { age: 30 } } * * @remarks * - The function does not return any value. * - If the `path` is an empty string or leads to a non-existent property, the function will not perform any operation. * - This function directly modifies the input object (`obj`), so no new object is created. * - The function handles only own properties of the object and does not traverse the prototype chain. */ export declare function RemoveFromObject(obj: any, path: string): void;