Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Apr 25, 2024 via pnpm

defaults 1.0.4

merge single level defaults over a config object
Package summary
Share
0
issues
1
license
2
MIT
Package created
3 Feb 2013
Version published
10 Oct 2022
Maintainers
1
Total deps
2
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
clone@1.0.4
defaults@1.0.4
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
β“˜ This is a list of defaults 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
clone1.0.44.35 kBMIT
prod

Visualizations

Frequently Asked Questions

What does defaults do?

The "defaults" npm package empowers JavaScript developers to handle defaults for their options efficiently. This package is distinct and practical because it doesn't overwrite options if they haven't been defined within the options object. Plus, it supports deep merging of objects while providing strong defense against prototype pollution attacks.

How do you use defaults?

To use the defaults package in your JavaScript application, follow these step-by-step instructions. Firstly, install the defaults package using npm with this command:

npm install defaults

Then, import defaults into your JavaScript file. You can apply defaults to your options objects. Here's an example:

import defaults from 'defaults';

const calculate = options => {
	options = defaults(options, {
		timeout: {
			before: 100,
			after: 100
		}
	});

	// Use options as per your requirements
	// …

}

// …

calculate({timeout: {before: 200}});

In this example, the calculate function accepts an options object. If no options are provided, or if certain options are missing, the defaults function will ensure that the options return with defined timeout before and after parameters, hence providing reliable default options.

Where are the defaults docs?

The documentation for the defaults npm package can be found on the package's GitHub page. Here, you can learn more about its API, installation, usage, and additional features. Importantly, the defaults function accepts two arguments, options and defaultOptions. The options object contains user-provided options, while the defaultOptions parameter hosts the default options to be returned when a value isn't provided in the options object.