diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-04-30 18:30:11 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-04-30 18:30:11 +0200 |
commit | eb28c3b137c8a0d61377087c9a04b820151b0b7c (patch) | |
tree | c1ebf149f43fa653a4ef1c3f33df04557094e834 /js/vendor/es6-shim | |
parent | 2e54780c1496bfa39cd035b9ac40ed851d2198f1 (diff) |
update deps
Diffstat (limited to 'js/vendor/es6-shim')
-rw-r--r-- | js/vendor/es6-shim/.bower.json | 8 | ||||
-rw-r--r-- | js/vendor/es6-shim/CHANGELOG.md | 17 | ||||
-rw-r--r-- | js/vendor/es6-shim/bower.json | 2 | ||||
-rw-r--r-- | js/vendor/es6-shim/component.json | 2 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-sham.js | 20 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-sham.map | 2 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-sham.min.js | 2 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-shim.js | 500 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-shim.map | 2 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-shim.min.js | 5 | ||||
-rw-r--r-- | js/vendor/es6-shim/package.json | 6 |
11 files changed, 319 insertions, 247 deletions
diff --git a/js/vendor/es6-shim/.bower.json b/js/vendor/es6-shim/.bower.json index ab5d66177..354c79ee2 100644 --- a/js/vendor/es6-shim/.bower.json +++ b/js/vendor/es6-shim/.bower.json @@ -1,6 +1,6 @@ { "name": "es6-shim", - "version": "0.28.2", + "version": "0.30.0", "repo": "paulmillr/es6-shim", "description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines", "keywords": [ @@ -28,11 +28,11 @@ "test" ], "homepage": "https://github.com/paulmillr/es6-shim", - "_release": "0.28.2", + "_release": "0.30.0", "_resolution": { "type": "version", - "tag": "0.28.2", - "commit": "f5a6b47afa92d81e38fe1e6e40854f07dcbe1ef8" + "tag": "0.30.0", + "commit": "ba581d8a4b9c1bdbadc71188d18a011f6be638a0" }, "_source": "git://github.com/paulmillr/es6-shim.git", "_target": "~0.*", diff --git a/js/vendor/es6-shim/CHANGELOG.md b/js/vendor/es6-shim/CHANGELOG.md index 7e71f6732..976cdef7b 100644 --- a/js/vendor/es6-shim/CHANGELOG.md +++ b/js/vendor/es6-shim/CHANGELOG.md @@ -1,5 +1,22 @@ # es6-shim x.x.x (not yet released) +# es6-shim 0.30.0 (26 Apr 2015) +* `Map` and `Set` methods are not generic, and must only be called on valid `Map` and `Set` objects. +* Use the native `Number#clz` (in Safari 8, eg) inside `Math.clz32` + +# es6-shim 0.29.0 (26 Apr 2015) +* Test on `io.js` `v1.7` and `v1.8` +* Ensure that shallowly wrapped Maps’ and Sets’ prototypes aren't one level too far away. +* Update `chai` and use new matchers +* Avoid reassigning argument variables to avoid deoptimizations +* Ensure that ES3 browsers get both `Object.is` and `Object.assign` +* Improve `Object.assign` to avoid leaking arguments in v8 +* Ensuring `Number.parseInt === parseInt` (failed in FF 37) +* a little more accurate Math.cbrt (#335) +* Test cleanups +* Adding `Symbol.unscopables` tests +* Adding tests to ensure that default iterators on builtins === the appropriate prototype function. + # es6-shim 0.28.2 (13 Apr 2015) * `Map` and `Set` should have an arity of 0. diff --git a/js/vendor/es6-shim/bower.json b/js/vendor/es6-shim/bower.json index 2f5415ca4..386992c6b 100644 --- a/js/vendor/es6-shim/bower.json +++ b/js/vendor/es6-shim/bower.json @@ -1,6 +1,6 @@ { "name": "es6-shim", - "version": "0.28.2", + "version": "0.30.0", "repo": "paulmillr/es6-shim", "description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines", "keywords": [ diff --git a/js/vendor/es6-shim/component.json b/js/vendor/es6-shim/component.json index d74d3ace0..7e18ff677 100644 --- a/js/vendor/es6-shim/component.json +++ b/js/vendor/es6-shim/component.json @@ -1,6 +1,6 @@ { "name": "es6-shim", - "version": "0.28.2", + "version": "0.30.0", "repo": "paulmillr/es6-shim", "description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines", "keywords": [ diff --git a/js/vendor/es6-shim/es6-sham.js b/js/vendor/es6-shim/es6-sham.js index 105f09d16..570deb3f0 100644 --- a/js/vendor/es6-shim/es6-sham.js +++ b/js/vendor/es6-shim/es6-sham.js @@ -48,8 +48,16 @@ /*jshint proto: true */ // @author Andrea Giammarchi - @WebReflection - // define into target descriptors from source + + var getOwnPropertyNames = Object.getOwnPropertyNames; + var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var create = Object.create; + var defineProperty = Object.defineProperty; + var getPrototypeOf = Object.getPrototypeOf; + var objProto = Object.prototype; + var copyDescriptors = function (target, source) { + // define into target descriptors from source getOwnPropertyNames(source).forEach(function (key) { defineProperty( target, @@ -63,17 +71,11 @@ var createAndCopy = function (origin, proto) { return copyDescriptors(create(proto), origin); }; - var create = Object.create; - var defineProperty = Object.defineProperty; - var getPrototypeOf = Object.getPrototypeOf; - var getOwnPropertyNames = Object.getOwnPropertyNames; - var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - var proto = Object.prototype; var set, setPrototypeOf; try { // this might fail for various reasons // ignore if Chrome cought it at runtime - set = getOwnPropertyDescriptor(proto, '__proto__').set; + set = getOwnPropertyDescriptor(objProto, '__proto__').set; set.call({}, null); // setter not poisoned, it can promote // Firefox, Chrome @@ -90,7 +92,7 @@ setPrototypeOf = createAndCopy; } else { // verify if null objects are buggy - set.__proto__ = proto; + set.__proto__ = objProto; // if null objects are buggy // nodejs 0.8 to 0.10 if (set instanceof Object) { diff --git a/js/vendor/es6-shim/es6-sham.map b/js/vendor/es6-shim/es6-sham.map index 6a2279c83..1e11c311a 100644 --- a/js/vendor/es6-shim/es6-sham.map +++ b/js/vendor/es6-shim/es6-sham.map @@ -1 +1 @@ -{"version":3,"sources":["es6-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","getGlobal","Function","globals","Object","setPrototypeOf","copyDescriptors","target","source","getOwnPropertyNames","forEach","key","defineProperty","getOwnPropertyDescriptor","createAndCopy","origin","proto","create","getPrototypeOf","prototype","set","call","e","__proto__"],"mappings":";;;;;;;;;CAYC,SAAUA,EAAMC,GAEf,SAAWC,UAAW,YAAcA,OAAOC,IAAK,CAE9CD,OAAOD,OACF,UAAWG,WAAY,SAAU,CAItCC,OAAOD,QAAUH,QACZ,CAELD,EAAKM,cAAgBL,OAEvBM,KAAM,WACN,YAGA,IAAIC,GAAY,GAAIC,UAAS,eAG7B,IAAIC,GAAUF,GACd,IAAIG,GAASD,EAAQC,QAWpB,WACC,GAAIA,EAAOC,eAAgB,CAAE,OAK7B,GAAIC,GAAkB,SAAUC,EAAQC,GACtCC,EAAoBD,GAAQE,QAAQ,SAAUC,GAC5CC,EACEL,EACAI,EACAE,EAAyBL,EAAQG,KAGrC,OAAOJ,GAGT,IAAIO,GAAgB,SAAUC,EAAQC,GACpC,MAAOV,GAAgBW,EAAOD,GAAQD,GAExC,IAAIE,GAASb,EAAOa,MACpB,IAAIL,GAAiBR,EAAOQ,cAC5B,IAAIM,GAAiBd,EAAOc,cAC5B,IAAIT,GAAsBL,EAAOK,mBACjC,IAAII,GAA2BT,EAAOS,wBACtC,IAAIG,GAAQZ,EAAOe,SACnB,IAAIC,GAAKf,CACT,KAGEe,EAAMP,EAAyBG,EAAO,aAAaI,GACnDA,GAAIC,QAAS,KAGbhB,GAAiB,SAAUU,EAAQC,GACjCI,EAAIC,KAAKN,EAAQC,EACjB,OAAOD,IAET,MAAOO,GAEPF,GAAOG,UAAW,KAGlB,IAAIH,YAAehB,GAAQ,CACzBC,EAAiBS,MACZ,CAELM,EAAIG,UAAYP,CAGhB,IAAII,YAAehB,GAAQ,CACzBC,EAAiB,SAAUU,EAAQC,GAEjCD,EAAOQ,UAAYP,CACnB,OAAOD,QAEJ,CAGLV,EAAiB,SAAUU,EAAQC,GAEjC,MAAOE,GAAeH,IAElBA,EAAOQ,UAAYP,EAAQD,GAE7BD,EAAcC,EAAQC,MAKhCZ,EAAOC,eAAiBA"}
\ No newline at end of file +{"version":3,"sources":["es6-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","getGlobal","Function","globals","Object","setPrototypeOf","getOwnPropertyNames","getOwnPropertyDescriptor","create","defineProperty","getPrototypeOf","objProto","prototype","copyDescriptors","target","source","forEach","key","createAndCopy","origin","proto","set","call","e","__proto__"],"mappings":";;;;;;;;;CAYC,SAAUA,EAAMC,GAEf,SAAWC,UAAW,YAAcA,OAAOC,IAAK,CAE9CD,OAAOD,OACF,UAAWG,WAAY,SAAU,CAItCC,OAAOD,QAAUH,QACZ,CAELD,EAAKM,cAAgBL,OAEvBM,KAAM,WACN,YAGA,IAAIC,GAAY,GAAIC,UAAS,eAG7B,IAAIC,GAAUF,GACd,IAAIG,GAASD,EAAQC,QAWpB,WACC,GAAIA,EAAOC,eAAgB,CAAE,OAK7B,GAAIC,GAAsBF,EAAOE,mBACjC,IAAIC,GAA2BH,EAAOG,wBACtC,IAAIC,GAASJ,EAAOI,MACpB,IAAIC,GAAiBL,EAAOK,cAC5B,IAAIC,GAAiBN,EAAOM,cAC5B,IAAIC,GAAWP,EAAOQ,SAEtB,IAAIC,GAAkB,SAAUC,EAAQC,GAEtCT,EAAoBS,GAAQC,QAAQ,SAAUC,GAC5CR,EACEK,EACAG,EACAV,EAAyBQ,EAAQE,KAGrC,OAAOH,GAGT,IAAII,GAAgB,SAAUC,EAAQC,GACpC,MAAOP,GAAgBL,EAAOY,GAAQD,GAExC,IAAIE,GAAKhB,CACT,KAGEgB,EAAMd,EAAyBI,EAAU,aAAaU,GACtDA,GAAIC,QAAS,KAGbjB,GAAiB,SAAUc,EAAQC,GACjCC,EAAIC,KAAKH,EAAQC,EACjB,OAAOD,IAET,MAAOI,GAEPF,GAAOG,UAAW,KAGlB,IAAIH,YAAejB,GAAQ,CACzBC,EAAiBa,MACZ,CAELG,EAAIG,UAAYb,CAGhB,IAAIU,YAAejB,GAAQ,CACzBC,EAAiB,SAAUc,EAAQC,GAEjCD,EAAOK,UAAYJ,CACnB,OAAOD,QAEJ,CAGLd,EAAiB,SAAUc,EAAQC,GAEjC,MAAOV,GAAeS,IAElBA,EAAOK,UAAYJ,EAAQD,GAE7BD,EAAcC,EAAQC,MAKhChB,EAAOC,eAAiBA"}
\ No newline at end of file diff --git a/js/vendor/es6-shim/es6-sham.min.js b/js/vendor/es6-shim/es6-sham.min.js index dba4ecc9e..dffa33876 100644 --- a/js/vendor/es6-shim/es6-sham.min.js +++ b/js/vendor/es6-shim/es6-sham.min.js @@ -7,5 +7,5 @@ * Details and documentation: * https://github.com/paulmillr/es6-shim/ */ -(function(t,e){if(typeof define==="function"&&define.amd){define(e)}else if(typeof exports==="object"){module.exports=e()}else{t.returnExports=e()}})(this,function(){"use strict";var t=new Function("return this;");var e=t();var r=e.Object;(function(){if(r.setPrototypeOf){return}var t=function(t,e){i(e).forEach(function(r){o(t,r,c(e,r))});return t};var e=function(e,r){return t(n(r),e)};var n=r.create;var o=r.defineProperty;var f=r.getPrototypeOf;var i=r.getOwnPropertyNames;var c=r.getOwnPropertyDescriptor;var u=r.prototype;var a,_;try{a=c(u,"__proto__").set;a.call({},null);_=function(t,e){a.call(t,e);return t}}catch(p){a={__proto__:null};if(a instanceof r){_=e}else{a.__proto__=u;if(a instanceof r){_=function(t,e){t.__proto__=e;return t}}else{_=function(t,r){return f(t)?(t.__proto__=r,t):e(t,r)}}}}r.setPrototypeOf=_})()}); +(function(t,e){if(typeof define==="function"&&define.amd){define(e)}else if(typeof exports==="object"){module.exports=e()}else{t.returnExports=e()}})(this,function(){"use strict";var t=new Function("return this;");var e=t();var r=e.Object;(function(){if(r.setPrototypeOf){return}var t=r.getOwnPropertyNames;var e=r.getOwnPropertyDescriptor;var n=r.create;var o=r.defineProperty;var f=r.getPrototypeOf;var i=r.prototype;var c=function(r,n){t(n).forEach(function(t){o(r,t,e(n,t))});return r};var u=function(t,e){return c(n(e),t)};var a,_;try{a=e(i,"__proto__").set;a.call({},null);_=function(t,e){a.call(t,e);return t}}catch(p){a={__proto__:null};if(a instanceof r){_=u}else{a.__proto__=i;if(a instanceof r){_=function(t,e){t.__proto__=e;return t}}else{_=function(t,e){return f(t)?(t.__proto__=e,t):u(t,e)}}}}r.setPrototypeOf=_})()}); //# sourceMappingURL=es6-sham.map
\ No newline at end of file diff --git a/js/vendor/es6-shim/es6-shim.js b/js/vendor/es6-shim/es6-shim.js index 6cde64919..1ab73a3ea 100644 --- a/js/vendor/es6-shim/es6-shim.js +++ b/js/vendor/es6-shim/es6-shim.js @@ -47,6 +47,46 @@ }; var isCallableWithoutNew = not(throwsError); + var arePropertyDescriptorsSupported = function () { + // if Object.defineProperty exists but throws, it's IE 8 + return !throwsError(function () { Object.defineProperty({}, 'x', {}); }); + }; + var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported(); + + var defineProperty = function (object, name, value, force) { + if (!force && name in object) { return; } + if (supportsDescriptors) { + Object.defineProperty(object, name, { + configurable: true, + enumerable: false, + writable: true, + value: value + }); + } else { + object[name] = value; + } + }; + + // Define configurable, writable and non-enumerable props + // if they don’t exist. + var defineProperties = function (object, map) { + Object.keys(map).forEach(function (name) { + var method = map[name]; + defineProperty(object, name, method, false); + }); + }; + + // Simple shim for Object.create on ES3 browsers + // (unlike real shim, no attempt to support `prototype === null`) + var create = Object.create || function (prototype, properties) { + function Prototype() {} + Prototype.prototype = prototype; + var object = new Prototype(); + if (typeof properties !== 'undefined') { + defineProperties(object, properties); + } + return object; + }; var supportsSubclassing = function (C, f) { if (!Object.setPrototypeOf) { return false; /* skip test on IE < 11 */ } @@ -63,11 +103,6 @@ }); }; - var arePropertyDescriptorsSupported = function () { - // if Object.defineProperty exists but throws, it's IE 8 - return !throwsError(function () { Object.defineProperty({}, 'x', {}); }); - }; - var startsWithRejectsRegex = function () { return String.prototype.startsWith && throwsError(function () { /* throws if spec-compliant */ @@ -84,7 +119,6 @@ var globals = getGlobal(); var globalIsFinite = globals.isFinite; - var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported(); var hasStrictMode = (function () { return this === null; }.call(null)); var startsWithIsCompliant = startsWithRejectsRegex() && startsWithHandlesInfinity; var _indexOf = Function.call.bind(String.prototype.indexOf); @@ -116,20 +150,6 @@ return typeof value === 'number' && globalIsFinite(value); }; - var defineProperty = function (object, name, value, force) { - if (!force && name in object) { return; } - if (supportsDescriptors) { - Object.defineProperty(object, name, { - configurable: true, - enumerable: false, - writable: true, - value: value - }); - } else { - object[name] = value; - } - }; - var Value = { getter: function (object, name, getter) { if (!supportsDescriptors) { @@ -167,25 +187,10 @@ } }; - // Define configurable, writable and non-enumerable props - // if they don’t exist. - var defineProperties = function (object, map) { - Object.keys(map).forEach(function (name) { - var method = map[name]; - defineProperty(object, name, method, false); - }); - }; - - // Simple shim for Object.create on ES3 browsers - // (unlike real shim, no attempt to support `prototype === null`) - var create = Object.create || function (prototype, properties) { - function Prototype() {} - Prototype.prototype = prototype; - var object = new Prototype(); - if (typeof properties !== 'undefined') { - defineProperties(object, properties); - } - return object; + var overrideNative = function overrideNative(object, property, replacement) { + var original = object[property]; + defineProperty(object, property, replacement, true); + Value.preserveToString(object[property], original); }; // This is a private name in the es6 spec, equal to '[Symbol.iterator]' @@ -201,13 +206,13 @@ $iterator$ = '@@iterator'; } var addIterator = function (prototype, impl) { - if (!impl) { impl = function iterator() { return this; }; } + var implementation = impl || function iterator() { return this; }; var o = {}; - o[$iterator$] = impl; + o[$iterator$] = implementation; defineProperties(prototype, o); if (!prototype[$iterator$] && Type.symbol($iterator$)) { // implementations are buggy when $iterator$ is a Symbol - prototype[$iterator$] = impl; + prototype[$iterator$] = implementation; } }; @@ -367,24 +372,25 @@ var emulateES6construct = function (o) { if (!ES.TypeIsObject(o)) { throw new TypeError('bad object'); } + var object = o; // es5 approximation to es6 subclass semantics: in es6, 'new Foo' // would invoke Foo.@@species to allocation/initialize the new object. // In es5 we just get the plain object. So if we detect an // uninitialized object, invoke o.constructor.@@species - if (!o._es6construct) { - if (o.constructor && ES.IsCallable(o.constructor[symbolSpecies])) { - o = o.constructor[symbolSpecies](o); + if (!object._es6construct) { + if (object.constructor && ES.IsCallable(object.constructor[symbolSpecies])) { + object = object.constructor[symbolSpecies](object); } - defineProperties(o, { _es6construct: true }); + defineProperties(object, { _es6construct: true }); } - return o; + return object; }; // Firefox 31 reports this function's length as 0 // https://bugzilla.mozilla.org/show_bug.cgi?id=1062484 if (String.fromCodePoint && String.fromCodePoint.length !== 1) { var originalFromCodePoint = Function.apply.bind(String.fromCodePoint); - defineProperty(String, 'fromCodePoint', function fromCodePoint(codePoints) { return originalFromCodePoint(this, arguments); }, true); + overrideNative(String, 'fromCodePoint', function fromCodePoint(codePoints) { return originalFromCodePoint(this, arguments); }); } var StringShims = { @@ -438,9 +444,7 @@ defineProperties(String, StringShims); if (String.raw({ raw: { 0: 'x', 1: 'y', length: 2 } }) !== 'xy') { // IE 11 TP has a broken String.raw implementation - var origStringRaw = String.raw; - defineProperty(String, 'raw', StringShims.raw, true); - Value.preserveToString(String.raw, origStringRaw); + overrideNative(String, 'raw', StringShims.raw); } // Fast repeat, uses the `Exponentiation by squaring` algorithm. @@ -457,32 +461,32 @@ repeat: function repeat(times) { ES.RequireObjectCoercible(this); var thisStr = String(this); - times = ES.ToInteger(times); - if (times < 0 || times >= stringMaxLength) { + var numTimes = ES.ToInteger(times); + if (numTimes < 0 || numTimes >= stringMaxLength) { throw new RangeError('repeat count must be less than infinity and not overflow maximum string size'); } - return stringRepeat(thisStr, times); + return stringRepeat(thisStr, numTimes); }, - startsWith: function startsWith(searchStr) { + startsWith: function startsWith(searchString) { ES.RequireObjectCoercible(this); var thisStr = String(this); - if (Type.regex(searchStr)) { + if (Type.regex(searchString)) { throw new TypeError('Cannot call method "startsWith" with a regex'); } - searchStr = String(searchStr); + var searchStr = String(searchString); var startArg = arguments.length > 1 ? arguments[1] : void 0; var start = Math.max(ES.ToInteger(startArg), 0); return thisStr.slice(start, start + searchStr.length) === searchStr; }, - endsWith: function endsWith(searchStr) { + endsWith: function endsWith(searchString) { ES.RequireObjectCoercible(this); var thisStr = String(this); - if (Type.regex(searchStr)) { + if (Type.regex(searchString)) { throw new TypeError('Cannot call method "endsWith" with a regex'); } - searchStr = String(searchStr); + var searchStr = String(searchString); var thisLen = thisStr.length; var posArg = arguments.length > 1 ? arguments[1] : void 0; var pos = typeof posArg === 'undefined' ? thisLen : ES.ToInteger(posArg); @@ -514,9 +518,7 @@ defineProperties(String.prototype, StringPrototypeShims); if ('a'.includes('a', Infinity) !== false) { - var origIncludes = String.prototype.includes; - defineProperty(String.prototype, 'includes', StringPrototypeShims.includes, true); - Value.preserveToString(String.prototype.includes, origIncludes); + overrideNative(String.prototype, 'includes', StringPrototypeShims.includes); } var hasStringTrimBug = '\u0085'.trim().length !== 1; @@ -569,8 +571,8 @@ if (!startsWithIsCompliant) { // Firefox (< 37?) and IE 11 TP have a noncompliant startsWith implementation - defineProperty(String.prototype, 'startsWith', StringPrototypeShims.startsWith, true); - defineProperty(String.prototype, 'endsWith', StringPrototypeShims.endsWith, true); + overrideNative(String.prototype, 'startsWith', StringPrototypeShims.startsWith); + overrideNative(String.prototype, 'endsWith', StringPrototypeShims.endsWith); } var ArrayShims = { @@ -741,9 +743,7 @@ return fooArr instanceof Foo && fooArr.length === 2; }()); if (!arrayOfSupportsSubclassing) { - var origArrayOf = Array.of; - defineProperty(Array, 'of', ArrayShims.of, true); - Value.preserveToString(Array.of, origArrayOf); + overrideNative(Array, 'of', ArrayShims.of); } var ArrayPrototypeShims = { @@ -751,10 +751,10 @@ var end = arguments[2]; // copyWithin.length must be 2 var o = ES.ToObject(this); var len = ES.ToLength(o.length); - target = ES.ToInteger(target); - start = ES.ToInteger(start); - var to = target < 0 ? Math.max(len + target, 0) : Math.min(target, len); - var from = start < 0 ? Math.max(len + start, 0) : Math.min(start, len); + var relativeTarget = ES.ToInteger(target); + var relativeStart = ES.ToInteger(start); + var to = relativeTarget < 0 ? Math.max(len + relativeTarget, 0) : Math.min(relativeTarget, len); + var from = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len); end = typeof end === 'undefined' ? len : ES.ToInteger(end); var fin = end < 0 ? Math.max(len + end, 0) : Math.min(end, len); var count = Math.min(fin - from, len - to); @@ -861,9 +861,8 @@ // Chrome 40 defines Array#values with the incorrect name, although Array#{keys,entries} have the correct name if (Array.prototype.values && Array.prototype.values.name !== 'values') { var originalArrayPrototypeValues = Array.prototype.values; - defineProperty(Array.prototype, 'values', function values() { return originalArrayPrototypeValues.call(this); }, true); + overrideNative(Array.prototype, 'values', function values() { return originalArrayPrototypeValues.call(this); }); defineProperty(Array.prototype, $iterator$, Array.prototype.values, true); - Value.preserveToString(Array.prototype.values, originalArrayPrototypeValues); } defineProperties(Array.prototype, ArrayPrototypeShims); @@ -875,20 +874,18 @@ } // note: this is positioned here because it relies on Array#entries - var arrayFromSwallowsNegativeLengths = function () { + var arrayFromSwallowsNegativeLengths = (function () { // Detects a Firefox bug in v32 // https://bugzilla.mozilla.org/show_bug.cgi?id=1063993 return valueOrFalseIfThrows(function () { return Array.from({ length: -1 }).length === 0; }); - }; + }()); var arrayFromHandlesIterables = (function () { // Detects a bug in Webkit nightly r181886 var arr = Array.from([0].entries()); return arr.length === 1 && arr[0][0] === 0 && arr[0][1] === 1; }()); - if (!arrayFromSwallowsNegativeLengths() || !arrayFromHandlesIterables) { - var origArrayFrom = Array.from; - defineProperty(Array, 'from', ArrayShims.from, true); - Value.preserveToString(Array.from, origArrayFrom); + if (!arrayFromSwallowsNegativeLengths || !arrayFromHandlesIterables) { + overrideNative(Array, 'from', ArrayShims.from); } var maxSafeInteger = Math.pow(2, 53) - 1; @@ -912,6 +909,8 @@ isNaN: numberIsNaN }); + // Firefox 37 has a conforming Number.parseInt, but it's not === to the global parseInt (fixed in v40) + defineProperty(Number, 'parseInt', globals.parseInt, Number.parseInt !== globals.parseInt); // Work around bugs in Array#find and Array#findIndex -- early // implementations skipped holes in sparse arrays. (Note that the @@ -919,41 +918,72 @@ // methods of Number, so this test has to happen down here.) /*jshint elision: true */ if (![, 1].find(function (item, idx) { return idx === 0; })) { - defineProperty(Array.prototype, 'find', ArrayPrototypeShims.find, true); + overrideNative(Array.prototype, 'find', ArrayPrototypeShims.find); } if ([, 1].findIndex(function (item, idx) { return idx === 0; }) !== 0) { - defineProperty(Array.prototype, 'findIndex', ArrayPrototypeShims.findIndex, true); + overrideNative(Array.prototype, 'findIndex', ArrayPrototypeShims.findIndex); } /*jshint elision: false */ - defineProperties(Object, { + var isEnumerableOn = Function.bind.call(Function.bind, Object.prototype.propertyIsEnumerable); + var sliceArgs = function sliceArgs() { + // per https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments + // and https://gist.github.com/WebReflection/4327762cb87a8c634a29 + var initial = Number(this); + var len = arguments.length; + var desiredArgCount = len - initial; + var args = new Array(desiredArgCount < 0 ? 0 : desiredArgCount); + for (var i = initial; i < len; ++i) { + args[i - initial] = arguments[i]; + } + return args; + }; + var assignTo = function assignTo(source) { + return function assignToSource(target, key) { + target[key] = source[key]; + return target; + }; + }; + var assignReducer = function (target, source) { + var keys = Object.keys(Object(source)); + var symbols; + if (ES.IsCallable(Object.getOwnPropertySymbols)) { + symbols = Object.getOwnPropertySymbols(Object(source)).filter(isEnumerableOn(source)); + } + return keys.concat(symbols || []).reduce(assignTo(source), 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(sliceArgs.apply(0, arguments), assignReducer); + }, + + // Added in WebKit in https://bugs.webkit.org/show_bug.cgi?id=143865 is: function is(a, b) { return ES.SameValue(a, b); } - }); + }; + var assignHasPendingExceptions = Object.assign && Object.preventExtensions && (function () { + // Firefox 37 still has "pending exception" logic in its Object.assign implementation, + // which is 72% slower than our shim, and Firefox 40's native implementation. + var thrower = Object.preventExtensions({ 1: 2 }); + try { + Object.assign(thrower, 'xy'); + } catch (e) { + return thrower[1] === 'y'; + } + }()); + if (assignHasPendingExceptions) { + overrideNative(Object, 'assign', ObjectShims.assign); + } + defineProperties(Object, ObjectShims); if (supportsDescriptors) { - var isEnumerableOn = Function.bind.call(Function.bind, Object.prototype.propertyIsEnumerable); - var assignReducer = function (target, source) { - var keys = Object.keys(Object(source)); - var symbols; - if (ES.IsCallable(Object.getOwnPropertySymbols)) { - symbols = Object.getOwnPropertySymbols(Object(source)).filter(isEnumerableOn(source)); - } - return keys.concat(symbols || []).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, assignReducer); - }, - + var ES5ObjectShims = { // 19.1.3.9 // shim from https://gist.github.com/WebReflection/5593554 setPrototypeOf: (function (Object, magic) { @@ -1008,22 +1038,7 @@ }(Object, '__proto__')) }; - var assignHasPendingExceptions = Object.assign && Object.preventExtensions && (function () { - // Firefox 37 still has "pending exception" logic in its Object.assign implementation, - // which is 72% slower than our shim, and Firefox 40's native implementation. - var thrower = Object.preventExtensions({ 1: 2 }); - try { - Object.assign(thrower, 'xy'); - } catch (e) { - return thrower[1] === 'y'; - } - }()); - if (assignHasPendingExceptions) { - var origAssign = Object.assign; - defineProperty(Object, 'assign', ObjectShims.assign, true); - Value.preserveToString(Object.assign, origAssign); - } - defineProperties(Object, ObjectShims); + defineProperties(Object, ES5ObjectShims); } // Workaround bug in Opera 12 where setPrototypeOf(x, null) doesn't work, @@ -1039,8 +1054,8 @@ return result === FAKENULL ? null : result; }; Object.setPrototypeOf = function (o, p) { - if (p === null) { p = FAKENULL; } - return spo(o, p); + var proto = p === null ? FAKENULL : p; + return spo(o, proto); }; Object.setPrototypeOf.polyfill = false; }()); @@ -1049,106 +1064,96 @@ var objectKeysAcceptsPrimitives = !throwsError(function () { Object.keys('foo'); }); if (!objectKeysAcceptsPrimitives) { var originalObjectKeys = Object.keys; - defineProperty(Object, 'keys', function keys(value) { + overrideNative(Object, 'keys', function keys(value) { return originalObjectKeys(ES.ToObject(value)); - }, true); - Value.preserveToString(Object.keys, originalObjectKeys); + }); } if (Object.getOwnPropertyNames) { var objectGOPNAcceptsPrimitives = !throwsError(function () { Object.getOwnPropertyNames('foo'); }); if (!objectGOPNAcceptsPrimitives) { var originalObjectGetOwnPropertyNames = Object.getOwnPropertyNames; - defineProperty(Object, 'getOwnPropertyNames', function getOwnPropertyNames(value) { + overrideNative(Object, 'getOwnPropertyNames', function getOwnPropertyNames(value) { return originalObjectGetOwnPropertyNames(ES.ToObject(value)); - }, true); - Value.preserveToString(Object.getOwnPropertyNames, originalObjectGetOwnPropertyNames); + }); } } if (Object.getOwnPropertyDescriptor) { var objectGOPDAcceptsPrimitives = !throwsError(function () { Object.getOwnPropertyDescriptor('foo', 'bar'); }); if (!objectGOPDAcceptsPrimitives) { var originalObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - defineProperty(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(value, property) { + overrideNative(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(value, property) { return originalObjectGetOwnPropertyDescriptor(ES.ToObject(value), property); - }, true); - Value.preserveToString(Object.getOwnPropertyDescriptor, originalObjectGetOwnPropertyDescriptor); + }); } } if (Object.seal) { var objectSealAcceptsPrimitives = !throwsError(function () { Object.seal('foo'); }); if (!objectSealAcceptsPrimitives) { var originalObjectSeal = Object.seal; - defineProperty(Object, 'seal', function seal(value) { + overrideNative(Object, 'seal', function seal(value) { if (!Type.object(value)) { return value; } return originalObjectSeal(value); - }, true); - Value.preserveToString(Object.seal, originalObjectSeal); + }); } } if (Object.isSealed) { var objectIsSealedAcceptsPrimitives = !throwsError(function () { Object.isSealed('foo'); }); if (!objectIsSealedAcceptsPrimitives) { var originalObjectIsSealed = Object.isSealed; - defineProperty(Object, 'isSealed', function isSealed(value) { + overrideNative(Object, 'isSealed', function isSealed(value) { if (!Type.object(value)) { return true; } return originalObjectIsSealed(value); - }, true); - Value.preserveToString(Object.isSealed, originalObjectIsSealed); + }); } } if (Object.freeze) { var objectFreezeAcceptsPrimitives = !throwsError(function () { Object.freeze('foo'); }); if (!objectFreezeAcceptsPrimi |