default-args
v1.0.1
Published
A simple function for providing defaults to an options argument. No dependencies, tiny amount of code.
Downloads
25
Maintainers
Readme
default-args
A simple function for providing defaults to an options to argument. No dependencies, tiny amount of code.
Usage
import defaults from 'default-args';
function helloWorld(options) {
options = defaults({
foo: true,
bar: {
a: 1,
b: 2,
},
}, options);
// do something with options
}
Installation
NPM
npm install default-args
Yarn
yarn add default-args
CDN
<script type="text/javascript" src="https://unpkg.com/default-args/"></script>
Packages
| File | Module Type | Transpiled | Source Maps | |---------------------------|-------------|------------|-------------| | dist/default-args.esm.mjs | esm | No | No | | dist/default-args.cjs.js | cjs | Yes | Yes | | dist/default-args.esm.js | esm | Yes | Yes | | dist/default-args.js | umd | Yes | Yes |
License
The code is available under the MIT license.
Contributing
We are open to contributions, see CONTRIBUTING.md for more info.