jsm-utilities
Version:
A utilities library.
50 lines (49 loc) • 2.2 kB
TypeScript
export declare const transformObjectToString: (obj: any) => any;
export declare function deepSanitizeObjectValues(value: any): any;
/**
* @since 11-12-2023 15:41:03
*/
export declare const flattenObjectKeys: (obj: Record<string, any>, prefix?: string) => string[];
/**
* @since 11-12-2023 15:41:10
*/
export declare const flattenObject: (obj: Record<string, any>, prefix?: string) => Record<string, any>;
/**
* Unflattens a flat object with dot notation keys into a nested object.
* Handles arrays with indices (e.g., "users[0].name").
* @param {Record<string, any>} flatObj - The flat object to unflatten.
* @returns {Record<string, any>} - The unflattened nested object.
*/
export declare function unflattenObject(flatObj: Record<string, any>): Record<string, any>;
export declare const extractPartialObject: <D extends object, P extends keyof D>(obj: D, properties: P[]) => Pick<D, P>;
export declare function deletePropertyRecursively<T extends object, P extends keyof T>(obj: T, property: P): void;
/**
* Update : added
* @author dr. Salmi <reevosolutions@gmail.com>
* @since 18-07-2024 21:24:07
*/
export declare const unflattenObjectArray: <T extends {
_id: string;
parent: string | null;
children: string[];
}>(items: T[]) => (T & {
children: T[];
})[];
/**
* Merges two objects deeply, excluding properties with null or undefined values.
* @param x - The first object to merge.
* @param y - The second object to merge.
* @returns The merged object.
*/
export declare function deepMergeUnlessNull<X extends object, Y extends object>(x: X, y: Y): X & Y;
/**
* Replaces null and undefined properties in the first object with values from the second object.
* @param x - The target object to modify.
* @param y - The source object with new values.
* @returns The modified target object.
*/
export declare function replaceNullAndUndefined<T>(x: T, y: Partial<T>): T;
/**
* Merge address data
*/
export declare function mergeAddresses(address1?: Partial<Jsm.Core.Utils.Entity.Snapshots.Locations.Address> | null, address2?: Partial<Jsm.Core.Utils.Entity.Snapshots.Locations.Address> | null): Jsm.Core.Utils.Entity.Snapshots.Locations.Address | undefined;