UNPKG

yini-parser

Version:

Readable configuration without YAML foot-guns or JSON noise. The official Node.js parser for YINI config format — An INI-inspired configuration format with clear nesting, explicit types, and predictable parsing.

68 lines (67 loc) 1.7 kB
interface SortOptions { /** Sort nested objects too (default: false) */ deep?: boolean; /** Custom key comparator (default: a.localeCompare(b)) */ comparator?: (a: string, b: string) => number; } /** * Returns a new object with keys sorted alphabetically. * Arrays and non-plain objects are preserved as-is (unless deep + they contain plain objects). */ export declare const sortObjectKeys: <T>(obj: T, options?: SortOptions) => T; /** * Removes top-level properties with value `undefined`. * Does not recurse into nested objects or arrays. * * @param obj Any JS object * @returns A shallow copy with undefined properties removed, * except in nested objects or arrays. * * @example * Input: * const input = { * a: 1, * b: undefined, * c: { d: undefined, e: 2 }, * f: [1, undefined, 2] * }; * * Output: * { * a: 1, * c: { d: undefined, e: 2 }, * f: [1, undefined, 2] * } */ export declare const removeUndefinedShallow: <T extends object>(obj: T) => Partial<T>; /** * Recursively removes properties with value `undefined` from objects * and arrays. * * @param obj Any JS value (object, array, primitive) * @returns A deep-cloned copy with all `undefined` removed, including in * nested objects and arrays. * * @example * Input: * const input = { * a: 1, * b: undefined, * c: { * d: undefined, * e: 2, * f: [1, undefined, { g: undefined, h: 42 }] * } * }; * * Output: * { * a: 1, * c: { * e: 2, * f: [1, { h: 42 }] * } * } */ export declare const removeUndefinedDeep: <T>(obj: T) => T; export {};