diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-04-13 19:23:10 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-04-13 19:23:10 +0200 |
commit | 2c194953f0ff0f24b7f9a18815ec80971871951a (patch) | |
tree | 1dcb7bbf969a0b3ba08ec16ec89b3abb3eb20dc6 /js/vendor/es6-shim | |
parent | f51129ae7f83b016155e7af81c479cf0f6a124e3 (diff) |
update angularjs
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 | 32 | ||||
-rw-r--r-- | js/vendor/es6-shim/README.md | 47 | ||||
-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 | 2 | ||||
-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 | 836 | ||||
-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 | 14 |
12 files changed, 516 insertions, 438 deletions
diff --git a/js/vendor/es6-shim/.bower.json b/js/vendor/es6-shim/.bower.json index 1b135576c..397da17fe 100644 --- a/js/vendor/es6-shim/.bower.json +++ b/js/vendor/es6-shim/.bower.json @@ -1,6 +1,6 @@ { "name": "es6-shim", - "version": "0.27.1", + "version": "0.28.1", "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.27.1", + "_release": "0.28.1", "_resolution": { "type": "version", - "tag": "0.27.1", - "commit": "dad3f8e9e78f8c0842628ad9558547a3c62382b7" + "tag": "0.28.1", + "commit": "c80f6037540026de9b8a0495310e2d37310942ee" }, "_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 37764c76b..830b85dc7 100644 --- a/js/vendor/es6-shim/CHANGELOG.md +++ b/js/vendor/es6-shim/CHANGELOG.md @@ -1,5 +1,37 @@ # es6-shim x.x.x (not yet released) +# es6-shim 0.28.1 (12 Apr 2015) +* Ensure `Object.assign` only includes enumerable Symbols. + +# es6-shim 0.28.0 (12 Apr 2015) +* Ensure `Object.assign` also includes Symbols. +* Make sure to clobber Firefox 37's very slow native Object.assign, that has "pending exception" logic. +* Adding much more granular Set/Map acceptance tests and replacements, to preserve as much of the original implementation as possible. (#326, #328) +* Lots of test additions and cleanup + * Fill in (and fix) missing name, arity, and enumerability tests. + * Using `property` matcher for a more helpful failure message. + * Make sure this test doesn't fail if `Array#values` doesn't exist yet. + * Make this `@@iterator` test not depend on `Array#values`, and properly skip tests if the symbol isn't available. +* Update `Math.fround` with a much smaller implementation (#332) +* Lock `uglify-js` down to v2.4.17, since v2.4.18 and v2.4.19 have a breaking change. +* Update `es5-shim`, `mocha`, `grunt-contrib-connect`, `chai`, `jshint` +* IE 11 TP has a broken `String.raw` implementation +* Overwriting some imprecise Math functions on IE 11 TP. +* Overwrite `Math.imul` in Safari 8 to report the correct length. +* Fix Math.round for very large numbers +* Don't rely on shims in tests, for better native failure checking. +* Shim `Object.is` in ES3 environments, and add tests. +* Test the native `Object.assign` prior to shimming it. +* Tweak the `travis-ci` config to make a separate "lint only" test run. +* Fix Firefox 4 test failures: ensure RegExp global aliases starting with "$" exist. +* more efficient Math.clz32 (#327) +* Fix Webkit nightly bugs with `Array.from` and `Array.of`. +* Make sure shims that depend on `Number.isNaN` and `Number.isFinite` will always work. +* The latest Webkit nightly has a bug with `String#includes` and a position arg of `Infinity`. +* Webkit r181855 has a noncompliant `String#startsWith` and `String#endsWith` +* Clean up README; add more accurate note about `es5-shim`. +* Updating the `String.raw` code to be more in line with the changes in RC2/Rev 35 of the spec. + # es6-shim 0.27.1 (5 Mar 2015) * Revert `Array#slice` changes. (#322) * Test on `io.js` `v1.4` diff --git a/js/vendor/es6-shim/README.md b/js/vendor/es6-shim/README.md index bbfc37545..1d0d9a385 100644 --- a/js/vendor/es6-shim/README.md +++ b/js/vendor/es6-shim/README.md @@ -12,21 +12,21 @@ closely as possible to ECMAScript 6 (Harmony). If you want to use it in browser: * Just include es6-shim before your scripts. -* Include [es5-shim](https://github.com/kriskowal/es5-shim) if your browser doesn't support ECMAScript 5. -* `component install paulmillr/es6-shim` if you’re using [component(1)](https://github.com/component/component). -* `bower install es6-shim` if you’re using [Twitter Bower](http://bower.io/). +* Include [es5-shim][es5-shim-url] especially if your browser doesn't support ECMAScript 5 - but every JS engine requires the `es5-shim` to correct broken implementations, so it's strongly recommended to always include it. -For node.js: +For `node.js`, `io.js`, or any `npm`-managed workflow (this is the recommended method): npm install es6-shim -In both browser and node you may also want to include `unorm`; see the -[`String.prototype.normalize`](#stringprototypenormalize) section for -details. +Alternative methods: +* `component install paulmillr/es6-shim` if you’re using [component(1)](https://github.com/component/component). +* `bower install es6-shim` if you’re using [Bower](http://bower.io/). + +In both browser and node you may also want to include `unorm`; see the [`String.prototype.normalize`](#stringprototypenormalize) section for details. ## Safe shims -* `Map`, `Set` (requires ES5) +* `Map`, `Set` (requires ES5 property descriptor support) * `Promise` * `String`: * `fromCodePoint()` ([a standalone shim is also available](http://mths.be/fromcodepoint)) @@ -178,23 +178,23 @@ Math.sign(400) // 1, 0 or -1 depending on sign. In this case 1. // Replacement for `{}` key-value storage. // Keys can be anything. -var map = new Map() -map.set('John', 25) -map.set('Alice', 400) -map.set(['meh'], 555) -map.get(['meh']) // undefined because you need to use exactly the same object. -map.delete('Alice') -map.keys() -map.values() -map.size // 2 +var map = new Map(); +map.set('John', 25); +map.set('Alice', 400); +map.set(['meh'], 555); +assert(map.get(['meh']) === undefined); // undefined because you need to use exactly the same object. +map.delete('Alice'); +map.keys(); +map.values(); +assert(map.size === 2); // Useful for storing unique items. -var set = new Set() -set.add(1) -set.add(5) -set.has(1) -set.has(4) // => false -set.delete(5) +var set = new Set(); +set.add(1); +set.add(5); +assert(set.has(1) === true); +assert(set.has(4) === false); +set.delete(5); // Promises, see // http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript @@ -224,3 +224,4 @@ Other stuff: [license-url]: https://github.com/paulmillr/es6-shim/blob/master/LICENSE [spec-html-url]: https://people.mozilla.org/~jorendorff/es6-draft.html [spec-drafts-url]: http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts +[es5-shim-url]: https://github.com/es-shims/es5-shim diff --git a/js/vendor/es6-shim/bower.json b/js/vendor/es6-shim/bower.json index 9d13578f4..9721755a9 100644 --- a/js/vendor/es6-shim/bower.json +++ b/js/vendor/es6-shim/bower.json @@ -1,6 +1,6 @@ { "name": "es6-shim", - "version": "0.27.1", + "version": "0.28.1", "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 a620bc64d..b4e0ea75b 100644 --- a/js/vendor/es6-shim/component.json +++ b/js/vendor/es6-shim/component.json @@ -1,6 +1,6 @@ { "name": "es6-shim", - "version": "0.27.1", + "version": "0.28.1", "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 59f77493e..105f09d16 100644 --- a/js/vendor/es6-shim/es6-sham.js +++ b/js/vendor/es6-shim/es6-sham.js @@ -24,7 +24,7 @@ // Browser globals (root is window) root.returnExports = factory(); } -}(this, function (undefined) { +}(this, function () { 'use strict'; /*jshint evil: true */ diff --git a/js/vendor/es6-shim/es6-sham.map b/js/vendor/es6-shim/es6-sham.map index f00976574..6a2279c83 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","undefined","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,SAAUC,GAChB,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","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 diff --git a/js/vendor/es6-shim/es6-sham.min.js b/js/vendor/es6-shim/es6-sham.min.js index 685a51e0e..dba4ecc9e 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(t){"use strict";var e=new Function("return this;");var r=e();var n=r.Object;(function(){if(n.setPrototypeOf){return}var t=function(t,e){i(e).forEach(function(r){o(t,r,c(e,r))});return t};var e=function(e,n){return t(r(n),e)};var r=n.create;var o=n.defineProperty;var f=n.getPrototypeOf;var i=n.getOwnPropertyNames;var c=n.getOwnPropertyDescriptor;var u=n.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 n){_=e}else{a.__proto__=u;if(a instanceof n){_=function(t,e){t.__proto__=e;return t}}else{_=function(t,r){return f(t)?(t.__proto__=r,t):e(t,r)}}}}n.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=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=_})()}); //# 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 6d2160f12..f9bf1991c 100644 --- a/js/vendor/es6-shim/es6-shim.js +++ b/js/vendor/es6-shim/es6-shim.js @@ -27,59 +27,66 @@ }(this, function () { 'use strict'; - var isCallableWithoutNew = function (func) { + var not = function notThunker(func) { + return function notThunk() { return !func.apply(this, arguments); }; + }; + var throwsError = function (func) { try { func(); + return false; + } catch (e) { + return true; + } + }; + var valueOrFalseIfThrows = function valueOrFalseIfThrows(func) { + try { + return func(); } catch (e) { return false; } - return true; }; + var isCallableWithoutNew = not(throwsError); + var supportsSubclassing = function (C, f) { - /* jshint proto:true */ - try { - var Sub = function () { C.apply(this, arguments); }; - if (!Sub.__proto__) { return false; /* skip test on IE < 11 */ } - Object.setPrototypeOf(Sub, C); - Sub.prototype = Object.create(C.prototype, { + if (!Object.setPrototypeOf) { return false; /* skip test on IE < 11 */ } + return valueOrFalseIfThrows(function () { + var Sub = function Subclass(arg) { + var o = new C(arg); + Object.setPrototypeOf(o, Subclass.prototype); + return o; + }; + Sub.prototype = create(C.prototype, { constructor: { value: C } }); return f(Sub); - } catch (e) { - return false; - } + }); }; var arePropertyDescriptorsSupported = function () { - try { - Object.defineProperty({}, 'x', {}); - return true; - } catch (e) { /* this is IE 8. */ - return false; - } + // if Object.defineProperty exists but throws, it's IE 8 + return !throwsError(function () { Object.defineProperty({}, 'x', {}); }); }; var startsWithRejectsRegex = function () { - var rejectsRegex = false; - if (String.prototype.startsWith) { - try { - '/a/'.startsWith(/a/); - } catch (e) { /* this is spec compliant */ - rejectsRegex = true; - } - } - return rejectsRegex; + return String.prototype.startsWith && throwsError(function () { + /* throws if spec-compliant */ + '/a/'.startsWith(/a/); + }); }; + var startsWithHandlesInfinity = (function () { + return String.prototype.startsWith && 'abc'.startsWith('a', Infinity) === false; + }()); /*jshint evil: true */ var getGlobal = new Function('return this;'); /*jshint evil: false */ var globals = getGlobal(); - var global_isFinite = globals.isFinite; + var globalIsFinite = globals.isFinite; var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported(); - var startsWithIsCompliant = startsWithRejectsRegex(); + var hasStrictMode = (function () { return this === null; }.call(null)); + var startsWithIsCompliant = startsWithRejectsRegex() && startsWithHandlesInfinity; var _indexOf = Function.call.bind(String.prototype.indexOf); var _toString = Function.call.bind(Object.prototype.toString); var _hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty); @@ -99,6 +106,18 @@ } }; + var numberIsNaN = Number.isNaN || function isNaN(value) { + // NaN !== NaN, but they are identical. + // NaNs are the only non-reflexive value, i.e., if x !== x, + // then x is NaN. + // isNaN is broken: it converts its argument to number, so + // isNaN('foo') => true + return value !== value; + }; + var numberIsFinite = Number.isFinite || function isFinite(value) { + return typeof value === 'number' && globalIsFinite(value); + }; + var defineProperty = function (object, name, value, force) { if (!force && name in object) { return; } if (supportsDescriptors) { @@ -263,8 +282,8 @@ ToInteger: function (value) { var number = ES.ToNumber(value); - if (Number.isNaN(number)) { return 0; } - if (number === 0 || !Number.isFinite(number)) { return number; } + if (numberIsNaN(number)) { return 0; } + if (number === 0 || !numberIsFinite(number)) { return number; } return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)); }, @@ -281,12 +300,12 @@ if (a === 0) { return 1 / a === 1 / b; } return true; } - return Number.isNaN(a) && Number.isNaN(b); + return numberIsNaN(a) && numberIsNaN(b); }, SameValueZero: function (a, b) { // same as SameValue except for SameValueZero(+0, -0) == true - return (a === b) || (Number.isNaN(a) && Number.isNaN(b)); + return (a === b) || (numberIsNaN(a) && numberIsNaN(b)); }, IsIterable: function (o) { @@ -363,146 +382,14 @@ return o; }; + // 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); + } - 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 - - function roundToEven(n) { - var w = Math.floor(n), f = n - w; - if (f < 0.5) { - return w; - } - if (f > 0.5) { - return w + 1; - } - return w % 2 ? w + 1 : w; - } - - function packIEEE754(v, ebits, fbits) { - var bias = (1 << (ebits - 1)) - 1, - s, e, f, - i, bits, str, bytes; - - // Compute sign, exponent, fraction - if (v !== v) { - // NaN - // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping - e = (1 << ebits) - 1; - f = Math.pow(2, fbits - 1); - s = 0; - } else if (v === Infinity || v === -Infinity) { - e = (1 << ebits) - 1; - f = 0; - s = (v < 0) ? 1 : 0; - } else if (v === 0) { - e = 0; - f = 0; - s = (1 / v === -Infinity) ? 1 : 0; - } else { - s = v < 0; - v = Math.abs(v); - - if (v >= Math.pow(2, 1 - bias)) { - e = Math.min(Math.floor(Math.log(v) / Math.LN2), 1023); - f = roundToEven(v / Math.pow(2, e) * Math.pow(2, fbits)); - if (f / Math.pow(2, fbits) >= 2) { - e = e + 1; - f = 1; - } - if (e > bias) { - // Overflow - e = (1 << ebits) - 1; - f = 0; - } else { - // Normal - e = e + bias; - f = f - Math.pow(2, fbits); - } - } else { - // Subnormal - e = 0; - f = roundToEven(v / Math.pow(2, 1 - bias - fbits)); - } - } - - // Pack sign, exponent, fraction - bits = []; - for (i = fbits; i; i -= 1) { - bits.push(f % 2 ? 1 : 0); - f = Math.floor(f / 2); - } - for (i = ebits; i; i -= 1) { - bits.push(e % 2 ? 1 : 0); - e = Math.floor(e / 2); - } - bits.push(s ? 1 : 0); - bits.reverse(); - str = bits.join(''); - - // Bits to bytes - bytes = []; - while (str.length) { - bytes.push(parseInt(str.slice(0, 8), 2)); - str = str.slice(8); - } - return bytes; - } - - function unpackIEEE754(bytes, ebits, fbits) { - // Bytes to bits - var bits = [], i, j, b, str, - bias, s, e, f; - - for (i = bytes.length; i; i -= 1) { - b = bytes[i - 1]; - for (j = 8; j; j -= 1) { - bits.push(b % 2 ? 1 : 0); - b = b >> 1; - } - } - bits.reverse(); - str = bits.join(''); - - // Unpack sign, exponent, fraction - bias = (1 << (ebits - 1)) - 1; - s = parseInt(str.slice(0, 1), 2) ? -1 : 1; - e = parseInt(str.slice(1, 1 + ebits), 2); - f = parseInt(str.slice(1 + ebits), 2); - - // Produce number - if (e === (1 << ebits) - 1) { - return f !== 0 ? NaN : s * Infinity; - } else if (e > 0) { - // Normalized - return s * Math.pow(2, e - bias) * (1 + f / Math.pow(2, fbits)); - } else if (f !== 0) { - // Denormalized - return s * Math.pow(2, -(bias - 1)) * (f / Math.pow(2, fbits)); - } else { - return s < 0 ? -0 : 0; - } - } - - function unpackFloat64(b) { return unpackIEEE754(b, 11, 52); } - function packFloat64(v) { return packIEEE754(v, 11, 52); } - function unpackFloat32(b) { return unpackIEEE754(b, 8, 23); } - function packFloat32(v) { return packIEEE754(v, 8, 23); } - - var conversions = { - toFloat32: function (num) { return unpackFloat32(packFloat32(num)); } - }; - if (typeof Float32Array !== 'undefined') { - var float32array = new Float32Array(1); - conversions.toFloat32 = function (num) { - float32array[0] = num; - return float32array[0]; - }; - } - return conversions; - }()); - - defineProperties(String, { + var StringShims = { fromCodePoint: function fromCodePoint(codePoints) { var result = []; var next; @@ -525,8 +412,7 @@ raw: function raw(callSite) { var cooked = ES.ToObject(callSite, 'bad callSite'); - var rawValue = cooked.raw; - var rawString = ES.ToObject(rawValue, 'bad raw value'); + var rawString = ES.ToObject(cooked.raw, 'bad raw value'); var len = rawString.length; var literalsegments = ES.ToLength(len); if (literalsegments <= 0) { @@ -538,8 +424,7 @@ var nextKey, next, nextSeg, nextSub; while (nextIndex < literalsegments) { nextKey = String(nextIndex); - next = rawString[nextKey]; - nextSeg = String(next); + nextSeg = String(rawString[nextKey]); stringElements.push(nextSeg); if (nextIndex + 1 >= literalsegments) { break; @@ -551,13 +436,13 @@ } return stringElements.join(''); } - }); - - // Firefox 31 reports this function's length as 0 - // https://bugzilla.mozilla.org/show_bug.cgi?id=1062484 - if (String.fromCodePoint.length !== 1) { - var originalFromCodePoint = Function.apply.bind(String.fromCodePoint); - defineProperty(String, 'fromCodePoint', function fromCodePoint(codePoints) { return originalFromCodePoint(this, arguments); }, true); + }; + 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); } // Fast repeat, uses the `Exponentiation by squaring` algorithm. @@ -570,7 +455,7 @@ }; var stringMaxLength = Infinity; - var StringShims = { + var StringPrototypeShims = { repeat: function repeat(times) { ES.RequireObjectCoercible(this); var thisStr = String(this); @@ -581,7 +466,7 @@ return stringRepeat(thisStr, times); }, - startsWith: function (searchStr) { + startsWith: function startsWith(searchStr) { ES.RequireObjectCoercible(this); var thisStr = String(this); if (Type.regex(searchStr)) { @@ -593,7 +478,7 @@ return thisStr.slice(start, start + searchStr.length) === searchStr; }, - endsWith: function (searchStr) { + endsWith: function endsWith(searchStr) { ES.RequireObjectCoercible(this); var thisStr = String(this); if (Type.regex(searchStr)) { @@ -613,7 +498,7 @@ return _indexOf(this, searchString, position) !== -1; }, - codePointAt: function (pos) { + codePointAt: function codePointAt(pos) { ES.RequireObjectCoercible(this); var thisStr = String(this); var position = ES.ToInteger(pos); @@ -628,7 +513,13 @@ } } }; - defineProperties(String.prototype, StringShims); + 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); + } var hasStringTrimBug = '\u0085'.trim().length !== 1; if (hasStringTrimBug) { @@ -642,7 +533,7 @@ ].join(''); var trimRegexp = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g'); defineProperties(String.prototype, { - trim: function () { + trim: function trim() { if (typeof this === 'undefined' || this === null) { throw new TypeError("can't convert " + this + ' to object'); } @@ -679,9 +570,9 @@ }); if (!startsWithIsCompliant) { - // Firefox has a noncompliant startsWith implementation - defineProperty(String.prototype, 'startsWith', StringShims.startsWith, true); - defineProperty(String.prototype, 'endsWith', StringShims.endsWith, true); + // 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); } var ArrayShims = { @@ -745,23 +636,10 @@ }; defineProperties(Array, ArrayShims); - var arrayFromSwallowsNegativeLengths = function () { - try { - return Array.from({ length: -1 }).length === 0; - } catch (e) { - return false; - } - }; - // Fixes a Firefox bug in v32 - // https://bugzilla.mozilla.org/show_bug.cgi?id=1063993 - if (!arrayFromSwallowsNegativeLengths()) { - defineProperty(Array, 'from', ArrayShims.from, true); - } - // Given an argument x, it will return an IteratorResult object, // with value set to x and done to false. // Given no arguments, it will return an iterator completion object. - var iterator_result = function (x) { + var iteratorResult = function (x) { return { value: x, done: arguments.length === 0 }; }; @@ -843,19 +721,33 @@ } if (this.kind === 'key') { - return iterator_result(key); + return iteratorResult(key); } else if (this.kind === 'value') { - return iterator_result(this.object[key]); + return iteratorResult(this.object[key]); } else { - return iterator_result([key, this.object[key]]); + return iteratorResult([key, this.object[key]]); } } - return iterator_result(); + return iteratorResult(); } }); addIterator(ObjectIterator.prototype); + // note: this is positioned here because it depends on ArrayIterator + var arrayOfSupportsSubclassing = (function () { + // Detects a bug in Webkit nightly r181886 + var Foo = function Foo(len) { this.length = len; }; + Foo.prototype = []; + var fooArr = Array.of.apply(Foo, [1, 2]); + return fooArr instanceof Foo && fooArr.length === 2; + }()); + if (!arrayOfSupportsSubclassing) { + var origArrayOf = Array.of; + defineProperty(Array, 'of', ArrayShims.of, true); + Value.preserveToString(Array.of, origArrayOf); + } + var ArrayPrototypeShims = { copyWithin: function copyWithin(target, start) { var end = arguments[2]; // copyWithin.length must be 2 @@ -984,6 +876,23 @@ addIterator(Object.getPrototypeOf([].values())); } + // note: this is positioned here because it relies on Array#entries + 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); + } + var maxSafeInteger = Math.pow(2, 53) - 1; defineProperties(Number, { MAX_SAFE_INTEGER: maxSafeInteger, @@ -993,26 +902,17 @@ parseInt: globals.parseInt, parseFloat: globals.parseFloat, |