default-args

Software
Cover image

A simple function for providing defaults to an options 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.

favicon GitHub\ A simple function for providing default options to arguments. No dependencies, tiny amount of code. - GitHub - victornpb/default-args: A simple function for providing default options to arguments. ...\ https://github.com/victornpb/default-args