@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
35 lines (34 loc) • 1.63 kB
TypeScript
/**
* Get a property value out of an object by providing the path to the property.
* @returns the property or object, following the given path, and the
* parent and last key to the parent object to be able to set it (see also setPropertyByPath).
*/
export declare const getPropertyByPath: (obj: any, path: string) => {
found: boolean;
object: any;
parentObject: any;
lastKey: string | null;
};
/**
* Sets the value of a property specified by a given path in an object.
* @returns true if the property was set successfully, false otherwise.
*/
export declare const setPropertyByPath: (obj: any, path: string, value: any) => boolean;
/**
* @returns a nested object from a given path of keys. The most deeply nested value will be an empty object.
*/
export declare const createObjectFromPath: (path: string) => Record<string, unknown>;
/**
* Deletes a property in an object and all its predecessors, if they otherwise would be empty objects.
*/
export declare const deletePropertyByPath: (obj: any, path: string) => void;
/**
* Merges the properties of two objects recursively. If properties in both objects
* are of type 'object', they will be merged deeply. Otherwise, properties in the
* second object will overwrite properties with the same keys in the first object.
*
* @param obj1 - The target object to be merged into.
* @param obj2 - The source object providing properties to merge.
* @returns The merged object containing properties from both input objects.
*/
export declare const mergeObjects: (obj1: Record<string, unknown>, obj2: Record<string, unknown>) => Record<string, unknown>;