Détail du package

@ndhoule/defaults

ndhoule104.8kMIT2.0.1

Copies owned, enumerable properties from a source object(s) to a target object when the value of that property on the source object is undefined.

component, defaults

readme

defaults CI

Copies owned, enumerable properties from a source object(s) to a target object when the value of that property on the source object is undefined.

Installation

$ component install ndhoule/defaults
$ npm install @ndhoule/defaults

API

defaults(target : Object, sources : ...Object) => Object

Copies owned, enumerable properties from a source object(s) to a target object when the value of that property on the source object is undefined.

var a = { a: 1 };
var b = { a: 2, b: 2 };

defaults(a, b);
console.log(a); //=> { a: 1, b: 2 }

defaults.deep(target : Object, sources : ...Object) => Object

Deeply copies owned, enumerable properties from a source object(s), recursing on object properties, to a target object when the value of that property on the source object is undefined.

var a = { a: 1, b: { c: 3 } };
var b = { a: 2, b: { d: 4 } };

defaults(a, b);
console.log(a); //=> { a: 1, b: { c: 3, d: 4} }

License

Released under the MIT license.

changelog

2.0.1

  • Bump @ndhoule/drop, @ndhoule/rest dependency to fix Browserify builds

2.0.0

  • Remove Component/Duo support

1.1.0

  • Add defaults.deep

1.0.1

  • Ensure npm@>=2.7.0 on Travis CI
  • Update Makefile

1.0.0

Initial release