UNPKG

super-utils-plus

Version:

A superior alternative to Lodash with improved performance, TypeScript support, and developer experience

33 lines (32 loc) 1.08 kB
/** * Assigns own and inherited enumerable string keyed properties of source * objects to the destination object for all destination properties that * resolve to undefined. Source objects are applied from left to right. * Once a property is set, additional values of the same property are ignored. * * @param object - The destination object * @param sources - The source objects * @returns The destination object * * @example * ```ts * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } * ``` */ export declare function defaults<T extends object>(object: T, ...sources: Array<Partial<T>>): T; /** * This method is like defaults except that it recursively assigns * default properties. * * @param object - The destination object * @param sources - The source objects * @returns The destination object * * @example * ```ts * defaults({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); * // => { 'a': { 'b': 2, 'c': 3 } } * ``` */ export declare function defaultsDeep<T extends object>(object: T, ...sources: Array<Partial<T>>): T;