Skip to content

Commit

Permalink
Use a cached reducer function for Object.assign.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Apr 9, 2015
1 parent 04c5949 commit 49cf978
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions es6-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@
return o;
};


var numberConversion = (function () {
// from https://github.com/inexorabletash/polyfill/blob/master/typedarray.js#L176-L266
// with permission and license, per https://twitter.com/inexorabletash/status/372206509540659200
Expand Down Expand Up @@ -1064,18 +1063,19 @@
/*jshint elision: false */

if (supportsDescriptors) {
var assignReducer = function (target, source) {
return Object.keys(Object(source)).reduce(function (target, key) {
target[key] = source[key];
return target;
}, target);
};
var ObjectShims = {
// 19.1.3.1
assign: function (target, source) {
if (!ES.TypeIsObject(target)) {
throw new TypeError('target must be an object');
}
return Array.prototype.reduce.call(arguments, function (target, source) {
return Object.keys(Object(source)).reduce(function (target, key) {
target[key] = source[key];
return target;
}, target);
});
return Array.prototype.reduce.call(arguments, assignReducer);
},

is: function (a, b) {
Expand Down

0 comments on commit 49cf978

Please sign in to comment.