diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-09-26 11:43:36 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-09-26 11:43:36 +0200 |
commit | c6ecb54be7a99b7f3ad9d601100f89151380d3b7 (patch) | |
tree | 8fd8e7cd26d907e03aad90003d07b00bf6b5ceb1 /js/vendor/es6-shim | |
parent | 847d9da9226383e69ff02c20bebf46a597e7f7d7 (diff) |
update js 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 | 73 | ||||
-rw-r--r-- | js/vendor/es6-shim/README.md | 98 | ||||
-rw-r--r-- | js/vendor/es6-shim/bower.json | 1 | ||||
-rw-r--r-- | js/vendor/es6-shim/component.json | 2 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-sham.js | 4 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-sham.min.js | 6 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-shim.js | 1521 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-shim.map | 2 | ||||
-rw-r--r-- | js/vendor/es6-shim/es6-shim.min.js | 11 | ||||
-rw-r--r-- | js/vendor/es6-shim/package.json | 22 | ||||
-rw-r--r-- | js/vendor/es6-shim/test-sham/set-prototype-of.js | 2 |
12 files changed, 1102 insertions, 648 deletions
diff --git a/js/vendor/es6-shim/.bower.json b/js/vendor/es6-shim/.bower.json index 0610a88ff..cca9aaecd 100644 --- a/js/vendor/es6-shim/.bower.json +++ b/js/vendor/es6-shim/.bower.json @@ -1,6 +1,5 @@ { "name": "es6-shim", - "version": "0.31.2", "repo": "paulmillr/es6-shim", "description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines", "keywords": [ @@ -28,11 +27,12 @@ "test" ], "homepage": "https://github.com/paulmillr/es6-shim", - "_release": "0.31.2", + "version": "0.33.3", + "_release": "0.33.3", "_resolution": { "type": "version", - "tag": "0.31.2", - "commit": "c4ef3981849dfdf68357cdeda494d9de6422f737" + "tag": "0.33.3", + "commit": "616eee62ceed6f1e988abab4e49d6d682702be1b" }, "_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 fb5af3456..b18eddc42 100644 --- a/js/vendor/es6-shim/CHANGELOG.md +++ b/js/vendor/es6-shim/CHANGELOG.md @@ -1,5 +1,78 @@ # es6-shim x.x.x (not yet released) +# es6-shim 0.33.3 (31 Aug 2015) +* [Fix] Handle Firefox Nightly's broken `construct` method +* [Tests] Add `JSON.stringify` tests for handling `Symbol`s + +# es6-shim 0.33.2 (26 Aug 2015) +* [Fix] Make sure that minified code preserves function names. +* [Fix] Skip the `Promise` shim when `setTimeout` is not available ([#301](https://github.com/paulmillr/es6-shim/issues/301#issuecomment-126566703)) +* [Docs] Add note about `setPrototypeOf` on null objects + +# es6-shim 0.33.1 (20 Aug 2015) +* [New] Add support for binary and octal literals in strings to the `Number` constructor (#358) +* [Docs] Update spec link to final spec +* [Fix] `Reflect.enumerate`: does not necessarily wait until the first `next()` to determine keys. +* [Refactors] split up some tests; name some functions; remove unnecessary code +* {Refactors] make ObjectIterator properties non-enumerable +* [Refactors] Refactor `RegExp` wrapping code so most of it can be reused. +* [Tests] up to `io.js` `v3.1` +* [Dev Deps] update `grunt-contrib-connect`, `jscs` + +# es6-shim 0.33.0 (30 Jul 2015) +* [Breaking] Avoid CSP errors in Chrome apps by using global var detection (#301) +* [Performance] Rearranging some of the Map/Set runtime shim clobberings to be more efficient. +* [Refactor] Implement `Array.of` directly, rather than in terms of `Array.from` +* [Dev Deps] Update `chai`, `es5-shim`, `promises-aplus-tests`, `uglify-js` +* [Tests] Add test for `Object.getPrototypeOf` accepting primitives. +* [Tests] Bail out of individual `Reflect` tests when the methods don’t exist +* [Tests] Test on latest `io.js` + +# es6-shim 0.32.3 (21 Jun 2015) +* [Fix] Override or wrap native `Reflect` methods in Microsoft Edge v0.11 as required. +* [Fix] Edge v0.11: `Array.from([], undefined)` should not throw +* [Fix] Fix a bug in `Array.from handles iterables` runtime clobbering, which would always replace the native function +* [Fix] Ensure that `Set#has` has the correct name in Edge v0.11 +* [Tests] Add `Map`/`Set` error messages for Edge v0.11 +* [Tests] Fix `Math.fround` test value for Edge v0.11 +* [Tests] Bail out of `Map`/`Set` test blocks if they don't exist +* [Docs] Update ES5 subclassing instructions in the README. +* [Dev Deps] Update `es5-shim` + +# es6-shim 0.32.2 (17 Jun 2015) +* [Fix] `Object.assign` with no sources should coerce to an object (#348) +* [Fix] `String#includes` should throw when given a `RegExp` (#349) +* [Fix] `RegExp()` should not throw (#350) +* [Fix] Create `Value.defineByDescriptor`, fix `create` when `Object.create` is unavailable. +* [Compliance] Update `Promise.reject` to match official ECMA-262 spec. +* [Dev Deps] Update `es5-shim` + +# es6-shim 0.32.1 (13 Jun 2015) +* [Fix] Make sure that all `Map`/`Set` shim forms properly add an iterable to the collection instance. +* [Tests] Make sure none of the `Array` ToLength tests throw *any* error (#347) + +# es6-shim 0.32.0 (7 Jun 2015) +* [Spec compliance] Update Promises to match finalized ES6 spec (#345, #344, #239) +* [Fix] Ensure `Map`, `Set`, and `Promise` shims all throw when used without "new". +* [Tests] Fix the pending exceptions test for Safari 5.1 +* [Refactor] Since the String HTML shims will be iterated anyways, no need to defineProperties them twice. +* [Deps] Update `chai`, `es5-shim` + +# es6-shim 0.31.3 (2 Jun 2015) +* [Fix] Properly name more shim functions +* [Fix] Fix an IE bug where the layout engine internally calls the userland `Object.getOwnPropertyNames` +* [Fix] Ensure `Map.prototype[Symbol.iterator] === Map.prototype.entries` +* [Fix] Ensure `Set.prototype[Symbol.iterator] === Set.prototype.values` +* [Tests] `Object.assign` pending exceptions: IE 9 `preventExtensions` doesn't throw, even in strict mode +* [Security] Cache more native methods in case they're overwritten later +* [Tests] IE 11 has native `Map`/`Set`, but it takes an optional *function*, not an optional iterable, in the constructor +* [Tests] Add more "exists" early bailouts, to declutter native test results +* [Docs] Alphabetize shim lists in the README +* [Perf] Add more `Map`/`Set` fast paths for more primitives: boolean, null, undefined +* [Tests] Test up to `io.js` `v2.2` +* [Deps] Update `mocha`, `es5-shim`, `uglify-js`, `jshint` +* [Refactor] Style cleanups + # es6-shim 0.31.2 (9 May 2015) * Fix ES5 `Array.prototype` method wrappers to return the correct value. (#341) diff --git a/js/vendor/es6-shim/README.md b/js/vendor/es6-shim/README.md index 1d0d9a385..074dd5af2 100644 --- a/js/vendor/es6-shim/README.md +++ b/js/vendor/es6-shim/README.md @@ -8,6 +8,8 @@ closely as possible to ECMAScript 6 (Harmony). [![Sauce Test Status](https://saucelabs.com/browser-matrix/es6-shim.svg)](https://saucelabs.com/u/es6-shim) +[HTML version of the final ECMAScript 6 spec][spec-html-url] + ## Installation If you want to use it in browser: @@ -33,39 +35,39 @@ In both browser and node you may also want to include `unorm`; see the [`String. * `raw()` * `String.prototype`: * `codePointAt()` ([a standalone shim is also available](http://mths.be/codepointat)) - * `repeat()` ([a standalone shim is also available](http://mths.be/repeat)) - * `startsWith()` ([a standalone shim is also available](http://mths.be/startswith)) * `endsWith()` ([a standalone shim is also available](http://mths.be/endswith)) * `includes()` ([a standalone shim is also available](http://mths.be/includes)) + * `repeat()` ([a standalone shim is also available](http://mths.be/repeat)) + * `startsWith()` ([a standalone shim is also available](http://mths.be/startswith)) * `RegExp`: * `new RegExp`, when given a RegExp as the pattern, will no longer throw when given a "flags" string argument. (requires ES5) * `RegExp.prototype`: * `flags` (requires ES5) ([a standalone shim is also available](https://github.com/es-shims/RegExp.prototype.flags)) * `Number`: + * `EPSILON` * `MAX_SAFE_INTEGER` * `MIN_SAFE_INTEGER` - * `EPSILON` - * `parseInt()` - * `parseFloat()` * `isNaN()`([a standalone shim is also available](https://npmjs.org/package/is-nan)) * `isInteger()` * `isSafeInteger()` * `isFinite()` + * `parseInt()` + * `parseFloat()` * `Array`: * `from()` ([a standalone shim is also available](https://npmjs.org/package/array.from)) * `of()` ([a standalone shim is also available](https://npmjs.org/package/array.of)) * `Array.prototype`: * `copyWithin()` + * `entries()` * `fill()` * `find()` ([a standalone shim is also available](https://github.com/paulmillr/Array.prototype.find)) * `findIndex()` ([a standalone shim is also available](https://github.com/paulmillr/Array.prototype.findIndex)) * `keys()` (note: keys/values/entries return an `ArrayIterator` object) - * `entries()` * `values()` * `Object`: - * `keys()` (in ES5, but no longer throws on non-object non-null/undefined values in ES6) - * `is()` ([a standalone shim is also available](https://github.com/ljharb/object-is)) * `assign()` ([a standalone shim is also available](https://github.com/ljharb/object.assign)) + * `is()` ([a standalone shim is also available](https://github.com/ljharb/object-is)) + * `keys()` (in ES5, but no longer throws on non-object non-null/undefined values in ES6) * `setPrototypeOf()` (IE >= 11) * `Math`: * `acosh()` @@ -75,16 +77,16 @@ In both browser and node you may also want to include `unorm`; see the [`String. * `clz32()` * `cosh()` * `expm1()` + * `fround()` * `hypot()` - * `log2()` + * `imul()` * `log10()` * `log1p()` + * `log2()` * `sign()` * `sinh()` * `tanh()` * `trunc()` - * `imul()` - * `fround()` Math functions’ accuracy is 1e-11. @@ -122,12 +124,15 @@ These methods are part of "Annex B", which means that although they are a defact ## Subclassing The `Map`, `Set`, and `Promise` implementations are subclassable. -You should use the following pattern to create a subclass in ES5 which -will continue to work in ES6: +You should use the following pattern to create a subclass in ES5 which will continue to work in ES6: ```javascript +require('es6-shim'); + function MyPromise(exec) { - Promise.call(this, exec); + var promise = new Promise(exec); + Object.setPrototypeOf(promise, MyPromise.prototype); // ... + return promise; } Object.setPrototypeOf(MyPromise, Promise); MyPromise.prototype = Object.create(Promise.prototype, { @@ -136,49 +141,45 @@ MyPromise.prototype = Object.create(Promise.prototype, { ``` ## String.prototype.normalize -Including a proper shim for `String.prototype.normalize` would -increase the size of this library by a factor of more than 4. -So instead we recommend that you install the -[`unorm`](https://github.com/walling/unorm) -package alongside `es6-shim` if you need `String.prototype.normalize`. -See https://github.com/paulmillr/es6-shim/issues/134 for more -discussion. +Including a proper shim for `String.prototype.normalize` would increase the size of this library by a factor of more than 4. +So instead we recommend that you install the [`unorm`](https://github.com/walling/unorm) package alongside `es6-shim` if you need `String.prototype.normalize`. +See https://github.com/paulmillr/es6-shim/issues/134 for more discussion. ## WeakMap shim It is not possible to implement WeakMap in pure javascript. -The [es6-collections](https://github.com/WebReflection/es6-collections) -implementation doesn't hold values strongly, which is critical -for the collection. es6-shim decided to not include an incorrect shim. +The [es6-collections](https://github.com/WebReflection/es6-collections) implementation doesn't hold values strongly, which is critical for the collection. `es6-shim` decided to not include an incorrect shim. -WeakMap has a very unusual use-case so you probably won't need it at all -(use simple `Map` instead). +`WeakMap` has very unusual use-cases, so you probably won't need it at all (use simple `Map` instead). ## Getting started ```javascript -'abc'.startsWith('a') // true -'abc'.endsWith('a') // false -'john alice'.includes('john') // true -'123'.repeat(2) // '123123' +var assert = require('assert'); +require('es6-shim'); + +'abc'.startsWith('a'); // true +'abc'.endsWith('a'); // false +'john alice'.includes('john'); // true +'123'.repeat(2); // '123123' -Object.is(NaN, NaN) // Fixes ===. 0 isnt -0, NaN is NaN -Object.assign({a: 1}, {b: 2}) // {a: 1, b: 2} +Object.is(NaN, NaN); // Fixes ===. 0 isnt -0, NaN is NaN +Object.assign({a: 1}, {b: 2}); // {a: 1, b: 2} -Number.isNaN('123') // false. isNaN('123') will give true. -Number.isFinite('asd') // false. Global isFinite() will give true. +Number.isNaN('123'); // false. Global isNaN('123') will give true. +Number.isFinite('asd'); // false. Global isFinite() will give true. // Tests if value is a number, finite, // >= -9007199254740992 && <= 9007199254740992 and floor(value) === value -Number.isInteger(2.4) // false. +Number.isInteger(2.4); // false. -Math.sign(400) // 1, 0 or -1 depending on sign. In this case 1. +Math.sign(400); // 1, 0 or -1 depending on sign. In this case 1. -[5, 10, 15, 10].find(function (item) {return item / 2 === 5;}) // 10 -[5, 10, 15, 10].findIndex(function (item) {return item / 2 === 5;}) // 1 +[5, 10, 15, 10].find(function (item) { return item / 2 === 5; }); // 10 +[5, 10, 15, 10].findIndex(function (item) { return item / 2 === 5; }); // 1 // Replacement for `{}` key-value storage. // Keys can be anything. -var map = new Map(); +var map = new Map([['Bob', 42], ['Foo', 'bar']]); map.set('John', 25); map.set('Alice', 400); map.set(['meh'], 555); @@ -186,13 +187,15 @@ assert(map.get(['meh']) === undefined); // undefined because you need to use exa map.delete('Alice'); map.keys(); map.values(); -assert(map.size === 2); +assert(map.size === 4); // Useful for storing unique items. -var set = new Set(); -set.add(1); +var set = new Set([0, 1]); +set.add(2); set.add(5); +assert(set.has(0) === true); assert(set.has(1) === true); +assert(set.has(2) === true); assert(set.has(4) === false); set.delete(5); @@ -200,7 +203,7 @@ set.delete(5); // http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript // https://github.com/petkaantonov/bluebird/#what-are-promises-and-why-should-i-use-them Promise.resolve(5).then(function (value) { - if ( ... ) throw new Error("whoops!"); + if (value) throw new Error("whoops!"); // do some stuff return anotherPromise(); }).catch(function (e) { @@ -208,10 +211,10 @@ Promise.resolve(5).then(function (value) { }); ``` -Other stuff: +## Caveats -* [HTML version of the latest ECMAScript 6 spec draft][spec-html-url] -* [PDFs of ECMAScript 6 spec drafts][spec-drafts-url] +- `Object.setPrototypeOf` / `Reflect.setPrototypeOf` + - Note that null objects (`Object.create(null)`, eg, an object with `null` as its `[[Prototype]]`) can not have their `[[Prototype]]` changed except via a native `Object.setPrototypeOf`. ## [License][license-url] @@ -222,6 +225,5 @@ Other stuff: [5]: https://david-dm.org/paulmillr/es6-shim/dev-status.svg [6]: https://david-dm.org/paulmillr/es6-shim#info=devDependencies [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 +[spec-html-url]: http://www.ecma-international.org/ecma-262/6.0/ [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 62a690596..231768dee 100644 --- a/js/vendor/es6-shim/bower.json +++ b/js/vendor/es6-shim/bower.json @@ -1,6 +1,5 @@ { "name": "es6-shim", - "version": "0.31.2", "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 9a5cac3aa..f2cf9dc15 100644 --- a/js/vendor/es6-shim/component.json +++ b/js/vendor/es6-shim/component.json @@ -1,6 +1,6 @@ { "name": "es6-shim", - "version": "0.31.2", + "version": "0.33.3", "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 570deb3f0..09d6218cb 100644 --- a/js/vendor/es6-shim/es6-sham.js +++ b/js/vendor/es6-shim/es6-sham.js @@ -2,8 +2,8 @@ * https://github.com/paulmillr/es6-shim * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) * and contributors, MIT License - * es6-sham: v0.27.1 - * see https://github.com/paulmillr/es6-shim/blob/0.27.1/LICENSE + * es6-sham: v0.33.3 + * see https://github.com/paulmillr/es6-shim/blob/0.33.3/LICENSE * Details and documentation: * https://github.com/paulmillr/es6-shim/ */ diff --git a/js/vendor/es6-shim/es6-sham.min.js b/js/vendor/es6-shim/es6-sham.min.js index dffa33876..b75ca177b 100644 --- a/js/vendor/es6-shim/es6-sham.min.js +++ b/js/vendor/es6-shim/es6-sham.min.js @@ -2,10 +2,10 @@ * https://github.com/paulmillr/es6-shim * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) * and contributors, MIT License - * es6-sham: v0.27.1 - * see https://github.com/paulmillr/es6-shim/blob/0.27.1/LICENSE + * es6-sham: v0.33.3 + * see https://github.com/paulmillr/es6-shim/blob/0.33.3/LICENSE * 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=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 +//# sourceMappingURL=es6-sham.map diff --git a/js/vendor/es6-shim/es6-shim.js b/js/vendor/es6-shim/es6-shim.js index 14229dd21..f16d48573 100644 --- a/js/vendor/es6-shim/es6-shim.js +++ b/js/vendor/es6-shim/es6-shim.js @@ -2,8 +2,8 @@ * https://github.com/paulmillr/es6-shim * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) * and contributors, MIT License - * es6-shim: v0.27.1 - * see https://github.com/paulmillr/es6-shim/blob/0.27.1/LICENSE + * es6-shim: v0.33.3 + * see https://github.com/paulmillr/es6-shim/blob/0.33.3/LICENSE * Details and documentation: * https://github.com/paulmillr/es6-shim/ */ @@ -27,8 +27,11 @@ }(this, function () { 'use strict'; + var _apply = Function.call.bind(Function.apply); + var _call = Function.call.bind(Function.call); + var not = function notThunker(func) { - return function notThunk() { return !func.apply(this, arguments); }; + return function notThunk() { return !_apply(func, this, arguments); }; }; var throwsError = function (func) { try { @@ -52,12 +55,31 @@ return !throwsError(function () { Object.defineProperty({}, 'x', {}); }); }; var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported(); + var functionsHaveNames = (function foo() {}).name === 'foo'; var _forEach = Function.call.bind(Array.prototype.forEach); - var _map = Function.call.bind(Array.prototype.map); var _reduce = Function.call.bind(Array.prototype.reduce); var _filter = Function.call.bind(Array.prototype.filter); + var _every = Function.call.bind(Array.prototype.every); + var createDataProperty = function createDataProperty(object, name, value) { + if (supportsDescriptors) { + Object.defineProperty(object, name, { + configurable: true, + enumerable: true, + writable: true, + value: value + }); + } else { + object[name] = value; + } + }; + var createDataPropertyOrThrow = function createDataPropertyOrThrow(object, name, value) { + createDataProperty(object, name, value); + if (!ES.SameValue(object[name], value)) { + throw new TypeError('property is nonconfigurable'); + } + }; var defineProperty = function (object, name, value, force) { if (!force && name in object) { return; } if (supportsDescriptors) { @@ -84,11 +106,13 @@ // 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() {} + var Prototype = function Prototype() {}; Prototype.prototype = prototype; var object = new Prototype(); if (typeof properties !== 'undefined') { - defineProperties(object, properties); + Object.keys(properties).forEach(function (key) { + Value.defineByDescriptor(object, key, properties[key]); + }); } return object; }; @@ -101,8 +125,9 @@ Object.setPrototypeOf(o, Subclass.prototype); return o; }; + Object.setPrototypeOf(Sub, C); Sub.prototype = create(C.prototype, { - constructor: { value: C } + constructor: { value: Sub } }); return f(Sub); }); @@ -118,9 +143,15 @@ return String.prototype.startsWith && 'abc'.startsWith('a', Infinity) === false; }()); - /*jshint evil: true */ - var getGlobal = new Function('return this;'); - /*jshint evil: false */ + var getGlobal = function () { + // the only reliable means to get the global object is + // `Function('return this')()` + // However, this causes CSP violations in Chrome apps. + if (typeof self !== 'undefined') { return self; } + if (typeof window !== 'undefined') { return window; } + if (typeof global !== 'undefined') { return global; } + throw new Error('unable to locate global object'); + }; var globals = getGlobal(); var globalIsFinite = globals.isFinite; @@ -128,32 +159,23 @@ var startsWithIsCompliant = startsWithRejectsRegex() && startsWithHandlesInfinity; var _indexOf = Function.call.bind(String.prototype.indexOf); var _toString = Function.call.bind(Object.prototype.toString); + var _concat = Function.call.bind(Array.prototype.concat); + var _strSlice = Function.call.bind(String.prototype.slice); + var _push = Function.call.bind(Array.prototype.push); + var _pushApply = Function.apply.bind(Array.prototype.push); + var _shift = Function.call.bind(Array.prototype.shift); + var _max = Math.max; + var _min = Math.min; + var _floor = Math.floor; + var _abs = Math.abs; + var _log = Math.log; + var _sqrt = Math.sqrt; var _hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty); var ArrayIterator; // make our implementation private var noop = function () {}; var Symbol = globals.Symbol || {}; var symbolSpecies = Symbol.species || '@@species'; - var Type = { - object: function (x) { return x !== null && typeof x === 'object'; }, - string: function (x) { return _toString(x) === '[object String]'; }, - regex: function (x) { return _toString(x) === '[object RegExp]'; }, - symbol: function (x) { - return typeof globals.Symbol === 'function' && typeof x === 'symbol'; - } - }; - - 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 Value = { getter: function (object, name, getter) { @@ -187,11 +209,60 @@ object[property] = newValue; } }, + defineByDescriptor: function (object, property, descriptor) { + if (supportsDescriptors) { + Object.defineProperty(object, property, descriptor); + } else if ('value' in descriptor) { + object[property] = descriptor.value; + } + }, preserveToString: function (target, source) { defineProperty(target, 'toString', source.toString.bind(source), true); } }; + var wrapConstructor = function wrapConstructor(original, replacement, keysToSkip) { + Value.preserveToString(replacement, original); + if (Object.setPrototypeOf) { + // sets up proper prototype chain where possible + Object.setPrototypeOf(original, replacement); + } + _forEach(Object.getOwnPropertyNames(original), function (key) { + if (key in noop || keysToSkip[key]) { return; } + Value.proxy(original, key, replacement); + }); + replacement.prototype = original.prototype; + Value.redefine(original.prototype, 'constructor', replacement); + }; + + var defaultSpeciesGetter = function () { return this; }; + var addDefaultSpecies = function (C) { + if (supportsDescriptors && !_hasOwnProperty(C, symbolSpecies)) { + Value.getter(C, symbolSpecies, defaultSpeciesGetter); + } + }; + var Type = { + primitive: function (x) { return x === null || (typeof x !== 'function' && typeof x !== 'object'); }, + object: function (x) { return x !== null && typeof x === 'object'; }, + string: function (x) { return _toString(x) === '[object String]'; }, + regex: function (x) { return _toString(x) === '[object RegExp]'; }, + symbol: function (x) { + return typeof globals.Symbol === 'function' && typeof x === 'symbol'; + } + }; + + 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 overrideNative = function overrideNative(object, property, replacement) { var original = object[property]; defineProperty(object, property, replacement, true); @@ -212,9 +283,7 @@ } var addIterator = function (prototype, impl) { var implementation = impl || function iterator() { return this; }; - var o = {}; - o[$iterator$] = implementation; - defineProperties(prototype, o); + defineProperty(prototype, $iterator$, implementation); if (!prototype[$iterator$] && Type.symbol($iterator$)) { // implementations are buggy when $iterator$ is a Symbol prototype[$iterator$] = implementation; @@ -237,8 +306,6 @@ return result; }; - var safeApply = Function.call.bind(Function.apply); - var ES = { // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args Call: function Call(F, V) { @@ -246,7 +313,7 @@ if (!ES.IsCallable(F)) { throw new TypeError(F + ' is not a function'); } - return safeApply(F, V, args); + return _apply(F, V, args); }, RequireObjectCoercible: function (x, optMessage) { @@ -273,6 +340,11 @@ return typeof x === 'function' && _toString(x) === '[object Function]'; }, + IsConstructor: function (x) { + // We can't tell callables from constructors in ES5 + return ES.IsCallable(x); + }, + ToInt32: function (x) { return ES.ToNumber(x) >> 0; }, @@ -292,7 +364,7 @@ var number = ES.ToNumber(value); if (numberIsNaN(number)) { return 0; } if (number === 0 || !numberIsFinite(number)) { return number; } - return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)); + return (number > 0 ? 1 : -1) * _floor(_abs(number)); }, ToLength: function (value) { @@ -325,17 +397,55 @@ // special case support for `arguments` return new ArrayIterator(o, 'value'); } - var itFn = o[$iterator$]; + var itFn = ES.GetMethod(o, $iterator$); if (!ES.IsCallable(itFn)) { + // Better diagnostics if itFn is null or undefined throw new TypeError('value is not an iterable'); } - var it = itFn.call(o); + var it = _call(itFn, o); if (!ES.TypeIsObject(it)) { throw new TypeError('bad iterator'); } return it; }, + GetMethod: function (o, p) { + var func = ES.ToObject(o)[p]; + if (func === void 0 || func === null) { + return void 0; + } + if (!ES.IsCallable(func)) { + throw new TypeError('Method not callable: ' + p); + } + return func; + }, + + IteratorComplete: function (iterResult) { + return !!(iterResult.done); + }, + + IteratorClose: function (iterator, completionIsThrow) { + var returnMethod = ES.GetMethod(iterator, 'return'); + if (returnMethod === void 0) { + return; + } + var innerResult, innerException; + try { + innerResult = _call(returnMethod, iterator); + } catch (e) { + innerException = e; + } + if (completionIsThrow) { + return; + } + if (innerException) { + throw innerException; + } + if (!ES.TypeIsObject(innerResult)) { + throw new TypeError("Iterator's return method returned a non-object."); + } + }, + IteratorNext: function (it) { var result = arguments.length > 1 ? it.next(arguments[1]) : it.next(); if (!ES.TypeIsObject(result)) { @@ -344,23 +454,53 @@ return result; }, - Construct: function (C, args) { - |