import { ObjectGeneric } from './types'; /** Return an object: * * with only selected fields * * OR without masked fields */ export declare function simpleObjectMaskOrSelect(object: Obj, maskedOrSelectedFields: (keyof Obj)[], mode?: 'mask' | 'select', deleteKeysInsteadOfReturningAnewObject?: boolean): Obj; /** * check if **object OR array** has property Safely (avoid cannot read property x of null and such) * @param {Object} obj object to test against * @param {string} addr `a.b.c.0.1` will test if myObject has props a that has prop b. Work wit arrays as well (like `arr.0`) */ export declare function has(obj: ObjectGeneric, addr: string): boolean | undefined; /** Find address in an object "a.b.c" IN { a : { b : {c : 'blah' }}} RETURNS 'blah' * @param obj * @param addr accept syntax like "obj.subItem.[0].sub2" OR "obj.subItem.0.sub2" OR "obj.subItem[0].sub2" * @returns the last item of the chain OR undefined if not found */ export declare function findByAddress(obj: ObjectGeneric, addr: string | string[]): any | undefined; type FindByAddressReturnFull = Array<[addr: string, value: any, lastElmKey: string, parent: any[] | Record]>; /** Will return all objects matching that path. Eg: user.*.myVar */ export declare function findByAddressAll(obj: Record, addr: string, returnAddresses?: ReturnAddresses): ReturnAddresses extends true ? FindByAddressReturnFull : Array; /** Enforce writing subItems. Eg: user.name.blah will ensure all are set until the writing of the last item * NOTE: doesn't work when parent is array */ export declare function objForceWrite>(obj: MainObj, addr: string, item: any, options?: { doNotWriteFinalValue?: boolean; }): MainObj; export declare function forcePathInObject>(obj: MainObj, addr: string): MainObj; export declare const objForceWritePath: typeof forcePathInObject; /** Enforce writing subItems, only if obj.addr is empty. * Eg: user.name.blah will ensure all are set until the writing of the last item * if user.name.blah has a value it will not change it. * NOTE: doesn't work when parent is array */ export declare function objForceWriteIfNotSet>(obj: MainObj, addr: string, item: any): MainObj; /** Merge mixins into class. Use it in the constructor like: mergeMixins(this, {myMixin: true}) */ export declare function mergeMixins(that: any, ...mixins: any[]): void; export declare function cloneObject>(o: MainObj): MainObj; /** Deep clone. WILL REMOVE circular references */ export declare function deepClone>(obj: MainObj, cache?: any[]): MainObj; /** * @param {Object} obj the object on which we want to filter the keys * @param {function} filterFunc function that returns true if the key match the wanted criteria */ export declare function filterKeys>(obj: MainObj, filter: any): MainObj; /** * @param {Object} obj the object on which we want to delete a property * @param {Array} addrArr addressArray on which to delete the property */ export declare function deleteByAddress(obj: object, addr: string | string[]): void; /** Remove all key/values pair if value is undefined */ export declare function objFilterUndefined>(o: MainObj): MainObj; /** Lock all 1st level props of an object to read only */ export declare function readOnly>(o: MainObj): { readonly [AA in keyof MainObj]: MainObj[AA]; }; /** Fields of the object can be created BUT NOT reassignated */ export declare function reassignForbidden(o: Record): Record; /** All fileds and subFields of the object will become readOnly */ export declare function readOnlyRecursive(object: Record): Record; /** @deprecated use readOnlyRecursive instead */ export declare const readOnlyForAll: typeof readOnlyRecursive; export declare function objFilterUndefinedRecursive(obj: Record): Record; export declare function sortObjKeyAccordingToValue(unorderedObj: Record, ascending?: boolean): Record; /** * Make default value if object key do not exist * @param {object} obj * @param {string} addr * @param {any} defaultValue * @param {function} callback (obj[addr]) => processValue. Eg: myObjAddr => myObjAddr.push('bikou') * @return obj[addr] eventually processed by the callback */ export declare function ensureObjectProp, Addr extends string>(obj: MainObj, addr: Addr, defaultValue: any, callback: (o: any) => any): MainObj[Addr]; /** object and array merge * @warn /!\ Array will be merged and duplicate values will be deleted /!\ * @return {Object} new object result from merge * NOTE: objects in params will NOT be modified*/ export declare function mergeDeep, O2 extends Record = Record, O3 extends Record = Record, O4 extends Record = Record, O5 extends Record = Record, O6 extends Record = Record>(...objects: [O1, O2?, O3?, O4?, O5?, O6?]): O1 & O2 & O3 & O4 & O5 & O6; /** object and array merge * @warn /!\ Array will be replaced by the latest object /!\ * @return {Object} new object result from merge * NOTE: objects in params will NOT be modified */ export declare function mergeDeepOverrideArrays, O2 extends Record = Record, O3 extends Record = Record, O4 extends Record = Record, O5 extends Record = Record, O6 extends Record = Record>(...objects: [O1, O2?, O3?, O4?, O5?, O6?]): O1 & O2 & O3 & O4 & O5 & O6; /** object and array merge * @param {Function} replacerForArrays item[key] = (prevValue, currentVal) => () When 2 values are arrays, * @param {Function} replacerForObjects item[key] = (prevValue, currentVal) => () When 2 values are objects, * @param {Function} replacerDefault item[key] = (prevValue, currentVal) => () For all other values * @param {...Object} objects * @return {Object} new object result from merge * NOTE: objects in params will NOT be modified */ export declare function mergeDeepConfigurable, O2 extends Record = Record, O3 extends Record = Record, O4 extends Record = Record, O5 extends Record = Record, O6 extends Record = Record>(replacerForArrays: ((_: any, curr: any) => any) | undefined, replacerForObjects: any, replacerDefault: ((_: any, curr: any) => any) | undefined, ...objects: [O1, O2?, O3?, O4?, O5?, O6?]): O1 & O2 & O3 & O4 & O5 & O6; /** { a: {b:2}} => {'a.b':2} useful for translations * NOTE: will remove circular references */ export declare function flattenObject(data: any, config?: { withoutArraySyntax?: boolean; withArraySyntaxMinified?: boolean; }): Record; /** {'a.b':2} => { a: {b:2}} */ export declare function unflattenObject(data: Record): Record; /** Mean to fix typing because type for Object.entries is not accurate. Ref: https://stackoverflow.com/questions/66565322/get-type-keys-in-typescript * /!\ THIS WILL REMOVE SYMBOL AND NUMBER FROM KEY TYPES as this is 99% of the time unwanted for generic objects */ export declare function objEntries>(obj: Obj): ObjEntries; /** Will remove Symbol and Number from keys types */ type ObjEntries = (K extends string ? [K, T[K]] : never)[]; /** Will remove Symbol and Number from keys types */ type StringKeys = keyof T extends infer K ? K extends string ? K : never : never; /** Mean to fix typing because type for Object.keys is not accurate */ export declare function objKeys>(obj: Obj): StringKeys[]; /** Will merge all arrays of an object into a single array */ export declare function mergeObjectArrays>(obj: T): T[keyof T][number][]; export declare const keys: typeof objKeys; export declare const entries: typeof objEntries; /** A Helper to create JavascriptProxies, will add __isProxy and toJSON helper to prevent error when logging the proxy and to be able to check if the object is proxyfied */ export declare function createProxy>(obj: T, optn: { get: Required>['get']; jsonRepresentation?: (obj: T) => string; }): T; /** Revert object keys and values. * @example revertObjectKeysAndValues({ a: 1, b: 2 }) => { 1: 'a', 2: 'b' } * @param obj Object to revert * @returns New object with keys and values swapped */ export declare function revertObjectKeysAndValues>(obj: T): { [K in keyof T as T[K]]: K; }; export {};