object-assign
Advanced tools
Comparing version 0.2.2 to 0.3.0
@@ -21,12 +21,17 @@ /*! | ||
var pendingException; | ||
var from; | ||
var keys; | ||
var to = ToObject(target); | ||
var from = ToObject(source); | ||
var keys = Object.keys(from); | ||
for (var i = 0; i < keys.length; i++) { | ||
try { | ||
to[keys[i]] = from[keys[i]]; | ||
} catch (err) { | ||
if (pendingException === undefined) { | ||
pendingException = err; | ||
for (var s = 1; s < arguments.length; s++) { | ||
from = ToObject(arguments[s]); | ||
keys = Object.keys(from) | ||
for (var i = 0; i < keys.length; i++) { | ||
try { | ||
to[keys[i]] = from[keys[i]]; | ||
} catch (err) { | ||
if (pendingException === undefined) { | ||
pendingException = err; | ||
} | ||
} | ||
@@ -33,0 +38,0 @@ } |
{ | ||
"name": "object-assign", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "ES6 Object.assign() ponyfill", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -32,3 +32,3 @@ # object-assign [![Build Status](https://travis-ci.org/sindresorhus/object-assign.svg?branch=master)](https://travis-ci.org/sindresorhus/object-assign) | ||
// multiple sources | ||
[{bar: 1}, {baz: 2}].reduce(objectAssign, {foo: 0}); | ||
objectAssign({foo: 0}, {bar: 1}, {baz: 3}); | ||
//=> {foo: 0, bar: 1, baz: 2} | ||
@@ -40,14 +40,7 @@ ``` | ||
### objectAssign(target, source) | ||
### objectAssign(target, source, [source, ...]) | ||
Assigns enumerable own properties of the `source` object to the `target` object and returns the `target` object. | ||
Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones. | ||
## Multiple sources | ||
Unfortunately support for multiple sources aren't defined in the Object.assign spec. | ||
However, you can easily achieve it with `[target, source, source, ...].reduce(objectAssign)`. | ||
## Resources | ||
@@ -54,0 +47,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44
2892
52