defaults
defaults<
R,P>(…args):R
Defined in: packages/core/src/object/defaults.ts:24
Assign default options to an object.
The first argument has the highest priority, the last argument the lowest.
Only properties that are undefined in the target object will be assigned
from the source objects.
This is equivalent to _.defaults from Lodash.
Type Parameters
Section titled “Type Parameters”R extends object
P extends Partial<R> = Partial<R>
Parameters
Section titled “Parameters”…[…(P | null | undefined)[], R]
The objects to merge.
Returns
Section titled “Returns”R
The merged object.
Example
Section titled “Example” const options = defaults({ a: 1 }, { a: 2, b: 2 }, { a: 3, b: 3, c: 3 });
console.log(options); // { a: 1, b: 2, c: 3 } ```;