Extend an object with the properties of other objects, but only if they don't already exist.
How is this different than extend or assign?
assign: "last one wins" - properties are updated or overwritten by new values.defaults: "first one wins" - only new properties are filled in.Install with npm
$ npm i defaults-shallow --save
var defaults = require('defaults-shallow');
defaults({a: 'b'}, {c: 'd'});
//=> {a: 'b', c: 'd'}
defaults({a: 'b'}, {a: 'c'});
//=> {a: 'b'}
To shallow clone you can use an empty object as the first argument:
var options = defaults({}, {a: 'b'}, {c: 'd'}, {a: 'f'});
//=> {a: 'b', c: 'd'}
extend but recursively copies only the missing properties/values to the target object. | homepageInstall dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on October 04, 2015.