UNPKG

cerceis-lib

Version:

Contains list of quality of life functions that is written in TypeScript and es6

42 lines (40 loc) 1.56 kB
declare const FromObject: { /** * Convert an object into a 2D array ([[key, value], ...]). * @param inputObj Input object. */ ObjectToArray(inputObj: Record<string | number, unknown>): [string, unknown][]; /** * Flatten a multi-level object into a single level. * Duplicate keys are given a generated ID when overwriteKey is false. * @param obj Object to flatten. * @param overwriteKey Overwrite duplicate keys (default false). */ flatten(obj: object, overwriteKey?: boolean): Record<string, unknown>; /** * Find and return the deepest nested object. * Returns the first deepest object found; or all if multi = true. * @param obj Input object. * @param multi Return all objects at the deepest level. */ getDeepest(obj: object, multi?: boolean): object | object[]; /** * Sum all numeric values in an object (supports single-level nesting via field). * @param obj Input object. * @param field Target field when values are nested objects. */ sumAll(obj: object, field?: string): number; /** * Find the maximum numeric value in an object. * @param obj Input object. * @param field Target field when values are nested objects. */ max(obj: object, field?: string): number; /** * Find the minimum numeric value in an object. * @param obj Input object. * @param field Target field when values are nested objects. */ min(obj: object, field?: string): number | null; }; export { FromObject };