package
Easily handle defaults for your options
npm install defaultsGitHub-flavored package documentation.
Across all versions, last 30 days.
282,453,068 in 30 days
Runtime metadata.
Tagged topics.
Easily handle defaults for your options
npm install defaultsimport defaults from 'defaults';
const calculate = options => {
options = defaults(options, {
timeout: {
before: 100,
after: 100
}
});
console.log(options);
//=> {timeout: {before: 200, after: 100}}
// …
}
// …
calculate({timeout: {before: 200}});Deeply merges the given options with the specified defaults and returns a new object.
The given parameters are deep-cloned and never mutated.
Type: object
The user-provided options.
If the value is not a plain object, a new plain object will be used instead.
Type: object | undefined
The default options to use when a value is not provided in the options object.
options objectEstimated unpacked size across 1 packages.
5.5 kB
Includes dependencies.