object-assign
Advanced tools
Comparing version 4.0.1 to 4.1.0
48
index.js
@@ -0,3 +1,3 @@ | ||
'use strict'; | ||
/* eslint-disable no-unused-vars */ | ||
'use strict'; | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
@@ -14,3 +14,47 @@ var propIsEnumerable = Object.prototype.propertyIsEnumerable; | ||
module.exports = Object.assign || function (target, source) { | ||
function shouldUseNative() { | ||
try { | ||
if (!Object.assign) { | ||
return false; | ||
} | ||
// Detect buggy property enumeration order in older V8 versions. | ||
// https://bugs.chromium.org/p/v8/issues/detail?id=4118 | ||
var test1 = new String('abc'); // eslint-disable-line | ||
test1[5] = 'de'; | ||
if (Object.getOwnPropertyNames(test1)[0] === '5') { | ||
return false; | ||
} | ||
// https://bugs.chromium.org/p/v8/issues/detail?id=3056 | ||
var test2 = {}; | ||
for (var i = 0; i < 10; i++) { | ||
test2['_' + String.fromCharCode(i)] = i; | ||
} | ||
var order2 = Object.getOwnPropertyNames(test2).map(function (n) { | ||
return test2[n]; | ||
}); | ||
if (order2.join('') !== '0123456789') { | ||
return false; | ||
} | ||
// https://bugs.chromium.org/p/v8/issues/detail?id=3056 | ||
var test3 = {}; | ||
'abcdefghijklmnopqrst'.split('').forEach(function (letter) { | ||
test3[letter] = letter; | ||
}); | ||
if (Object.keys(Object.assign({}, test3)).join('') !== | ||
'abcdefghijklmnopqrst') { | ||
return false; | ||
} | ||
return true; | ||
} catch (e) { | ||
// We don't expect any of the above to throw, but better to be safe. | ||
return false; | ||
} | ||
} | ||
module.exports = shouldUseNative() ? Object.assign : function (target, source) { | ||
var from; | ||
@@ -17,0 +61,0 @@ var to = toObject(target); |
{ | ||
"name": "object-assign", | ||
"version": "4.0.1", | ||
"description": "ES6 Object.assign() ponyfill", | ||
"version": "4.1.0", | ||
"description": "ES2015 Object.assign() ponyfill", | ||
"license": "MIT", | ||
@@ -10,3 +10,3 @@ "repository": "sindresorhus/object-assign", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "http://sindresorhus.com" | ||
"url": "sindresorhus.com" | ||
}, | ||
@@ -28,3 +28,3 @@ "engines": { | ||
"properties", | ||
"es6", | ||
"es2015", | ||
"ecmascript", | ||
@@ -39,13 +39,7 @@ "harmony", | ||
"devDependencies": { | ||
"lodash": "^3.10.1", | ||
"matcha": "^0.6.0", | ||
"lodash": "^4.8.2", | ||
"matcha": "^0.7.0", | ||
"mocha": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"envs": [ | ||
"node", | ||
"mocha" | ||
] | ||
} | ||
} |
# object-assign [![Build Status](https://travis-ci.org/sindresorhus/object-assign.svg?branch=master)](https://travis-ci.org/sindresorhus/object-assign) | ||
> ES6 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill | ||
> ES2015 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill | ||
@@ -10,3 +10,3 @@ > Ponyfill: A polyfill that doesn't overwrite the native method | ||
```sh | ||
``` | ||
$ npm install --save object-assign | ||
@@ -19,3 +19,3 @@ ``` | ||
```js | ||
var objectAssign = require('object-assign'); | ||
const objectAssign = require('object-assign'); | ||
@@ -48,7 +48,12 @@ objectAssign({foo: 0}, {bar: 1}); | ||
- [ES6 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign) | ||
- [ES2015 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign) | ||
## Related | ||
- [deep-assign](https://github.com/sindresorhus/deep-assign) - Recursive `Object.assign()` | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
5162
70
57
1