| [a762898] | 1 | /**
|
|---|
| 2 | * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.
|
|---|
| 3 | * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.
|
|---|
| 4 | *
|
|---|
| 5 | * @template T - The type of the object being processed.
|
|---|
| 6 | * @template S - The type of the object that provides default values.
|
|---|
| 7 | * @param {T} object - The target object that will receive default values.
|
|---|
| 8 | * @param {S} source - The object that specifies the default values to apply.
|
|---|
| 9 | * @returns {NonNullable<S & T>} The `object` that has been updated with default values from `source`.
|
|---|
| 10 | *
|
|---|
| 11 | * @example
|
|---|
| 12 | * defaults({ a: 1 }, { b: 2 }); // { a: 1, b: 2 }
|
|---|
| 13 | * defaults({ a: undefined }, { a: 1 }); // { a: 1 }
|
|---|
| 14 | */
|
|---|
| 15 | declare function defaults<T, S>(object: T, source: S): NonNullable<S & T>;
|
|---|
| 16 | /**
|
|---|
| 17 | * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.
|
|---|
| 18 | * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.
|
|---|
| 19 | *
|
|---|
| 20 | * @template T - The type of the object being processed.
|
|---|
| 21 | * @template S1 - The type of the first object that provides default values.
|
|---|
| 22 | * @template S2 - The type of the second object that provides default values.
|
|---|
| 23 | * @param {T} object - The target object that will receive default values.
|
|---|
| 24 | * @param {S1} source1 - The first object that specifies the default values to apply.
|
|---|
| 25 | * @param {S2} source2 - The second object that specifies the default values to apply.
|
|---|
| 26 | * @returns {NonNullable<S2 & S1 & T>} The `object` that has been updated with default values from `source1` and `source2`.
|
|---|
| 27 | *
|
|---|
| 28 | * @example
|
|---|
| 29 | * defaults({ a: 1 }, { b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 }
|
|---|
| 30 | * defaults({ a: undefined }, { a: 1 }, { b: 2 }); // { a: 1, b: 2 }
|
|---|
| 31 | */
|
|---|
| 32 | declare function defaults<T, S1, S2>(object: T, source1: S1, source2: S2): NonNullable<S2 & S1 & T>;
|
|---|
| 33 | /**
|
|---|
| 34 | * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.
|
|---|
| 35 | * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.
|
|---|
| 36 | *
|
|---|
| 37 | * @template T - The type of the object being processed.
|
|---|
| 38 | * @template S1 - The type of the first object that provides default values.
|
|---|
| 39 | * @template S2 - The type of the second object that provides default values.
|
|---|
| 40 | * @template S3 - The type of the third object that provides default values.
|
|---|
| 41 | * @param {T} object - The target object that will receive default values.
|
|---|
| 42 | * @param {S1} source1 - The first object that specifies the default values to apply.
|
|---|
| 43 | * @param {S2} source2 - The second object that specifies the default values to apply.
|
|---|
| 44 | * @param {S3} source3 - The third object that specifies the default values to apply.
|
|---|
| 45 | * @returns {NonNullable<S3 & S2 & S1 & T>} The `object` that has been updated with default values from `source1`, `source2`, and `source3`.
|
|---|
| 46 | *
|
|---|
| 47 | * @example
|
|---|
| 48 | * defaults({ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }); // { a: 1, b: 2, c: 3, d: 4 }
|
|---|
| 49 | * defaults({ a: undefined }, { a: 1 }, { b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 }
|
|---|
| 50 | */
|
|---|
| 51 | declare function defaults<T, S1, S2, S3>(object: T, source1: S1, source2: S2, source3: S3): NonNullable<S3 & S2 & S1 & T>;
|
|---|
| 52 | /**
|
|---|
| 53 | * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.
|
|---|
| 54 | * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.
|
|---|
| 55 | *
|
|---|
| 56 | * @template T - The type of the object being processed.
|
|---|
| 57 | * @template S1 - The type of the first object that provides default values.
|
|---|
| 58 | * @template S2 - The type of the second object that provides default values.
|
|---|
| 59 | * @template S3 - The type of the third object that provides default values.
|
|---|
| 60 | * @template S4 - The type of the fourth object that provides default values.
|
|---|
| 61 | * @param {T} object - The target object that will receive default values.
|
|---|
| 62 | * @param {S1} source1 - The first object that specifies the default values to apply.
|
|---|
| 63 | * @param {S2} source2 - The second object that specifies the default values to apply.
|
|---|
| 64 | * @param {S3} source3 - The third object that specifies the default values to apply.
|
|---|
| 65 | * @param {S4} source4 - The fourth object that specifies the default values to apply.
|
|---|
| 66 | * @returns {NonNullable<S4 & S3 & S2 & S1 & T>} The `object` that has been updated with default values from `source1`, `source2`, `source3`, and `source4`.
|
|---|
| 67 | *
|
|---|
| 68 | * @example
|
|---|
| 69 | * defaults({ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }, { e: 5 }); // { a: 1, b: 2, c: 3, d: 4, e: 5 }
|
|---|
| 70 | * defaults({ a: undefined }, { a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }); // { a: 1, b: 2, c: 3, d: 4 }
|
|---|
| 71 | */
|
|---|
| 72 | declare function defaults<T, S1, S2, S3, S4>(object: T, source1: S1, source2: S2, source3: S3, source4: S4): NonNullable<S4 & S3 & S2 & S1 & T>;
|
|---|
| 73 | /**
|
|---|
| 74 | * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.
|
|---|
| 75 | * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.
|
|---|
| 76 | *
|
|---|
| 77 | * @template T - The type of the object being processed.
|
|---|
| 78 | * @param {T} object - The target object that will receive default values.
|
|---|
| 79 | * @returns {NonNullable<T>} The `object` that has been updated with default values.
|
|---|
| 80 | *
|
|---|
| 81 | * @example
|
|---|
| 82 | * defaults({ a: 1 }); // { a: 1 }
|
|---|
| 83 | * defaults({ a: undefined }); // { a: undefined }
|
|---|
| 84 | */
|
|---|
| 85 | declare function defaults<T>(object: T): NonNullable<T>;
|
|---|
| 86 | /**
|
|---|
| 87 | * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.
|
|---|
| 88 | * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.
|
|---|
| 89 | *
|
|---|
| 90 | * @param {any} object - The target object that will receive default values.
|
|---|
| 91 | * @param {...any[]} sources - The objects that specify the default values to apply.
|
|---|
| 92 | * @returns {any} The `object` that has been updated with default values from `sources`.
|
|---|
| 93 | *
|
|---|
| 94 | * @example
|
|---|
| 95 | * defaults({}, { a: 1 }, { b: 2 }); // { a: 1, b: 2 }
|
|---|
| 96 | * defaults({ a: undefined }, { a: 1 }); // { a: 1 }
|
|---|
| 97 | */
|
|---|
| 98 | declare function defaults(object: any, ...sources: any[]): any;
|
|---|
| 99 |
|
|---|
| 100 | export { defaults };
|
|---|