UNPKG

@blinkk/selective-edit

Version:
39 lines (38 loc) 1.24 kB
/** * Utility for working with deep object references. * * Example: obj.get('somthing.sub.key') would deeply reference the object. */ export declare class DeepObject { obj: Record<string, any>; constructor(obj?: Record<string, any>); /** * Allows for accessing nested values in an object with a single reference. * * @param key Period separated reference to the deep value. */ get(key: string): any; /** * Determine all of the 'key' references for a deep object. * * ``` * { foo: { bar: true } } => ['foo.bar'] * ``` */ keys(): Array<string>; protected keysForRecord(record: Record<string, any>, parentKeys: Array<string>): Array<string>; /** * Set a deep value on the object using a referenced key. * * @param key Period separated reference to the deep value. * @param value New value to set at the deep reference. */ set(key: string, value: any): void; /** * Updates the current object with the keys from a new value. * * @param value New object to be added to the existing object. */ update(value?: Record<string, any>): void; } export declare const autoDeepObject: (value: any) => DeepObject;