1 /* Polyfill service v3.27.1
2 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
4 * Features requested: es6
6 * - _ESAbstract.IsCallable, License: CC0 (required by "Array.from", "es6", "Array.prototype.find", "Array.prototype.findIndex", "Map", "Set", "WeakMap", "WeakSet", "_ESAbstract.GetMethod", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map", "Function.prototype.bind", "_ESAbstract.Construct", "Array.of", "Object.getOwnPropertyDescriptor", "Object.assign", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.fill", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
7 * - Object.defineProperty, License: CC0 (required by "Function.name", "es6", "Map", "Array.from", "Number.Epsilon", "Number.MAX_SAFE_INTEGER", "Number.MIN_SAFE_INTEGER", "Object.setPrototypeOf", "RegExp.prototype.flags", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Symbol", "WeakMap", "WeakSet", "_ESAbstract.CreateMethodProperty", "Array.of", "Array.prototype.copyWithin", "Array.prototype.entries", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.keys", "Array.prototype.values", "Math.acosh", "Math.asinh", "Math.atanh", "Math.cbrt", "Math.clz32", "Math.cosh", "Math.expm1", "Math.fround", "Math.hypot", "Math.imul", "Math.log10", "Math.log1p", "Math.log2", "Math.sign", "Math.sinh", "Math.tanh", "Math.trunc", "Number.isFinite", "Number.isInteger", "Number.isNaN", "Number.isSafeInteger", "Number.parseFloat", "Number.parseInt", "Object.assign", "Object.is", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "_ArrayIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_StringIterator", "_ESAbstract.CreateDataProperty", "_ESAbstract.CreateDataPropertyOrThrow", "_ESAbstract.CreateIterResultObject", "_Iterator", "Object.defineProperties", "Object.create", "_ESAbstract.GetIterator")
8 * - _ESAbstract.CreateMethodProperty, License: CC0 (required by "Array.from", "es6", "Array.of", "Array.prototype.@@iterator", "Array.prototype.copyWithin", "Array.prototype.entries", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.keys", "Array.prototype.values", "Map", "Math.acosh", "Math.asinh", "Math.atanh", "Math.cbrt", "Math.clz32", "Math.cosh", "Math.expm1", "Math.fround", "Math.hypot", "Math.imul", "Math.log10", "Math.log1p", "Math.log2", "Math.sign", "Math.sinh", "Math.tanh", "Math.trunc", "Number.isFinite", "Number.isInteger", "Number.isNaN", "Number.isSafeInteger", "Number.parseFloat", "Number.parseInt", "Object.assign", "Object.is", "Object.setPrototypeOf", "Set", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "WeakMap", "WeakSet", "Array.isArray", "Object.create", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.GetIterator", "_ArrayIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Object.getOwnPropertyDescriptor", "Array.prototype.forEach", "Object.getPrototypeOf", "Object.getOwnPropertyNames", "Array.prototype.filter", "Array.prototype.map", "Object.freeze", "Function.prototype.bind", "Object.defineProperties", "_Iterator", "_StringIterator")
9 * - _ESAbstract.ToObject, License: CC0 (required by "Array.from", "es6", "Array.prototype.entries", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "Object.assign", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.GetV", "_ESAbstract.GetMethod", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "Object.defineProperties", "Object.create", "_ArrayIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator", "_StringIterator")
10 * - _ESAbstract.GetV, License: CC0 (required by "_ESAbstract.GetMethod", "Array.from", "es6", "Map", "Set", "_ESAbstract.GetIterator", "WeakMap", "WeakSet")
11 * - _ESAbstract.GetMethod, License: CC0 (required by "Array.from", "es6", "Map", "Set", "_ESAbstract.IsConstructor", "Array.of", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ESAbstract.IteratorClose", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
12 * - _ESAbstract.ToInteger, License: CC0 (required by "Array.prototype.copyWithin", "es6", "Array.prototype.fill", "Number.isInteger", "Number.isSafeInteger", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "_ESAbstract.ToLength", "Array.from", "Array.prototype.find", "Array.prototype.findIndex")
13 * - _ESAbstract.ToLength, License: CC0 (required by "Array.from", "es6", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map")
14 * - _ESAbstract.Get, License: CC0 (required by "Array.from", "es6", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Object.assign", "RegExp.prototype.flags", "WeakMap", "WeakSet", "_ESAbstract.IteratorValue", "Map", "Set", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.GetPrototypeFromConstructor", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "Object.defineProperties", "Object.create", "_ESAbstract.GetIterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_Iterator", "_StringIterator", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "String.prototype.codePointAt", "String.prototype.repeat")
15 * - _ESAbstract.HasProperty, License: CC0 (required by "Array.prototype.copyWithin", "es6", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map")
16 * - _ESAbstract.Call, License: CC0 (required by "Array.from", "es6", "Array.prototype.find", "Array.prototype.findIndex", "WeakMap", "WeakSet", "_ESAbstract.GetIterator", "Map", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.IteratorNext", "_ESAbstract.IteratorStep", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.of", "Array.prototype.fill", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "_ESAbstract.OrdinaryToPrimitive")
17 * - _ESAbstract.Type, License: CC0 (required by "Map", "es6", "Array.from", "Number.isFinite", "Number.isInteger", "Number.isNaN", "Number.isSafeInteger", "RegExp.prototype.flags", "WeakMap", "WeakSet", "_ESAbstract.IsConstructor", "Array.of", "_ESAbstract.GetIterator", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.ToString", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "_ESAbstract.IteratorValue", "_ESAbstract.CreateIterResultObject", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "_ESAbstract.IteratorNext", "_ESAbstract.SameValueZero", "Object.create", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.SameValue", "Object.is", "_ESAbstract.IsRegExp", "_ESAbstract.ToPrimitive", "_ESAbstract.GetPrototypeFromConstructor", "Object.defineProperties", "_Iterator", "_StringIterator", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.OrdinaryToPrimitive")
18 * - _ESAbstract.OrdinaryToPrimitive, License: CC0 (required by "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.from", "es6", "Array.of", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
19 * - _ESAbstract.ToPrimitive, License: CC0 (required by "_ESAbstract.ToString", "Array.from", "es6", "Array.of", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
20 * - _ESAbstract.ToString, License: CC0 (required by "Array.from", "es6", "Array.of", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map")
21 * - Array.prototype.forEach, License: CC0 (required by "Object.setPrototypeOf", "es6", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
22 * - _ESAbstract.IsArray, License: CC0 (required by "WeakMap", "es6", "WeakSet", "Array.isArray", "Map", "Array.from", "Set", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
23 * - _ESAbstract.ArrayCreate, License: CC0 (required by "Array.from", "es6", "Array.of", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
24 * - _ESAbstract.IsConstructor, License: CC0 (required by "Array.from", "es6", "Array.of", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
25 * - _ESAbstract.GetPrototypeFromConstructor, License: CC0 (required by "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "es6", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
26 * - Object.keys, License: MIT (required by "Object.assign", "es6", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Object.defineProperties", "Object.create", "Object.setPrototypeOf", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator", "_StringIterator")
27 * - Function.prototype.bind, License: MIT (required by "_ESAbstract.Construct", "Array.from", "es6", "Array.of", "Object.getOwnPropertyDescriptor", "Object.assign", "Object.setPrototypeOf", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
28 * - Object.getOwnPropertyDescriptor, License: CC0 (required by "Object.assign", "es6", "Object.setPrototypeOf", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Object.defineProperties", "Object.create", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator", "_StringIterator")
29 * - Object.defineProperties, License: CC0 (required by "Object.create", "Map", "es6", "Array.from", "Object.setPrototypeOf", "Set", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator", "_StringIterator")
30 * - Object.create, License: CC0 (required by "Map", "es6", "Array.from", "Object.setPrototypeOf", "Set", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_StringIterator")
31 * - Object.getPrototypeOf, License: CC0 (required by "Object.setPrototypeOf", "es6", "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
32 * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "Map", "es6", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
33 * - _ESAbstract.Construct, License: CC0 (required by "Array.from", "es6", "Array.of", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
34 * - _ESAbstract.ArraySpeciesCreate, License: CC0 (required by "Array.prototype.filter", "Symbol", "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
35 * - _ESAbstract.ToBoolean, License: CC0 (required by "Array.prototype.find", "es6", "Array.prototype.findIndex", "RegExp.prototype.flags", "_ESAbstract.IteratorComplete", "Map", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.filter", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
36 * - _ESAbstract.CreateDataProperty, License: CC0 (required by "_ESAbstract.CreateDataPropertyOrThrow", "Array.from", "es6", "Array.of", "_ESAbstract.CreateIterResultObject", "Map", "Set")
37 * - _ESAbstract.CreateDataPropertyOrThrow, License: CC0 (required by "Array.from", "es6", "Array.of", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
38 * - Array.prototype.filter, License: CC0 (required by "Symbol", "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
39 * - Array.prototype.map, License: CC0 (required by "Symbol", "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
40 * - Object.getOwnPropertyNames, License: CC0 (required by "Object.setPrototypeOf", "es6", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
41 * - Object.freeze, License: CC0 (required by "Symbol", "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
42 * - Symbol, License: MIT (required by "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "WeakMap", "WeakSet", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
43 * - Symbol.iterator, License: MIT (required by "es6", "Array.from", "Array.prototype.@@iterator", "Map", "Set", "String.prototype.@@iterator", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
44 * - _ESAbstract.GetIterator, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
45 * - _ESAbstract.IteratorClose, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
46 * - _ESAbstract.IteratorNext, License: CC0 (required by "Map", "es6", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet")
47 * - _ESAbstract.IteratorComplete, License: CC0 (required by "Map", "es6", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet")
48 * - _ESAbstract.IteratorStep, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
49 * - _ESAbstract.IteratorValue, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
50 * - _ESAbstract.CreateIterResultObject, License: CC0 (required by "Map", "es6", "Array.from", "Set")
51 * - _ESAbstract.SameValueNonNumber, License: CC0 (required by "_ESAbstract.SameValueZero", "Map", "es6", "Array.from", "Set", "WeakSet", "_ESAbstract.SameValue", "Object.is", "WeakMap")
52 * - _ESAbstract.SameValueZero, License: CC0 (required by "Map", "es6", "Array.from", "Set", "WeakSet")
53 * - Array.isArray, License: CC0 (required by "Map", "es6", "Array.from", "Set", "WeakMap")
54 * - Symbol.species, License: MIT (required by "es6", "Map", "Array.from", "Set")
55 * - Map, License: CC0 (required by "es6", "Array.from")
56 * - Set, License: CC0 (required by "es6", "Array.from")
57 * - Array.from, License: CC0 (required by "es6")
58 * - Array.of, License: CC0 (required by "es6")
59 * - Object.assign, License: CC0 (required by "es6", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
60 * - Symbol.toStringTag, License: MIT (required by "es6", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
61 * - _Iterator, License: MIT (required by "_ArrayIterator", "Array.prototype.entries", "es6", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
62 * - Object.setPrototypeOf, License: MIT (required by "es6", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
63 * - _ESAbstract.RequireObjectCoercible, License: CC0 (required by "String.prototype.@@iterator", "es6", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
64 * - _ESAbstract.IsRegExp, License: CC0 (required by "String.prototype.endsWith", "es6", "String.prototype.includes", "String.prototype.startsWith")
65 * - String.prototype.includes, License: CC0 (required by "es6", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
66 * - _ArrayIterator, License: MIT (required by "Array.prototype.entries", "es6", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
67 * - Array.prototype.values, License: MIT (required by "es6", "Array.prototype.@@iterator")
68 * - Array.prototype.@@iterator, License: CC0 (required by "es6")
69 * - Array.prototype.copyWithin, License: MIT (required by "es6")
70 * - Array.prototype.entries, License: CC0 (required by "es6")
71 * - Array.prototype.fill, License: CC0 (required by "es6")
72 * - Array.prototype.find, License: CC0 (required by "es6")
73 * - Array.prototype.findIndex, License: CC0 (required by "es6")
74 * - Array.prototype.keys, License: CC0 (required by "es6")
75 * - Function.name, License: MIT (required by "es6")
76 * - Math.acosh, License: CC0 (required by "es6")
77 * - Math.asinh, License: CC0 (required by "es6")
78 * - Math.atanh, License: CC0 (required by "es6")
79 * - Math.cbrt, License: CC0 (required by "es6")
80 * - _ESAbstract.ToUint32, License: CC0 (required by "Math.clz32", "es6", "Math.imul")
81 * - Math.clz32, License: CC0 (required by "es6")
82 * - Math.cosh, License: CC0 (required by "es6")
83 * - Math.expm1, License: CC0 (required by "es6")
84 * - _TypedArray, License: Copyright 2010, Linden Research, Inc. Copyright 2014, Joshua Bell. (required by "Math.fround", "es6")
85 * - Math.fround, License: CC0 (required by "es6")
86 * - Math.hypot, License: CC0 (required by "es6")
87 * - Math.imul, License: CC0 (required by "es6")
88 * - Math.log10, License: CC0 (required by "es6")
89 * - Math.log1p, License: CC0 (required by "es6")
90 * - Math.log2, License: CC0 (required by "es6")
91 * - Math.sign, License: CC0 (required by "es6")
92 * - Math.sinh, License: CC0 (required by "es6")
93 * - Math.tanh, License: CC0 (required by "es6")
94 * - Math.trunc, License: CC0 (required by "es6")
95 * - Number.Epsilon, License: MIT (required by "es6")
96 * - Number.MAX_SAFE_INTEGER, License: MIT (required by "es6")
97 * - Number.MIN_SAFE_INTEGER, License: MIT (required by "es6")
98 * - Number.isFinite, License: MIT (required by "es6")
99 * - Number.isInteger, License: MIT (required by "es6")
100 * - Number.isNaN, License: MIT (required by "es6")
101 * - Number.isSafeInteger, License: MIT (required by "es6")
102 * - Number.parseFloat, License: MIT (required by "es6")
103 * - Number.parseInt, License: MIT (required by "es6")
104 * - _ESAbstract.SameValue, License: CC0 (required by "Object.is", "es6", "WeakMap")
105 * - Object.is, License: CC0 (required by "es6")
106 * - Promise, License: MIT (required by "es6")
107 * - RegExp.prototype.flags, License: MIT (required by "es6")
108 * - _StringIterator, License: MIT (required by "String.prototype.@@iterator", "es6")
109 * - String.prototype.@@iterator, License: CC0 (required by "es6")
110 * - _ESAbstract.UTF16Decode, License: CC0 (required by "String.prototype.codePointAt", "es6")
111 * - String.prototype.codePointAt, License: MIT (required by "es6")
112 * - String.prototype.endsWith, License: CC0 (required by "es6")
113 * - String.prototype.repeat, License: CC0 (required by "es6")
114 * - String.prototype.startsWith, License: CC0 (required by "es6")
115 * - Symbol.hasInstance, License: MIT (required by "es6")
116 * - Symbol.isConcatSpreadable, License: MIT (required by "es6")
117 * - Symbol.match, License: MIT (required by "es6")
118 * - Symbol.replace, License: MIT (required by "es6")
119 * - Symbol.search, License: MIT (required by "es6")
120 * - Symbol.split, License: MIT (required by "es6")
121 * - Symbol.toPrimitive, License: MIT (required by "es6")
122 * - Symbol.unscopables, License: MIT (required by "es6")
123 * - WeakMap, License: CC0 (required by "es6")
124 * - WeakSet, License: CC0 (required by "es6") */
126 (function(undefined) {
128 // _ESAbstract.IsCallable
129 // 7.2.3. IsCallable ( argument )
130 function IsCallable(argument) { // eslint-disable-line no-unused-vars
131 // 1. If Type(argument) is not Object, return false.
132 // 2. If argument has a [[Call]] internal method, return true.
135 // Polyfill.io - Only function objects have a [[Call]] internal method. This means we can simplify this function to check that the argument has a type of function.
136 return typeof argument === 'function';
138 if (!(// In IE8, defineProperty could only act on DOM elements, so full support
139 // for the feature requires the ability to set a property on an arbitrary object
140 'defineProperty' in Object && (function() {
143 Object.defineProperty(a, 'test', {value:42});
150 // Object.defineProperty
151 (function (nativeDefineProperty) {
153 var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
154 var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
155 var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
157 // Polyfill.io - This does not use CreateMethodProperty because our CreateMethodProperty function uses Object.defineProperty.
158 Object['defineProperty'] = function defineProperty(object, property, descriptor) {
160 // Where native support exists, assume it
161 if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
162 return nativeDefineProperty(object, property, descriptor);
165 if (object === null || !(object instanceof Object || typeof object === 'object')) {
166 throw new TypeError('Object.defineProperty called on non-object');
169 if (!(descriptor instanceof Object)) {
170 throw new TypeError('Property description must be an object');
173 var propertyString = String(property);
174 var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
175 var getterType = 'get' in descriptor && typeof descriptor.get;
176 var setterType = 'set' in descriptor && typeof descriptor.set;
178 // handle descriptor.get
180 if (getterType !== 'function') {
181 throw new TypeError('Getter must be a function');
183 if (!supportsAccessors) {
184 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
186 if (hasValueOrWritable) {
187 throw new TypeError(ERR_VALUE_ACCESSORS);
189 Object.__defineGetter__.call(object, propertyString, descriptor.get);
191 object[propertyString] = descriptor.value;
194 // handle descriptor.set
196 if (setterType !== 'function') {
197 throw new TypeError('Setter must be a function');
199 if (!supportsAccessors) {
200 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
202 if (hasValueOrWritable) {
203 throw new TypeError(ERR_VALUE_ACCESSORS);
205 Object.__defineSetter__.call(object, propertyString, descriptor.set);
208 // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
209 if ('value' in descriptor) {
210 object[propertyString] = descriptor.value;
215 }(Object.defineProperty));
220 // _ESAbstract.CreateMethodProperty
221 // 7.3.5. CreateMethodProperty ( O, P, V )
222 function CreateMethodProperty(O, P, V) { // eslint-disable-line no-unused-vars
223 // 1. Assert: Type(O) is Object.
224 // 2. Assert: IsPropertyKey(P) is true.
225 // 3. Let newDesc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}.
232 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
233 Object.defineProperty(O, P, newDesc);
236 // _ESAbstract.ToObject
237 // 7.1.13 ToObject ( argument )
238 // The abstract operation ToObject converts argument to a value of type Object according to Table 12:
239 // Table 12: ToObject Conversions
241 |----------------------------------------------------------------------------------------------------------------------------------------------------|
242 | Argument Type | Result |
243 |----------------------------------------------------------------------------------------------------------------------------------------------------|
244 | Undefined | Throw a TypeError exception. |
245 | Null | Throw a TypeError exception. |
246 | Boolean | Return a new Boolean object whose [[BooleanData]] internal slot is set to argument. See 19.3 for a description of Boolean objects. |
247 | Number | Return a new Number object whose [[NumberData]] internal slot is set to argument. See 20.1 for a description of Number objects. |
248 | String | Return a new String object whose [[StringData]] internal slot is set to argument. See 21.1 for a description of String objects. |
249 | Symbol | Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 19.4 for a description of Symbol objects. |
250 | Object | Return argument. |
251 |----------------------------------------------------------------------------------------------------------------------------------------------------|
253 function ToObject(argument) { // eslint-disable-line no-unused-vars
254 if (argument === null || argument === undefined) {
257 return Object(argument);
261 /* global ToObject */
263 function GetV(v, p) { // eslint-disable-line no-unused-vars
264 // 1. Assert: IsPropertyKey(P) is true.
265 // 2. Let O be ? ToObject(V).
267 // 3. Return ? O.[[Get]](P, V).
271 // _ESAbstract.GetMethod
272 /* global GetV, IsCallable */
273 // 7.3.9. GetMethod ( V, P )
274 function GetMethod(V, P) { // eslint-disable-line no-unused-vars
275 // 1. Assert: IsPropertyKey(P) is true.
276 // 2. Let func be ? GetV(V, P).
277 var func = GetV(V, P);
278 // 3. If func is either undefined or null, return undefined.
279 if (func === null || func === undefined) {
282 // 4. If IsCallable(func) is false, throw a TypeError exception.
283 if (IsCallable(func) === false) {
284 throw new TypeError('Method not callable: ' + P);
290 // _ESAbstract.ToInteger
291 // 7.1.4. ToInteger ( argument )
292 function ToInteger(argument) { // eslint-disable-line no-unused-vars
293 // 1. Let number be ? ToNumber(argument).
294 var number = Number(argument);
295 // 2. If number is NaN, return +0.
299 // 3. If number is +0, -0, +∞, or -∞, return number.
300 if (1/number === Infinity || 1/number === -Infinity || number === Infinity || number === -Infinity) {
303 // 4. Return the number value that is the same sign as number and whose magnitude is floor(abs(number)).
304 return ((number < 0) ? -1 : 1) * Math.floor(Math.abs(number));
307 // _ESAbstract.ToLength
308 /* global ToInteger */
309 // 7.1.15. ToLength ( argument )
310 function ToLength(argument) { // eslint-disable-line no-unused-vars
311 // 1. Let len be ? ToInteger(argument).
312 var len = ToInteger(argument);
313 // 2. If len ≤ +0, return +0.
317 // 3. Return min(len, 253-1).
318 return Math.min(len, Math.pow(2, 53) -1);
322 // 7.3.1. Get ( O, P )
323 function Get(O, P) { // eslint-disable-line no-unused-vars
324 // 1. Assert: Type(O) is Object.
325 // 2. Assert: IsPropertyKey(P) is true.
326 // 3. Return ? O.[[Get]](P, O).
330 // _ESAbstract.HasProperty
331 // 7.3.10. HasProperty ( O, P )
332 function HasProperty(O, P) { // eslint-disable-line no-unused-vars
333 // Assert: Type(O) is Object.
334 // Assert: IsPropertyKey(P) is true.
335 // Return ? O.[[HasProperty]](P).
340 /* global IsCallable */
341 // 7.3.12. Call ( F, V [ , argumentsList ] )
342 function Call(F, V /* [, argumentsList] */) { // eslint-disable-line no-unused-vars
343 // 1. If argumentsList is not present, set argumentsList to a new empty List.
344 var argumentsList = arguments.length > 2 ? arguments[2] : [];
345 // 2. If IsCallable(F) is false, throw a TypeError exception.
346 if (IsCallable(F) === false) {
347 throw new TypeError(Object.prototype.toString.call(F) + 'is not a function.');
349 // 3. Return ? F.[[Call]](V, argumentsList).
350 return F.apply(V, argumentsList);
354 // "Type(x)" is used as shorthand for "the type of x"...
355 function Type(x) { // eslint-disable-line no-unused-vars
368 // typeof null is 'object'
369 if (x === null) return 'null';
370 // Polyfill.io - This is here because a Symbol polyfill will have a typeof `object`.
371 if ('Symbol' in this && x instanceof this.Symbol) return 'symbol';
376 // _ESAbstract.OrdinaryToPrimitive
377 /* global Get, IsCallable, Call, Type */
378 // 7.1.1.1. OrdinaryToPrimitive ( O, hint )
379 function OrdinaryToPrimitive(O, hint) { // eslint-disable-line no-unused-vars
380 // 1. Assert: Type(O) is Object.
381 // 2. Assert: Type(hint) is String and its value is either "string" or "number".
382 // 3. If hint is "string", then
383 if (hint === 'string') {
384 // a. Let methodNames be « "toString", "valueOf" ».
385 var methodNames = ['toString', 'valueOf'];
388 // a. Let methodNames be « "valueOf", "toString" ».
389 methodNames = ['valueOf', 'toString'];
391 // 5. For each name in methodNames in List order, do
392 for (var i = 0; i < methodNames.length; ++i) {
393 var name = methodNames[i];
394 // a. Let method be ? Get(O, name).
395 var method = Get(O, name);
396 // b. If IsCallable(method) is true, then
397 if (IsCallable(method)) {
398 // i. Let result be ? Call(method, O).
399 var result = Call(method, O);
400 // ii. If Type(result) is not Object, return result.
401 if (Type(result) !== 'object') {
406 // 6. Throw a TypeError exception.
407 throw new TypeError('Cannot convert to primitive.');
410 // _ESAbstract.ToPrimitive
411 /* global Type, GetMethod, Call, OrdinaryToPrimitive */
412 // 7.1.1. ToPrimitive ( input [ , PreferredType ] )
413 function ToPrimitive(input /* [, PreferredType] */) { // eslint-disable-line no-unused-vars
414 var PreferredType = arguments.length > 1 ? arguments[1] : undefined;
415 // 1. Assert: input is an ECMAScript language value.
416 // 2. If Type(input) is Object, then
417 if (Type(input) === 'object') {
418 // a. If PreferredType is not present, let hint be "default".
419 if (arguments.length < 2) {
420 var hint = 'default';
421 // b. Else if PreferredType is hint String, let hint be "string".
422 } else if (PreferredType === String) {
424 // c. Else PreferredType is hint Number, let hint be "number".
425 } else if (PreferredType === Number) {
428 // d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
429 var exoticToPrim = typeof this.Symbol === 'function' && typeof this.Symbol.toPrimitive === 'symbol' ? GetMethod(input, this.Symbol.toPrimitive) : undefined;
430 // e. If exoticToPrim is not undefined, then
431 if (exoticToPrim !== undefined) {
432 // i. Let result be ? Call(exoticToPrim, input, « hint »).
433 var result = Call(exoticToPrim, input, [hint]);
434 // ii. If Type(result) is not Object, return result.
435 if (Type(result) !== 'object') {
438 // iii. Throw a TypeError exception.
439 throw new TypeError('Cannot convert exotic object to primitive.');
441 // f. If hint is "default", set hint to "number".
442 if (hint === 'default') {
445 // g. Return ? OrdinaryToPrimitive(input, hint).
446 return OrdinaryToPrimitive(input, hint);
452 // _ESAbstract.ToString
453 /* global Type, ToPrimitive */
454 // 7.1.12. ToString ( argument )
455 // The abstract operation ToString converts argument to a value of type String according to Table 11:
456 // Table 11: ToString Conversions
458 |---------------|--------------------------------------------------------|
459 | Argument Type | Result |
460 |---------------|--------------------------------------------------------|
461 | Undefined | Return "undefined". |
462 |---------------|--------------------------------------------------------|
463 | Null | Return "null". |
464 |---------------|--------------------------------------------------------|
465 | Boolean | If argument is true, return "true". |
466 | | If argument is false, return "false". |
467 |---------------|--------------------------------------------------------|
468 | Number | Return NumberToString(argument). |
469 |---------------|--------------------------------------------------------|
470 | String | Return argument. |
471 |---------------|--------------------------------------------------------|
472 | Symbol | Throw a TypeError exception. |
473 |---------------|--------------------------------------------------------|
474 | Object | Apply the following steps: |
475 | | Let primValue be ? ToPrimitive(argument, hint String). |
476 | | Return ? ToString(primValue). |
477 |---------------|--------------------------------------------------------|
479 function ToString(argument) { // eslint-disable-line no-unused-vars
480 switch(Type(argument)) {
482 throw new TypeError('Cannot convert a Symbol value to a string');
485 var primValue = ToPrimitive(argument, 'string');
486 return ToString(primValue);
488 return String(argument);
491 if (!('forEach' in Array.prototype)) {
493 // Array.prototype.forEach
494 /* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
495 // 22.1.3.10. Array.prototype.forEach ( callbackfn [ , thisArg ] )
496 CreateMethodProperty(Array.prototype, 'forEach', function forEach(callbackfn /* [ , thisArg ] */) {
497 // 1. Let O be ? ToObject(this value).
498 var O = ToObject(this);
499 // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
500 // We will use arrayLike in place of O when we are iterating through the list.
501 var arraylike = O instanceof String ? O.split('') : O;
502 // 2. Let len be ? ToLength(? Get(O, "length")).
503 var len = ToLength(Get(O, "length"));
504 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
505 if (IsCallable(callbackfn) === false) {
506 throw new TypeError(callbackfn + ' is not a function');
508 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
509 var T = arguments.length > 1 ? arguments[1] : undefined;
512 // 6. Repeat, while k < len
514 // a. Let Pk be ! ToString(k).
515 var Pk = ToString(k);
516 // b. Let kPresent be ? HasProperty(O, Pk).
517 var kPresent = HasProperty(arraylike, Pk);
518 // c. If kPresent is true, then
520 // i. Let kValue be ? Get(O, Pk).
521 var kValue = Get(arraylike, Pk);
522 // ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
523 Call(callbackfn, T, [kValue, k, O]);
525 // d. Increase k by 1.
528 // 7. Return undefined.
535 // _ESAbstract.IsArray
536 // 7.2.2. IsArray ( argument )
537 function IsArray(argument) { // eslint-disable-line no-unused-vars
538 // 1. If Type(argument) is not Object, return false.
539 // 2. If argument is an Array exotic object, return true.
540 // 3. If argument is a Proxy exotic object, then
541 // a. If argument.[[ProxyHandler]] is null, throw a TypeError exception.
542 // b. Let target be argument.[[ProxyTarget]].
543 // c. Return ? IsArray(target).
546 // Polyfill.io - We can skip all the above steps and check the string returned from Object.prototype.toString().
547 return Object.prototype.toString.call(argument) === '[object Array]';
550 // _ESAbstract.ArrayCreate
551 // 9.4.2.2. ArrayCreate ( length [ , proto ] )
552 function ArrayCreate(length /* [, proto] */) { // eslint-disable-line no-unused-vars
553 // 1. Assert: length is an integer Number ≥ 0.
554 // 2. If length is -0, set length to +0.
555 if (1 / length === -Infinity) {
558 // 3. If length>2^32-1, throw a RangeError exception.
559 if (length > (Math.pow(2, 32) - 1)) {
560 throw new RangeError('Invalid array length');
562 // 4. If proto is not present, set proto to the intrinsic object %ArrayPrototype%.
563 // 5. Let A be a newly created Array exotic object.
565 // 6. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.
566 // 7. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1.
567 // 8. Set A.[[Prototype]] to proto.
568 // 9. Set A.[[Extensible]] to true.
569 // 10. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
575 // _ESAbstract.IsConstructor
577 // 7.2.4. IsConstructor ( argument )
578 function IsConstructor(argument) { // eslint-disable-line no-unused-vars
579 // 1. If Type(argument) is not Object, return false.
580 if (Type(argument) !== 'object') {
583 // 2. If argument has a [[Construct]] internal method, return true.
586 // Polyfill.io - `new argument` is the only way to truly test if a function is a constructor.
587 // We choose to not use`new argument` because the argument could have side effects when called.
588 // Instead we check to see if the argument is a function and if it has a prototype.
589 // Arrow functions do not have a [[Construct]] internal method, nor do they have a prototype.
590 return typeof argument === 'function' && !!argument.prototype;
593 // _ESAbstract.GetPrototypeFromConstructor
594 /* global Get, Type */
595 // 9.1.14. GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
596 function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
597 // 1. Assert: intrinsicDefaultProto is a String value that is this specification's name of an intrinsic object. The corresponding object must be an intrinsic that is intended to be used as the [[Prototype]] value of an object.
598 // 2. Assert: IsCallable(constructor) is true.
599 // 3. Let proto be ? Get(constructor, "prototype").
600 var proto = Get(constructor, "prototype");
601 // 4. If Type(proto) is not Object, then
602 if (Type(proto) !== 'object') {
603 // a. Let realm be ? GetFunctionRealm(constructor).
604 // b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
605 proto = intrinsicDefaultProto;
610 if (!('keys' in Object && (function () {
611 // Safari 5.0 bug where Object.keys doesn't work with arguments
612 return (Object.keys(arguments)).length === 2;
613 }(1, 2)) && (function () {
615 // In ES6 Object.keys works on all object except `null` and `undefined`.
624 Object.keys = (function() {
627 // modified from https://github.com/es-shims/object-keys
629 var has = Object.prototype.hasOwnProperty;
630 var toStr = Object.prototype.toString;
631 var isEnumerable = Object.prototype.propertyIsEnumerable;
632 var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
633 var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
640 'propertyIsEnumerable',
643 var equalsConstructorPrototype = function (o) {
644 var ctor = o.constructor;
645 return ctor && ctor.prototype === o;
665 $webkitIndexedDB: true,
666 $webkitStorageInfo: true,
669 var hasAutomationEqualityBug = (function () {
671 if (typeof window === 'undefined') { return false; }
672 for (var k in window) {
674 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
676 equalsConstructorPrototype(window[k]);
687 var equalsConstructorPrototypeIfNotBuggy = function (o) {
689 if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
690 return equalsConstructorPrototype(o);
693 return equalsConstructorPrototype(o);
699 function isArgumentsObject(value) {
700 var str = toStr.call(value);
701 var isArgs = str === '[object Arguments]';
703 isArgs = str !== '[object Array]' &&
705 typeof value === 'object' &&
706 typeof value.length === 'number' &&
708 toStr.call(value.callee) === '[object Function]';
713 return function keys(object) {
714 var isFunction = toStr.call(object) === '[object Function]';
715 var isArguments = isArgumentsObject(object);
716 var isString = toStr.call(object) === '[object String]';
719 if (object === undefined || object === null) {
720 throw new TypeError('Cannot convert undefined or null to object');
723 var skipProto = hasProtoEnumBug && isFunction;
724 if (isString && object.length > 0 && !has.call(object, 0)) {
725 for (var i = 0; i < object.length; ++i) {
726 theKeys.push(String(i));
730 if (isArguments && object.length > 0) {
731 for (var j = 0; j < object.length; ++j) {
732 theKeys.push(String(j));
735 for (var name in object) {
736 if (!(skipProto && name === 'prototype') && has.call(object, name)) {
737 theKeys.push(String(name));
742 if (hasDontEnumBug) {
743 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
745 for (var k = 0; k < dontEnums.length; ++k) {
746 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
747 theKeys.push(dontEnums[k]);
757 if (!('bind' in Function.prototype)) {
759 // Function.prototype.bind
760 /* global CreateMethodProperty, IsCallable */
761 // 19.2.3.2. Function.prototype.bind ( thisArg, ...args )
762 // https://github.com/es-shims/es5-shim/blob/d6d7ff1b131c7ba14c798cafc598bb6780d37d3b/es5-shim.js#L182
763 CreateMethodProperty(Function.prototype, 'bind', function bind(that) { // .length is 1
764 // add necessary es5-shim utilities
766 var $Object = Object;
767 var ArrayPrototype = $Array.prototype;
768 var Empty = function Empty() { };
769 var array_slice = ArrayPrototype.slice;
770 var array_concat = ArrayPrototype.concat;
771 var array_push = ArrayPrototype.push;
773 // /add necessary es5-shim utilities
775 // 1. Let Target be the this value.
777 // 2. If IsCallable(Target) is false, throw a TypeError exception.
778 if (!IsCallable(target)) {
779 throw new TypeError('Function.prototype.bind called on incompatible ' + target);
781 // 3. Let A be a new (possibly empty) internal list of all of the
782 // argument values provided after thisArg (arg1, arg2 etc), in order.
783 // XXX slicedArgs will stand in for "A" if used
784 var args = array_slice.call(arguments, 1); // for normal call
785 // 4. Let F be a new native ECMAScript object.
786 // 11. Set the [[Prototype]] internal property of F to the standard
787 // built-in Function prototype object as specified in 15.3.3.1.
788 // 12. Set the [[Call]] internal property of F as described in
790 // 13. Set the [[Construct]] internal property of F as described in
792 // 14. Set the [[HasInstance]] internal property of F as described in
795 var binder = function () {
797 if (this instanceof bound) {
798 // 15.3.4.5.2 [[Construct]]
799 // When the [[Construct]] internal method of a function object,
800 // F that was created using the bind function is called with a
801 // list of arguments ExtraArgs, the following steps are taken:
802 // 1. Let target be the value of F's [[TargetFunction]]
803 // internal property.
804 // 2. If target has no [[Construct]] internal method, a
805 // TypeError exception is thrown.
806 // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
808 // 4. Let args be a new list containing the same values as the
809 // list boundArgs in the same order followed by the same
810 // values as the list ExtraArgs in the same order.
811 // 5. Return the result of calling the [[Construct]] internal
812 // method of target providing args as the arguments.
814 var result = target.apply(
816 array_concat.call(args, array_slice.call(arguments))
818 if ($Object(result) === result) {
824 // 15.3.4.5.1 [[Call]]
825 // When the [[Call]] internal method of a function object, F,
826 // which was created using the bind function is called with a
827 // this value and a list of arguments ExtraArgs, the following
829 // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
831 // 2. Let boundThis be the value of F's [[BoundThis]] internal
833 // 3. Let target be the value of F's [[TargetFunction]] internal
835 // 4. Let args be a new list containing the same values as the
836 // list boundArgs in the same order followed by the same
837 // values as the list ExtraArgs in the same order.
838 // 5. Return the result of calling the [[Call]] internal method
839 // of target providing boundThis as the this value and
840 // providing args as the arguments.
842 // equiv: target.call(this, ...boundArgs, ...args)
845 array_concat.call(args, array_slice.call(arguments))
852 // 15. If the [[Class]] internal property of Target is "Function", then
853 // a. Let L be the length property of Target minus the length of A.
854 // b. Set the length own property of F to either 0 or L, whichever is
856 // 16. Else set the length own property of F to 0.
858 var boundLength = max(0, target.length - args.length);
860 // 17. Set the attributes of the length own property of F to the values
861 // specified in 15.3.5.1.
863 for (var i = 0; i < boundLength; i++) {
864 array_push.call(boundArgs, '$' + i);
867 // XXX Build a dynamic function with desired amount of arguments is the only
868 // way to set the length property of a function.
869 // In environments where Content Security Policies enabled (Chrome extensions,
870 // for ex.) all use of eval or Function costructor throws an exception.
871 // However in all of these environments Function.prototype.bind exists
872 // and so this code will never be executed.
873 bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
875 if (target.prototype) {
876 Empty.prototype = target.prototype;
877 bound.prototype = new Empty();
878 // Clean up dangling references.
879 Empty.prototype = null;
883 // 18. Set the [[Extensible]] internal property of F to true.
886 // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
887 // 20. Call the [[DefineOwnProperty]] internal method of F with
888 // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
889 // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
891 // 21. Call the [[DefineOwnProperty]] internal method of F with
892 // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
893 // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
897 // NOTE Function objects created using Function.prototype.bind do not
898 // have a prototype property or the [[Code]], [[FormalParameters]], and
899 // [[Scope]] internal properties.
900 // XXX can't delete prototype in pure-js.
908 if (!('getOwnPropertyDescriptor' in Object && typeof Object.getOwnPropertyDescriptor === 'function' && (function() {
912 return Object.getOwnPropertyDescriptor(
916 } catch (exception) {
921 // Object.getOwnPropertyDescriptor
922 /* global CreateMethodProperty */
924 var call = Function.prototype.call;
925 var prototypeOfObject = Object.prototype;
926 var owns = call.bind(prototypeOfObject.hasOwnProperty);
930 var supportsAccessors;
931 if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
932 lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
933 lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
935 function doesGetOwnPropertyDescriptorWork(object) {
938 return Object.getOwnPropertyDescriptor(
942 } catch (exception) {
946 // check whether getOwnPropertyDescriptor works if it's given. Otherwise,
948 if (Object.defineProperty) {
949 var getOwnPropertyDescriptorWorksOnObject =
950 doesGetOwnPropertyDescriptorWork({});
951 var getOwnPropertyDescriptorWorksOnDom = typeof document == "undefined" ||
952 doesGetOwnPropertyDescriptorWork(document.createElement("div"));
953 if (!getOwnPropertyDescriptorWorksOnDom ||
954 !getOwnPropertyDescriptorWorksOnObject
956 var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
960 if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
961 var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
963 CreateMethodProperty(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(object, property) {
964 if ((typeof object != "object" && typeof object != "function") || object === null) {
965 throw new TypeError(ERR_NON_OBJECT + object);
968 // make a valiant attempt to use the real getOwnPropertyDescriptor
969 // for I8's DOM elements.
970 if (getOwnPropertyDescriptorFallback) {
972 return getOwnPropertyDescriptorFallback.call(Object, object, property);
973 } catch (exception) {
974 // try the shim if the real one doesn't work
978 // If object does not owns property return undefined immediately.
979 if (!owns(object, property)) {
983 // If object has a property then it's for sure both `enumerable` and
985 var descriptor = { enumerable: true, configurable: true };
987 // If JS engine supports accessor properties then property may be a
989 if (supportsAccessors) {
990 // Unfortunately `__lookupGetter__` will return a getter even
991 // if object has own non getter property along with a same named
992 // inherited getter. To avoid misbehavior we temporary remove
993 // `__proto__` so that `__lookupGetter__` will return getter only
994 // if it's owned by an object.
995 var prototype = object.__proto__;
996 object.__proto__ = prototypeOfObject;
998 var getter = lookupGetter(object, property);
999 var setter = lookupSetter(object, property);
1001 // Once we have getter and setter we can put values back.
1002 object.__proto__ = prototype;
1004 if (getter || setter) {
1006 descriptor.get = getter;
1009 descriptor.set = setter;
1011 // If it was accessor property we're done and return here
1012 // in order to avoid adding `value` to the descriptor.
1017 // If we got this far we know that object has an own property that is
1018 // not an accessor so we set it as a value and return descriptor.
1019 descriptor.value = object[property];
1020 descriptor.writable = true;
1028 if (!('defineProperties' in Object)) {
1030 // Object.defineProperties
1031 /* global CreateMethodProperty, Get, ToObject, Type */
1032 // 19.1.2.3. Object.defineProperties ( O, Properties )
1033 CreateMethodProperty(Object, 'defineProperties', function defineProperties(O, Properties) {
1034 // 1. If Type(O) is not Object, throw a TypeError exception.
1035 if (Type(O) !== 'object') {
1036 throw new TypeError('Object.defineProperties called on non-object');
1038 // 2. Let props be ? ToObject(Properties).
1039 var props = ToObject(Properties);
1040 // 3. Let keys be ? props.[[OwnPropertyKeys]]().
1042 Polyfill.io - This step in our polyfill is not complying with the specification.
1043 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
1044 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
1046 var keys = Object.keys(props);
1047 // 4. Let descriptors be a new empty List.
1048 var descriptors = [];
1049 // 5. For each element nextKey of keys in List order, do
1050 for (var i = 0; i < keys.length; i++) {
1051 var nextKey = keys[i];
1052 // a. Let propDesc be ? props.[[GetOwnProperty]](nextKey).
1053 var propDesc = Object.getOwnPropertyDescriptor(props, nextKey);
1054 // b. If propDesc is not undefined and propDesc.[[Enumerable]] is true, then
1055 if (propDesc !== undefined && propDesc.enumerable) {
1056 // i. Let descObj be ? Get(props, nextKey).
1057 var descObj = Get(props, nextKey);
1058 // ii. Let desc be ? ToPropertyDescriptor(descObj).
1059 // Polyfill.io - We skip this step because Object.defineProperty deals with it.
1060 // TODO: Implement this step?
1062 // iii. Append the pair (a two element List) consisting of nextKey and desc to the end of descriptors.
1063 descriptors.push([nextKey, desc]);
1066 // 6. For each pair from descriptors in list order, do
1067 for (var i = 0; i < descriptors.length; i++){
1068 // a. Let P be the first element of pair.
1069 var P = descriptors[i][0];
1070 // b. Let desc be the second element of pair.
1071 var desc = descriptors[i][1];
1072 // c. Perform ? DefinePropertyOrThrow(O, P, desc).
1073 Object.defineProperty(O, P, desc);
1081 if (!('create' in Object)) {
1084 /* global CreateMethodProperty, Type */
1085 CreateMethodProperty(Object, 'create', function create(O, properties) {
1086 // 1. If Type(O) is neither Object nor Null, throw a TypeError exception.
1087 if (Type(O) !== 'object' && Type(O) !== 'null') {
1088 throw new TypeError('Object prototype may only be an Object or null');
1090 // 2. Let obj be ObjectCreate(O).
1091 var obj = new Function('e', 'function Object() {}Object.prototype=e;return new Object')(O);
1093 obj.constructor.prototype = O;
1095 // 3. If Properties is not undefined, then
1096 if (1 in arguments) {
1097 // a. Return ? ObjectDefineProperties(obj, Properties).
1098 return Object.defineProperties(obj, properties);
1106 if (!('getPrototypeOf' in Object)) {
1108 // Object.getPrototypeOf
1109 /* global CreateMethodProperty */
1110 // Based on: https://github.com/es-shims/es5-shim/blob/master/es5-sham.js
1112 // https://github.com/es-shims/es5-shim/issues#issue/2
1113 // http://ejohn.org/blog/objectgetprototypeof/
1114 // recommended by fschaefer on github
1116 // sure, and webreflection says ^_^
1117 // ... this will nerever possibly return null
1118 // ... Opera Mini breaks here with infinite loops
1119 CreateMethodProperty(Object, 'getPrototypeOf', function getPrototypeOf(object) {
1120 if (object !== Object(object)) {
1121 throw new TypeError('Object.getPrototypeOf called on non-object');
1123 var proto = object.__proto__;
1124 if (proto || proto === null) {
1126 } else if (typeof object.constructor == 'function' && object instanceof object.constructor) {
1127 return object.constructor.prototype;
1128 } else if (object instanceof Object) {
1129 return Object.prototype;
1131 // Correctly return null for Objects created with `Object.create(null)`
1132 // (shammed or native) or `{ __proto__: null}`. Also returns null for
1133 // cross-realm objects on browsers that lack `__proto__` support (like
1134 // IE <11), but that's the best we can do.
1142 // _ESAbstract.OrdinaryCreateFromConstructor
1143 /* global GetPrototypeFromConstructor */
1144 // 9.1.13. OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
1145 function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
1146 var internalSlotsList = arguments[2] || {};
1147 // 1. Assert: intrinsicDefaultProto is a String value that is this specification's name of an intrinsic object.
1148 // The corresponding object must be an intrinsic that is intended to be used as the[[Prototype]] value of an object.
1150 // 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
1151 var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto);
1153 // 3. Return ObjectCreate(proto, internalSlotsList).
1154 // Polyfill.io - We do not pass internalSlotsList to Object.create because Object.create does not use the default ordinary object definitions specified in 9.1.
1155 var obj = Object.create(proto);
1156 for (var name in internalSlotsList) {
1157 if (Object.prototype.hasOwnProperty.call(internalSlotsList, name)) {
1158 Object.defineProperty(obj, name, {
1162 value: internalSlotsList[name]
1169 // _ESAbstract.Construct
1170 /* global IsConstructor, OrdinaryCreateFromConstructor, Call */
1171 // 7.3.13. Construct ( F [ , argumentsList [ , newTarget ]] )
1172 function Construct(F /* [ , argumentsList [ , newTarget ]] */) { // eslint-disable-line no-unused-vars
1173 // 1. If newTarget is not present, set newTarget to F.
1174 var newTarget = arguments.length > 2 ? arguments[2] : F;
1176 // 2. If argumentsList is not present, set argumentsList to a new empty List.
1177 var argumentsList = arguments.length > 1 ? arguments[1] : [];
1179 // 3. Assert: IsConstructor(F) is true.
1180 if (!IsConstructor(F)) {
1181 throw new TypeError('F must be a constructor.');
1184 // 4. Assert: IsConstructor(newTarget) is true.
1185 if (!IsConstructor(newTarget)) {
1186 throw new TypeError('newTarget must be a constructor.');
1189 // 5. Return ? F.[[Construct]](argumentsList, newTarget).
1190 // Polyfill.io - If newTarget is the same as F, it is equivalent to new F(...argumentsList).
1191 if (newTarget === F) {
1192 return new (Function.prototype.bind.apply(F, [null].concat(argumentsList)))();
1194 // Polyfill.io - This is mimicking section 9.2.2 step 5.a.
1195 var obj = OrdinaryCreateFromConstructor(newTarget, Object.prototype);
1196 return Call(F, obj, argumentsList);
1200 // _ESAbstract.ArraySpeciesCreate
1201 /* global IsArray, ArrayCreate, Get, Type, IsConstructor, Construct */
1202 // 9.4.2.3. ArraySpeciesCreate ( originalArray, length )
1203 function ArraySpeciesCreate(originalArray, length) { // eslint-disable-line no-unused-vars
1204 // 1. Assert: length is an integer Number ≥ 0.
1205 // 2. If length is -0, set length to +0.
1206 if (1/length === -Infinity) {
1210 // 3. Let isArray be ? IsArray(originalArray).
1211 var isArray = IsArray(originalArray);
1213 // 4. If isArray is false, return ? ArrayCreate(length).
1214 if (isArray === false) {
1215 return ArrayCreate(length);
1218 // 5. Let C be ? Get(originalArray, "constructor").
1219 var C = Get(originalArray, 'constructor');
1221 // Polyfill.io - We skip this section as not sure how to make a cross-realm normal Array, a same-realm Array.
1222 // 6. If IsConstructor(C) is true, then
1223 // if (IsConstructor(C)) {
1224 // a. Let thisRealm be the current Realm Record.
1225 // b. Let realmC be ? GetFunctionRealm(C).
1226 // c. If thisRealm and realmC are not the same Realm Record, then
1227 // i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined.
1229 // 7. If Type(C) is Object, then
1230 if (Type(C) === 'object') {
1231 // a. Set C to ? Get(C, @@species).
1232 C = 'Symbol' in this && 'species' in this.Symbol ? Get(C, this.Symbol.species) : undefined;
1233 // b. If C is null, set C to undefined.
1238 // 8. If C is undefined, return ? ArrayCreate(length).
1239 if (C === undefined) {
1240 return ArrayCreate(length);
1242 // 9. If IsConstructor(C) is false, throw a TypeError exception.
1243 if (!IsConstructor(C)) {
1244 throw new TypeError('C must be a constructor');
1246 // 10. Return ? Construct(C, « length »).
1247 return Construct(C, [length]);
1250 // _ESAbstract.ToBoolean
1251 // 7.1.2. ToBoolean ( argument )
1252 // The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 9:
1254 --------------------------------------------------------------------------------------------------------------
1255 | Argument Type | Result |
1256 --------------------------------------------------------------------------------------------------------------
1257 | Undefined | Return false. |
1258 | Null | Return false. |
1259 | Boolean | Return argument. |
1260 | Number | If argument is +0, -0, or NaN, return false; otherwise return true. |
1261 | String | If argument is the empty String (its length is zero), return false; otherwise return true. |
1262 | Symbol | Return true. |
1263 | Object | Return true. |
1264 --------------------------------------------------------------------------------------------------------------
1266 function ToBoolean(argument) { // eslint-disable-line no-unused-vars
1267 return Boolean(argument);
1270 // _ESAbstract.CreateDataProperty
1271 // 7.3.4. CreateDataProperty ( O, P, V )
1273 // This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator.
1274 // Normally, the property will not already exist. If it does exist and is not configurable or if O is not extensible, [[DefineOwnProperty]] will return false.
1275 function CreateDataProperty(O, P, V) { // eslint-disable-line no-unused-vars
1276 // 1. Assert: Type(O) is Object.
1277 // 2. Assert: IsPropertyKey(P) is true.
1278 // 3. Let newDesc be the PropertyDescriptor{ [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.
1285 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
1287 Object.defineProperty(O, P, newDesc);
1294 // _ESAbstract.CreateDataPropertyOrThrow
1295 /* global CreateDataProperty */
1296 // 7.3.6. CreateDataPropertyOrThrow ( O, P, V )
1297 function CreateDataPropertyOrThrow(O, P, V) { // eslint-disable-line no-unused-vars
1298 // 1. Assert: Type(O) is Object.
1299 // 2. Assert: IsPropertyKey(P) is true.
1300 // 3. Let success be ? CreateDataProperty(O, P, V).
1301 var success = CreateDataProperty(O, P, V);
1302 // 4. If success is false, throw a TypeError exception.
1304 throw new TypeError('Cannot assign value `' + Object.prototype.toString.call(V) + '` to property `' + Object.prototype.toString.call(P) + '` on object `' + Object.prototype.toString.call(O) + '`');
1306 // 5. Return success.
1309 if (!('filter' in Array.prototype)) {
1311 // Array.prototype.filter
1312 /* global CreateMethodProperty, ToObject, ToLength, Get, IsCallable, ArraySpeciesCreate, ToString, HasProperty, ToBoolean, Call, CreateDataPropertyOrThrow */
1313 // 22.1.3.7. Array.prototype.filter ( callbackfn [ , thisArg ] )
1314 CreateMethodProperty(Array.prototype, 'filter', function filter(callbackfn /* [ , thisArg ] */) {
1315 // 1. Let O be ? ToObject(this value).
1316 var O = ToObject(this);
1317 // 2. Let len be ? ToLength(? Get(O, "length")).
1318 var len = ToLength(Get(O, "length"));
1319 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
1320 if (IsCallable(callbackfn) === false) {
1321 throw new TypeError(callbackfn + ' is not a function');
1323 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
1324 var T = arguments.length > 1 ? arguments[1] : undefined;
1325 // 5. Let A be ? ArraySpeciesCreate(O, 0).
1326 var A = ArraySpeciesCreate(O, 0);
1331 // 8. Repeat, while k < len
1333 // a. Let Pk be ! ToString(k).
1334 var Pk = ToString(k);
1335 // b. Let kPresent be ? HasProperty(O, Pk).
1336 var kPresent = HasProperty(O, Pk);
1337 // c. If kPresent is true, then
1339 // i. Let kValue be ? Get(O, Pk).
1340 var kValue = Get(O, Pk);
1341 // ii. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
1342 var selected = ToBoolean(Call(callbackfn, T, [kValue, k, O]));
1343 // iii. If selected is true, then
1345 // 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue)
1346 CreateDataPropertyOrThrow(A, ToString(to), kValue);
1347 // 2. Increase to by 1.
1352 // d. Increase k by 1.
1361 if (!('map' in Array.prototype)) {
1363 // Array.prototype.map
1364 /* global ArraySpeciesCreate, Call, CreateDataPropertyOrThrow, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
1365 /* global CreateMethodProperty, ToObject, ToLength, Get, ArraySpeciesCreate, ToString, HasProperty, Call, CreateDataPropertyOrThrow */
1366 // 22.1.3.16. Array.prototype.map ( callbackfn [ , thisArg ] )
1367 CreateMethodProperty(Array.prototype, 'map', function map(callbackfn /* [ , thisArg ] */) {
1368 // 1. Let O be ? ToObject(this value).
1369 var O = ToObject(this);
1370 // 2. Let len be ? ToLength(? Get(O, "length")).
1371 var len = ToLength(Get(O, "length"));
1372 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
1373 if (IsCallable(callbackfn) === false) {
1374 throw new TypeError(callbackfn + ' is not a function');
1376 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
1377 var T = arguments.length > 1 ? arguments[1] : undefined;
1378 // 5. Let A be ? ArraySpeciesCreate(O, len).
1379 var A = ArraySpeciesCreate(O, len);
1382 // 7. Repeat, while k < len
1384 // a. Let Pk be ! ToString(k).
1385 var Pk = ToString(k);
1386 // b. Let kPresent be ? HasProperty(O, Pk).
1387 var kPresent = HasProperty(O, Pk);
1388 // c. If kPresent is true, then
1390 // i. Let kValue be ? Get(O, Pk).
1391 var kValue = Get(O, Pk);
1392 // ii. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
1393 var mappedValue = Call(callbackfn, T, [kValue, k, O]);
1394 // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
1395 CreateDataPropertyOrThrow(A, Pk, mappedValue);
1397 // d. Increase k by 1.
1406 if (!('getOwnPropertyNames' in Object)) {
1408 // Object.getOwnPropertyNames
1409 /* global CreateMethodProperty */
1411 var toString = ({}).toString;
1412 var split = ''.split;
1414 CreateMethodProperty(Object, 'getOwnPropertyNames', function getOwnPropertyNames(object) {
1418 // Non-enumerable properties cannot be discovered but can be checked for by name.
1419 // Define those used internally by JS to allow an incomplete solution
1420 var commonProps = ['length', "name", "arguments", "caller", "prototype", "observe", "unobserve"];
1422 if (typeof object === 'undefined' || object === null) {
1423 throw new TypeError('Cannot convert undefined or null to object');
1426 // Polyfill.io fallback for non-array-like strings which exist in some ES3 user-agents (IE 8)
1427 object = toString.call(object) == '[object String]' ? split.call(object, '') : Object(object);
1429 // Enumerable properties only
1430 for (key in object) {
1431 if (Object.prototype.hasOwnProperty.call(object, key)) {
1436 // Check for and add the common non-enumerable properties
1437 for (var i=0, s=commonProps.length; i<s; i++) {
1438 if (commonProps[i] in object) buffer.push(commonProps[i]);
1446 if (!('freeze' in Object)) {
1449 /* global CreateMethodProperty */
1450 // 19.1.2.6. Object.freeze ( O )
1451 CreateMethodProperty(Object, 'freeze', function freeze(O) {
1452 // This feature cannot be implemented fully as a polyfill.
1453 // We choose to silently fail which allows "securable" code
1454 // to "gracefully" degrade to working but insecure code.
1460 if (!('Symbol' in this && this.Symbol.length === 0)) {
1463 // A modification of https://github.com/WebReflection/get-own-property-symbols
1464 // (C) Andrea Giammarchi - MIT Licensed
1466 (function (Object, GOPS, global) {
1470 var random = '' + Math.random();
1471 var prefix = '__\x01symbol:';
1472 var prefixLength = prefix.length;
1473 var internalSymbol = '__\x01symbol@@' + random;
1474 var DP = 'defineProperty';
1475 var DPies = 'defineProperties';
1476 var GOPN = 'getOwnPropertyNames';
1477 var GOPD = 'getOwnPropertyDescriptor';
1478 var PIE = 'propertyIsEnumerable';
1479 var ObjectProto = Object.prototype;
1480 var hOP = ObjectProto.hasOwnProperty;
1481 var pIE = ObjectProto[PIE];
1482 var toString = ObjectProto.toString;
1483 var concat = Array.prototype.concat;
1484 var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : [];
1485 var nGOPN = Object[GOPN];
1486 var gOPN = function getOwnPropertyNames (obj) {
1487 if (toString.call(obj) === '[object Window]') {
1491 // IE bug where layout engine calls userland gOPN for cross-domain `window` objects
1492 return concat.call([], cachedWindowNames);
1497 var gOPD = Object[GOPD];
1498 var create = Object.create;
1499 var keys = Object.keys;
1500 var freeze = Object.freeze || Object;
1501 var defineProperty = Object[DP];
1502 var $defineProperties = Object[DPies];
1503 var descriptor = gOPD(Object, GOPN);
1504 var addInternalIfNeeded = function (o, uid, enumerable) {
1505 if (!hOP.call(o, internalSymbol)) {
1507 defineProperty(o, internalSymbol, {
1509 configurable: false,
1514 o[internalSymbol] = {};
1517 o[internalSymbol]['@@' + uid] = enumerable;
1519 var createWithSymbols = function (proto, descriptors) {
1520 var self = create(proto);
1521 gOPN(descriptors).forEach(function (key) {
1522 if (propertyIsEnumerable.call(descriptors, key)) {
1523 $defineProperty(self, key, descriptors[key]);
1528 var copyAsNonEnumerable = function (descriptor) {
1529 var newDescriptor = create(descriptor);
1530 newDescriptor.enumerable = false;
1531 return newDescriptor;
1533 var get = function get(){};
1534 var onlyNonSymbols = function (name) {
1535 return name != internalSymbol &&
1536 !hOP.call(source, name);
1538 var onlySymbols = function (name) {
1539 return name != internalSymbol &&
1540 hOP.call(source, name);
1542 var propertyIsEnumerable = function propertyIsEnumerable(key) {
1544 return onlySymbols(uid) ? (
1545 hOP.call(this, uid) &&
1546 this[internalSymbol]['@@' + uid]
1547 ) : pIE.call(this, key);
1549 var setAndGetSymbol = function (uid) {
1554 set: function (value) {
1555 setDescriptor(this, uid, {
1561 addInternalIfNeeded(this, uid, true);
1565 defineProperty(ObjectProto, uid, descriptor);
1567 ObjectProto[uid] = descriptor.value;
1569 return freeze(source[uid] = defineProperty(
1575 var Symbol = function Symbol() {
1576 var description = arguments[0];
1577 if (this instanceof Symbol) {
1578 throw new TypeError('Symbol is not a constructor');
1580 return setAndGetSymbol(
1581 prefix.concat(description || '', random, ++id)
1584 var source = create(null);
1585 var sourceConstructor = {value: Symbol};
1586 var sourceMap = function (uid) {
1589 var $defineProperty = function defineProp(o, key, descriptor) {
1591 if (onlySymbols(uid)) {
1592 setDescriptor(o, uid, descriptor.enumerable ?
1593 copyAsNonEnumerable(descriptor) : descriptor);
1594 addInternalIfNeeded(o, uid, !!descriptor.enumerable);
1596 defineProperty(o, key, descriptor);
1601 var onlyInternalSymbols = function (obj) {
1602 return function (name) {
1603 return hOP.call(obj, internalSymbol) && hOP.call(obj[internalSymbol], '@@' + name);
1606 var $getOwnPropertySymbols = function getOwnPropertySymbols(o) {
1607 return gOPN(o).filter(o === ObjectProto ? onlyInternalSymbols(o) : onlySymbols).map(sourceMap);
1611 descriptor.value = $defineProperty;
1612 defineProperty(Object, DP, descriptor);
1614 descriptor.value = $getOwnPropertySymbols;
1615 defineProperty(Object, GOPS, descriptor);
1617 descriptor.value = function getOwnPropertyNames(o) {
1618 return gOPN(o).filter(onlyNonSymbols);
1620 defineProperty(Object, GOPN, descriptor);
1622 descriptor.value = function defineProperties(o, descriptors) {
1623 var symbols = $getOwnPropertySymbols(descriptors);
1624 if (symbols.length) {
1625 keys(descriptors).concat(symbols).forEach(function (uid) {
1626 if (propertyIsEnumerable.call(descriptors, uid)) {
1627 $defineProperty(o, uid, descriptors[uid]);
1631 $defineProperties(o, descriptors);
1635 defineProperty(Object, DPies, descriptor);
1637 descriptor.value = propertyIsEnumerable;
1638 defineProperty(ObjectProto, PIE, descriptor);
1640 descriptor.value = Symbol;
1641 defineProperty(global, 'Symbol', descriptor);
1643 // defining `Symbol.for(key)`
1644 descriptor.value = function (key) {
1645 var uid = prefix.concat(prefix, key, random);
1646 return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid);
1648 defineProperty(Symbol, 'for', descriptor);
1650 // defining `Symbol.keyFor(symbol)`
1651 descriptor.value = function (symbol) {
1652 if (onlyNonSymbols(symbol))
1653 throw new TypeError(symbol + ' is not a symbol');
1654 return hOP.call(source, symbol) ?
1655 symbol.slice(prefixLength * 2, -random.length) :
1659 defineProperty(Symbol, 'keyFor', descriptor);
1661 descriptor.value = function getOwnPropertyDescriptor(o, key) {
1662 var descriptor = gOPD(o, key);
1663 if (descriptor && onlySymbols(key)) {
1664 descriptor.enumerable = propertyIsEnumerable.call(o, key);
1668 defineProperty(Object, GOPD, descriptor);
1670 descriptor.value = function (proto, descriptors) {
1671 return arguments.length === 1 || typeof descriptors === "undefined" ?
1673 createWithSymbols(proto, descriptors);
1675 defineProperty(Object, 'create', descriptor);
1677 descriptor.value = function () {
1678 var str = toString.call(this);
1679 return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
1681 defineProperty(ObjectProto, 'toString', descriptor);
1684 setDescriptor = function (o, key, descriptor) {
1685 var protoDescriptor = gOPD(ObjectProto, key);
1686 delete ObjectProto[key];
1687 defineProperty(o, key, descriptor);
1688 if (o !== ObjectProto) {
1689 defineProperty(ObjectProto, key, protoDescriptor);
1693 }(Object, 'getOwnPropertySymbols', this));
1697 if (!('Symbol' in this && 'iterator' in this.Symbol)) {
1701 Object.defineProperty(Symbol, 'iterator', { value: Symbol('iterator') });
1706 // _ESAbstract.GetIterator
1707 /* global GetMethod, Symbol, Call, Type, GetV */
1708 // 7.4.1. GetIterator ( obj [ , method ] )
1709 // The abstract operation GetIterator with argument obj and optional argument method performs the following steps:
1710 function GetIterator(obj /*, method */) { // eslint-disable-line no-unused-vars
1711 // 1. If method is not present, then
1712 // a. Set method to ? GetMethod(obj, @@iterator).
1713 var method = arguments.length > 1 ? arguments[1] : GetMethod(obj, Symbol.iterator);
1714 // 2. Let iterator be ? Call(method, obj).
1715 var iterator = Call(method, obj);
1716 // 3. If Type(iterator) is not Object, throw a TypeError exception.
1717 if (Type(iterator) !== 'object') {
1718 throw new TypeError('bad iterator');
1720 // 4. Let nextMethod be ? GetV(iterator, "next").
1721 var nextMethod = GetV(iterator, "next");
1722 // 5. Let iteratorRecord be Record {[[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false}.
1723 var iteratorRecord = Object.create(null);
1724 iteratorRecord['[[Iterator]]'] = iterator;
1725 iteratorRecord['[[NextMethod]]'] = nextMethod;
1726 iteratorRecord['[[Done]]'] = false;
1727 // 6. Return iteratorRecord.
1728 return iteratorRecord;
1731 // _ESAbstract.IteratorClose
1732 /* global GetMethod, Type, Call */
1733 // 7.4.6. IteratorClose ( iteratorRecord, completion )
1734 function IteratorClose(iteratorRecord, completion) { // eslint-disable-line no-unused-vars
1735 // 1. Assert: Type(iteratorRecord.[[Iterator]]) is Object.
1736 if (Type(iteratorRecord['[[Iterator]]']) !== 'object') {
1737 throw new Error(Object.prototype.toString.call(iteratorRecord['[[Iterator]]']) + 'is not an Object.');
1739 // 2. Assert: completion is a Completion Record.
1740 // Polyfill.io - Ignoring this step as there is no way to check if something is a Completion Record in userland JavaScript.
1742 // 3. Let iterator be iteratorRecord.[[Iterator]].
1743 var iterator = iteratorRecord['[[Iterator]]'];
1744 // 4. Let return be ? GetMethod(iterator, "return").
1745 // Polyfill.io - We name it returnMethod because return is a keyword and can not be used as an identifier (E.G. variable name, function name etc).
1746 var returnMethod = GetMethod(iterator, "return");
1747 // 5. If return is undefined, return Completion(completion).
1748 if (returnMethod === undefined) {
1751 // 6. Let innerResult be Call(return, iterator, « »).
1753 var innerResult = Call(returnMethod, iterator);
1755 var innerException = error;
1757 // 7. If completion.[[Type]] is throw, return Completion(completion).
1761 // 8. If innerResult.[[Type]] is throw, return Completion(innerResult).
1762 if (innerException) {
1763 throw innerException;
1765 // 9. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
1766 if (Type(innerResult) !== 'object') {
1767 throw new TypeError("Iterator's return method returned a non-object.");
1769 // 10. Return Completion(completion).
1773 // _ESAbstract.IteratorNext
1774 /* global Call, Type */
1775 // 7.4.2. IteratorNext ( iteratorRecord [ , value ] )
1776 function IteratorNext(iteratorRecord /* [, value] */) { // eslint-disable-line no-unused-vars
1777 // 1. If value is not present, then
1778 if (arguments.length < 2) {
1779 // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « »).
1780 var result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']);
1783 // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « value »).
1784 result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]);
1786 // 3. If Type(result) is not Object, throw a TypeError exception.
1787 if (Type(result) !== 'object') {
1788 throw new TypeError('bad iterator');
1790 // 4. Return result.
1794 // _ESAbstract.IteratorComplete
1795 /* global Type, ToBoolean, Get */
1796 // 7.4.3 IteratorComplete ( iterResult )
1797 function IteratorComplete(iterResult) { // eslint-disable-line no-unused-vars
1798 // 1. Assert: Type(iterResult) is Object.
1799 if (Type(iterResult) !== 'object') {
1800 throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
1802 // 2. Return ToBoolean(? Get(iterResult, "done")).
1803 return ToBoolean(Get(iterResult, "done"));
1806 // _ESAbstract.IteratorStep
1807 /* global IteratorNext, IteratorComplete */
1808 // 7.4.5. IteratorStep ( iteratorRecord )
1809 function IteratorStep(iteratorRecord) { // eslint-disable-line no-unused-vars
1810 // 1. Let result be ? IteratorNext(iteratorRecord).
1811 var result = IteratorNext(iteratorRecord);
1812 // 2. Let done be ? IteratorComplete(result).
1813 var done = IteratorComplete(result);
1814 // 3. If done is true, return false.
1815 if (done === true) {
1818 // 4. Return result.
1822 // _ESAbstract.IteratorValue
1823 /* global Type, Get */
1824 // 7.4.4 IteratorValue ( iterResult )
1825 function IteratorValue(iterResult) { // eslint-disable-line no-unused-vars
1826 // Assert: Type(iterResult) is Object.
1827 if (Type(iterResult) !== 'object') {
1828 throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
1830 // Return ? Get(iterResult, "value").
1831 return Get(iterResult, "value");
1834 // _ESAbstract.CreateIterResultObject
1835 /* global Type, CreateDataProperty */
1836 // 7.4.7. CreateIterResultObject ( value, done )
1837 function CreateIterResultObject(value, done) { // eslint-disable-line no-unused-vars
1838 // 1. Assert: Type(done) is Boolean.
1839 if (Type(done) !== 'boolean') {
1842 // 2. Let obj be ObjectCreate(%ObjectPrototype%).
1844 // 3. Perform CreateDataProperty(obj, "value", value).
1845 CreateDataProperty(obj, "value", value);
1846 // 4. Perform CreateDataProperty(obj, "done", done).
1847 CreateDataProperty(obj, "done", done);
1852 // _ESAbstract.SameValueNonNumber
1853 // 7.2.12. SameValueNonNumber ( x, y )
1854 function SameValueNonNumber(x, y) { // eslint-disable-line no-unused-vars
1855 // 1. Assert: Type(x) is not Number.
1856 // 2. Assert: Type(x) is the same as Type(y).
1857 // 3. If Type(x) is Undefined, return true.
1858 // 4. If Type(x) is Null, return true.
1859 // 5. If Type(x) is String, then
1860 // a. If x and y are exactly the same sequence of code units (same length and same code units at corresponding indices), return true; otherwise, return false.
1861 // 6. If Type(x) is Boolean, then
1862 // a. If x and y are both true or both false, return true; otherwise, return false.
1863 // 7. If Type(x) is Symbol, then
1864 // a. If x and y are both the same Symbol value, return true; otherwise, return false.
1865 // 8. If x and y are the same Object value, return true. Otherwise, return false.
1867 // Polyfill.io - We can skip all above steps because the === operator does it all for us.
1871 // _ESAbstract.SameValueZero
1872 /* global Type, SameValueNonNumber */
1873 // 7.2.11. SameValueZero ( x, y )
1874 function SameValueZero (x, y) { // eslint-disable-line no-unused-vars
1875 // 1. If Type(x) is different from Type(y), return false.
1876 if (Type(x) !== Type(y)) {
1879 // 2. If Type(x) is Number, then
1880 if (Type(x) === 'number') {
1881 // a. If x is NaN and y is NaN, return true.
1882 if (isNaN(x) && isNaN(y)) {
1885 // b. If x is +0 and y is -0, return true.
1886 if (1/x === Infinity && 1/y === -Infinity) {
1889 // c. If x is -0 and y is +0, return true.
1890 if (1/x === -Infinity && 1/y === Infinity) {
1893 // d. If x is the same Number value as y, return true.
1900 // 3. Return SameValueNonNumber(x, y).
1901 return SameValueNonNumber(x, y);
1903 if (!('isArray' in Array)) {
1906 /* global CreateMethodProperty, IsArray */
1907 // 22.1.2.2. Array.isArray ( arg )
1908 CreateMethodProperty(Array, 'isArray', function isArray(arg) {
1909 // 1. Return ? IsArray(arg).
1910 return IsArray(arg);
1915 if (!('Symbol' in this && 'species' in this.Symbol)) {
1919 Object.defineProperty(Symbol, 'species', { value: Symbol('species') });
1923 if (!('Map' in this && (function() {
1925 var m = new Map([[1, 1], [2, 2]]);
1926 if (Map.length === 0) {
1928 if ('Symbol' in this && 'iterator' in Symbol && typeof m[Symbol.iterator] === 'function') {
1940 /* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
1941 (function (global) {
1942 var supportsGetters = (function () {
1945 Object.defineProperty(a, 't', {
1959 // Deleted map items mess with iterator pointers, so rather than removing them mark them as deleted. Can't use undefined or null since those both valid keys so use a private symbol.
1960 var undefMarker = Symbol('undef');
1961 // 23.1.1.1 Map ( [ iterable ] )
1962 var Map = function Map(/* iterable */) {
1963 // 1. If NewTarget is undefined, throw a TypeError exception.
1964 if (!(this instanceof Map)) {
1965 throw new TypeError('Constructor Map requires "new"');
1967 // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%MapPrototype%", « [[MapData]] »).
1968 var map = OrdinaryCreateFromConstructor(this, Map.prototype, {
1975 // 3. Set map.[[MapData]] to a new empty List.
1976 // Polyfill.io - This step was done as part of step two.
1978 // Some old engines do not support ES5 getters/setters. Since Map only requires these for the size property, we can fall back to setting the size property statically each time the size of the map changes.
1979 if (!supportsGetters) {
1980 Object.defineProperty(map, 'size', {
1988 // 4. If iterable is not present, let iterable be undefined.
1989 var iterable = arguments.length > 0 ? arguments[0] : undefined;
1991 // 5. If iterable is either undefined or null, return map.
1992 if (iterable === null || iterable === undefined) {
1996 // 6. Let adder be ? Get(map, "set").
1997 var adder = map.set;
1999 // 7. If IsCallable(adder) is false, throw a TypeError exception.
2000 if (!IsCallable(adder)) {
2001 throw new TypeError("Map.prototype.set is not a function");
2004 // 8. Let iteratorRecord be ? GetIterator(iterable).
2006 var iteratorRecord = GetIterator(iterable);
2009 // a. Let next be ? IteratorStep(iteratorRecord).
2010 var next = IteratorStep(iteratorRecord);
2011 // b. If next is false, return map.
2012 if (next === false) {
2015 // c. Let nextItem be ? IteratorValue(next).
2016 var nextItem = IteratorValue(next);
2017 // d. If Type(nextItem) is not Object, then
2018 if (Type(nextItem) !== 'object') {
2019 // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
2021 throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
2023 // ii. Return ? IteratorClose(iteratorRecord, error).
2024 return IteratorClose(iteratorRecord, error);
2028 // Polyfill.io - The try catch accounts for steps: f, h, and j.
2030 // e. Let k be Get(nextItem, "0").
2031 var k = nextItem[0];
2032 // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
2033 // g. Let v be Get(nextItem, "1").
2034 var v = nextItem[1];
2035 // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
2036 // i. Let status be Call(adder, map, « k.[[Value]], v.[[Value]] »).
2037 adder.call(map, k, v);
2039 // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
2040 return IteratorClose(iteratorRecord, e);
2044 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
2045 if (Array.isArray(iterable) ||
2046 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
2047 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
2048 (!!iterable.callee)) {
2050 var length = iterable.length;
2051 for (index = 0; index < length; index++) {
2052 adder.call(map, iterable[index][0], iterable[index][1]);
2059 // 23.1.2.1. Map.prototype
2060 // The initial value of Map.prototype is the intrinsic object %MapPrototype%.
2061 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
2062 Object.defineProperty(Map, 'prototype', {
2063 configurable: false,
2069 // 23.1.2.2 get Map [ @@species ]
2070 if (supportsGetters) {
2071 Object.defineProperty(Map, Symbol.species, {
2075 // 1. Return the this value.
2081 CreateMethodProperty(Map, Symbol.species, Map);
2084 // 23.1.3.1 Map.prototype.clear ( )
2085 CreateMethodProperty(Map.prototype, 'clear', function clear() {
2086 // 1. Let M be the this value.
2088 // 2. If Type(M) is not Object, throw a TypeError exception.
2089 if (Type(M) !== 'object') {
2090 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
2092 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2093 if (M._es6Map !== true) {
2094 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
2096 // 4. Let entries be the List that is M.[[MapData]].
2097 var entries = M._keys;
2098 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
2099 for (var i = 0; i < entries.length; i++) {
2100 // 5.a. Set p.[[Key]] to empty.
2101 M._keys[i] = undefMarker;
2102 // 5.b. Set p.[[Value]] to empty.
2103 M._values[i] = undefMarker;
2106 if (!supportsGetters) {
2107 this.size = this._size;
2109 // 6. Return undefined.
2114 // 23.1.3.2. Map.prototype.constructor
2115 CreateMethodProperty(Map.prototype, 'constructor', Map);
2117 // 23.1.3.3. Map.prototype.delete ( key )
2118 CreateMethodProperty(Map.prototype, 'delete', function (key) {
2119 // 1. Let M be the this value.
2121 // 2. If Type(M) is not Object, throw a TypeError exception.
2122 if (Type(M) !== 'object') {
2123 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
2125 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2126 if (M._es6Map !== true) {
2127 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
2129 // 4. Let entries be the List that is M.[[MapData]].
2130 var entries = M._keys;
2131 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
2132 for (var i = 0; i < entries.length; i++) {
2133 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
2134 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
2135 // i. Set p.[[Key]] to empty.
2136 this._keys[i] = undefMarker;
2137 // ii. Set p.[[Value]] to empty.
2138 this._values[i] = undefMarker;
2139 this._size = --this._size;
2140 if (!supportsGetters) {
2141 this.size = this._size;
2143 // iii. Return true.
2152 // 23.1.3.4. Map.prototype.entries ( )
2153 CreateMethodProperty(Map.prototype, 'entries', function entries () {
2154 // 1. Let M be the this value.
2156 // 2. Return ? CreateMapIterator(M, "key+value").
2157 return CreateMapIterator(M, 'key+value');
2161 // 23.1.3.5. Map.prototype.forEach ( callbackfn [ , thisArg ] )
2162 CreateMethodProperty(Map.prototype, 'forEach', function (callbackFn) {
2163 // 1. Let M be the this value.
2165 // 2. If Type(M) is not Object, throw a TypeError exception.
2166 if (Type(M) !== 'object') {
2167 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
2169 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2170 if (M._es6Map !== true) {
2171 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
2173 // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
2174 if (!IsCallable(callbackFn)) {
2175 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
2177 // 5. If thisArg is present, let T be thisArg; else let T be undefined.
2179 var T = arguments[1];
2181 // 6. Let entries be the List that is M.[[MapData]].
2182 var entries = M._keys;
2183 // 7. For each Record {[[Key]], [[Value]]} e that is an element of entries, in original key insertion order, do
2184 for (var i = 0; i < entries.length; i++) {
2185 // a. If e.[[Key]] is not empty, then
2186 if (M._keys[i] !== undefMarker && M._values[i] !== undefMarker ) {
2187 // i. Perform ? Call(callbackfn, T, « e.[[Value]], e.[[Key]], M »).
2188 callbackFn.call(T, M._values[i], M._keys[i], M);
2191 // 8. Return undefined.
2196 // 23.1.3.6. Map.prototype.get ( key )
2197 CreateMethodProperty(Map.prototype, 'get', function get(key) {
2198 // 1. Let M be the this value.
2200 // 2. If Type(M) is not Object, throw a TypeError exception.
2201 if (Type(M) !== 'object') {
2202 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
2204 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2205 if (M._es6Map !== true) {
2206 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
2208 // 4. Let entries be the List that is M.[[MapData]].
2209 var entries = M._keys;
2210 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
2211 for (var i = 0; i < entries.length; i++) {
2212 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return p.[[Value]].
2213 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
2214 return M._values[i];
2217 // 6. Return undefined.
2221 // 23.1.3.7. Map.prototype.has ( key )
2222 CreateMethodProperty(Map.prototype, 'has', function has (key) {
2223 // 1. Let M be the this value.
2225 // 2. If Type(M) is not Object, throw a TypeError exception.
2226 if (typeof M !== 'object') {
2227 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
2229 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2230 if (M._es6Map !== true) {
2231 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
2233 // 4. Let entries be the List that is M.[[MapData]].
2234 var entries = M._keys;
2235 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
2236 for (var i = 0; i < entries.length; i++) {
2237 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return true.
2238 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
2246 // 23.1.3.8. Map.prototype.keys ( )
2247 CreateMethodProperty(Map.prototype, 'keys', function keys () {
2248 // 1. Let M be the this value.
2250 // 2. Return ? CreateMapIterator(M, "key").
2251 return CreateMapIterator(M, "key");
2254 // 23.1.3.9. Map.prototype.set ( key, value )
2255 CreateMethodProperty(Map.prototype, 'set', function set(key, value) {
2256 // 1. Let M be the this value.
2258 // 2. If Type(M) is not Object, throw a TypeError exception.
2259 if (Type(M) !== 'object') {
2260 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
2262 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2263 if (M._es6Map !== true) {
2264 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
2266 // 4. Let entries be the List that is M.[[MapData]].
2267 var entries = M._keys;
2268 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
2269 for (var i = 0; i < entries.length; i++) {
2270 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
2271 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
2272 // i. Set p.[[Value]] to value.
2273 M._values[i] = value;
2278 // 6. If key is -0, let key be +0.
2279 if (1/key === -Infinity) {
2282 // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
2285 p['[[Value]]'] = value;
2286 // 8. Append p as the last element of entries.
2287 M._keys.push(p['[[Key]]']);
2288 M._values.push(p['[[Value]]']);
2290 if (!supportsGetters) {
2297 // 23.1.3.10. get Map.prototype.size
2298 if (supportsGetters) {
2299 Object.defineProperty(Map.prototype, 'size', {
2303 // 1. Let M be the this value.
2305 // 2. If Type(M) is not Object, throw a TypeError exception.
2306 if (Type(M) !== 'object') {
2307 throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
2309 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2310 if (M._es6Map !== true) {
2311 throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
2313 // 4. Let entries be the List that is M.[[MapData]].
2314 var entries = M._keys;
2315 // 5. Let count be 0.
2317 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
2318 for (var i = 0; i < entries.length; i++) {
2319 // a. If p.[[Key]] is not empty, set count to count+1.
2320 if (M._keys[i] !== undefMarker) {
2331 // 23.1.3.11. Map.prototype.values ( )
2332 CreateMethodProperty(Map.prototype, 'values', function values () {
2333 // 1. Let M be the this value.
2335 // 2. Return ? CreateMapIterator(M, "value").
2336 return CreateMapIterator(M, 'value');
2340 // 23.1.3.12. Map.prototype [ @@iterator ] ( )
2341 // The initial value of the @@iterator property is the same function object as the initial value of the entries property.
2342 CreateMethodProperty(Map.prototype, Symbol.iterator, Map.prototype.entries);
2344 // 23.1.3.13. Map.prototype [ @@toStringTag ]
2345 // The initial value of the @@toStringTag property is the String value "Map".
2346 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
2348 // Polyfill.io - Safari 8 implements Map.name but as a non-configurable property, which means it would throw an error if we try and configure it here.
2349 if (!('name' in Map)) {
2351 Object.defineProperty(Map, 'name', {
2359 // 23.1.5.1. CreateMapIterator ( map, kind )
2360 function CreateMapIterator(map, kind) {
2361 // 1. If Type(map) is not Object, throw a TypeError exception.
2362 if (Type(map) !== 'object') {
2363 throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
2365 // 2. If map does not have a [[MapData]] internal slot, throw a TypeError exception.
2366 if (map._es6Map !== true) {
2367 throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
2369 // 3. Let iterator be ObjectCreate(%MapIteratorPrototype%, « [[Map]], [[MapNextIndex]], [[MapIterationKind]] »).
2370 var iterator = Object.create(MapIteratorPrototype);
2371 // 4. Set iterator.[[Map]] to map.
2372 Object.defineProperty(iterator, '[[Map]]', {
2378 // 5. Set iterator.[[MapNextIndex]] to 0.
2379 Object.defineProperty(iterator, '[[MapNextIndex]]', {
2385 // 6. Set iterator.[[MapIterationKind]] to kind.
2386 Object.defineProperty(iterator, '[[MapIterationKind]]', {
2392 // 7. Return iterator.
2396 // 23.1.5.2. The %MapIteratorPrototype% Object
2397 var MapIteratorPrototype = {};
2398 // Polyfill.io - We use this as a quick way to check if an object is a Map Iterator instance.
2399 Object.defineProperty(MapIteratorPrototype, 'isMapIterator', {
2400 configurable: false,
2406 // 23.1.5.2.1. %MapIteratorPrototype%.next ( )
2407 CreateMethodProperty(MapIteratorPrototype, 'next', function next() {
2408 // 1. Let O be the this value.
2410 // 2. If Type(O) is not Object, throw a TypeError exception.
2411 if (Type(O) !== 'object') {
2412 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
2414 // 3. If O does not have all of the internal slots of a Map Iterator Instance (23.1.5.3), throw a TypeError exception.
2415 if (!O.isMapIterator) {
2416 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
2418 // 4. Let m be O.[[Map]].
2419 var m = O['[[Map]]'];
2420 // 5. Let index be O.[[MapNextIndex]].
2421 var index = O['[[MapNextIndex]]'];
2422 // 6. Let itemKind be O.[[MapIterationKind]].
2423 var itemKind = O['[[MapIterationKind]]'];
2424 // 7. If m is undefined, return CreateIterResultObject(undefined, true).
2425 if (m === undefined) {
2426 return CreateIterResultObject(undefined, true);
2428 // 8. Assert: m has a [[MapData]] internal slot.
2430 throw new Error(Object.prototype.toString.call(m) + ' has a [[MapData]] internal slot.');
2432 // 9. Let entries be the List that is m.[[MapData]].
2433 var entries = m._keys;
2434 // 10. Let numEntries be the number of elements of entries.
2435 var numEntries = entries.length;
2436 // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
2437 // 12. Repeat, while index is less than numEntries,
2438 while (index < numEntries) {
2439 // a. Let e be the Record {[[Key]], [[Value]]} that is the value of entries[index].
2440 var e = Object.create(null);
2441 e['[[Key]]'] = m._keys[index];
2442 e['[[Value]]'] = m._values[index];
2443 // b. Set index to index+1.
2445 // c. Set O.[[MapNextIndex]] to index.
2446 O['[[MapNextIndex]]'] = index;
2447 // d. If e.[[Key]] is not empty, then
2448 if (e['[[Key]]'] !== undefMarker) {
2449 // i. If itemKind is "key", let result be e.[[Key]].
2450 if (itemKind === 'key') {
2451 var result = e['[[Key]]'];
2452 // ii. Else if itemKind is "value", let result be e.[[Value]].
2453 } else if (itemKind === 'value') {
2454 result = e['[[Value]]'];
2457 // 1. Assert: itemKind is "key+value".
2458 if (itemKind !== 'key+value') {
2461 // 2. Let result be CreateArrayFromList(« e.[[Key]], e.[[Value]] »).
2467 // iv. Return CreateIterResultObject(result, false).
2468 return CreateIterResultObject(result, false);
2471 // 13. Set O.[[Map]] to undefined.
2472 O['[[Map]]'] = undefined;
2473 // 14. Return CreateIterResultObject(undefined, true).
2474 return CreateIterResultObject(undefined, true);
2478 // 23.1.5.2.2 %MapIteratorPrototype% [ @@toStringTag ]
2479 // The initial value of the @@toStringTag property is the String value "Map Iterator".
2480 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
2482 CreateMethodProperty(MapIteratorPrototype, Symbol.iterator, function iterator() {
2487 // Export the object
2489 CreateMethodProperty(global, 'Map', Map);
2491 // IE8 throws an error here if we set enumerable to false.
2492 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
2493 global['Map'] = Map;
2499 if (!('Set' in this && (function() {
2501 var s = new Set([1, 2]);
2502 if (Set.length === 0) {
2504 if ('Symbol' in this && 'iterator' in Symbol && typeof s[Symbol.iterator] === 'function') {
2516 /* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Symbol */
2517 (function (global) {
2518 var supportsGetters = (function () {
2521 Object.defineProperty(a, 't', {
2535 // Deleted set items mess with iterator pointers, so rather than removing them mark them as deleted. Can't use undefined or null since those both valid keys so use a private symbol.
2536 var undefMarker = Symbol('undef');
2537 // 23.2.1.1. Set ( [ iterable ] )
2538 var Set = function Set(/* iterable */) {
2539 // 1. If NewTarget is undefined, throw a TypeError exception.
2540 if (!(this instanceof Set)) {
2541 throw new TypeError('Constructor Set requires "new"');
2543 // 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%SetPrototype%", « [[SetData]] »).
2544 var set = OrdinaryCreateFromConstructor(this, Set.prototype, {
2550 // 3. Set set.[[SetData]] to a new empty List.
2551 // Polyfill.io - This step was done as part of step two.
2553 // Some old engines do not support ES5 getters/setters. Since Set only requires these for the size property, we can fall back to setting the size property statically each time the size of the set changes.
2554 if (!supportsGetters) {
2555 Object.defineProperty(set, 'size', {
2563 // 4. If iterable is not present, let iterable be undefined.
2564 var iterable = arguments.length > 0 ? arguments[0] : undefined;
2566 // 5. If iterable is either undefined or null, return set.
2567 if (iterable === null || iterable === undefined) {
2571 // 6. Let adder be ? Get(set, "add").
2572 var adder = set.add;
2573 // 7. If IsCallable(adder) is false, throw a TypeError exception.
2574 if (!IsCallable(adder)) {
2575 throw new TypeError("Set.prototype.add is not a function");
2579 // 8. Let iteratorRecord be ? GetIterator(iterable).
2580 var iteratorRecord = GetIterator(iterable);
2583 // a. Let next be ? IteratorStep(iteratorRecord).
2584 var next = IteratorStep(iteratorRecord);
2585 // b. If next is false, return set.
2586 if (next === false) {
2589 // c. Let nextValue be ? IteratorValue(next).
2590 var nextValue = IteratorValue(next);
2591 // d. Let status be Call(adder, set, « nextValue.[[Value]] »).
2593 adder.call(set, nextValue);
2595 // e. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
2596 return IteratorClose(iteratorRecord, e);
2600 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
2601 if (Array.isArray(iterable) ||
2602 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
2603 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
2604 (!!iterable.callee)) {
2606 var length = iterable.length;
2607 for (index = 0; index < length; index++) {
2608 adder.call(set, iterable[index]);
2615 // 23.2.2.1. Set.prototype
2616 // The initial value of Set.prototype is the intrinsic %SetPrototype% object.
2617 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
2618 Object.defineProperty(Set, 'prototype', {
2619 configurable: false,
2625 // 23.2.2.2 get Set [ @@species ]
2626 if (supportsGetters) {
2627 Object.defineProperty(Set, Symbol.species, {
2631 // 1. Return the this value.
2637 CreateMethodProperty(Set, Symbol.species, Set);
2640 // 23.2.3.1. Set.prototype.add ( value )
2641 CreateMethodProperty(Set.prototype, 'add', function add(value) {
2642 // 1. Let S be the this value.
2644 // 2. If Type(S) is not Object, throw a TypeError exception.
2645 if (typeof S !== 'object') {
2646 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
2648 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
2649 if (S._es6Set !== true) {
2650 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
2652 // 4. Let entries be the List that is S.[[SetData]].
2653 var entries = S._values;
2654 // 5. For each e that is an element of entries, do
2655 for (var i = 0; i < entries.length; i++) {
2657 // a. If e is not empty and SameValueZero(e, value) is true, then
2658 if (e !== undefMarker && SameValueZero(e, value)) {
2663 // 6. If value is -0, let value be +0.
2664 if (1/value === -Infinity) {
2667 // 7. Append value as the last element of entries.
2668 S._values.push(value);
2670 this._size = ++this._size;
2671 if (!supportsGetters) {
2672 this.size = this._size;
2678 // 23.2.3.2. Set.prototype.clear ( )
2679 CreateMethodProperty(Set.prototype, 'clear', function clear() {
2680 // 1. Let S be the this value.
2682 // 2. If Type(S) is not Object, throw a TypeError exception.
2683 if (typeof S !== 'object') {
2684 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
2686 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
2687 if (S._es6Set !== true) {
2688 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
2690 // 4. Let entries be the List that is S.[[SetData]].
2691 var entries = S._values;
2692 // 5. For each e that is an element of entries, do
2693 for (var i = 0; i < entries.length; i++) {
2694 // a. Replace the element of entries whose value is e with an element whose value is empty.
2695 entries[i] = undefMarker;
2698 if (!supportsGetters) {
2699 this.size = this._size;
2701 // 6. Return undefined.
2705 // 23.2.3.3. Set.prototype.constructor
2706 CreateMethodProperty(Set.prototype, 'constructor', Set);
2708 // 23.2.3.4. Set.prototype.delete ( value )
2709 CreateMethodProperty(Set.prototype, 'delete', function (value) {
2710 // 1. Let S be the this value.
2712 // 2. If Type(S) is not Object, throw a TypeError exception.
2713 if (typeof S !== 'object') {
2714 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
2716 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
2717 if (S._es6Set !== true) {
2718 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
2720 // 4. Let entries be the List that is S.[[SetData]].
2721 var entries = S._values;
2722 // 5. For each e that is an element of entries, do
2723 for (var i = 0; i < entries.length; i++) {
2725 // a. If e is not empty and SameValueZero(e, value) is true, then
2726 if (e !== undefMarker && SameValueZero(e, value)) {
2727 // i. Replace the element of entries whose value is e with an element whose value is empty.
2728 entries[i] = undefMarker;
2730 this._size = --this._size;
2731 if (!supportsGetters) {
2732 this.size = this._size;
2743 // 23.2.3.5. Set.prototype.entries ( )
2744 CreateMethodProperty(Set.prototype, 'entries', function entries() {
2745 // 1. Let S be the this value.
2747 // 2. Return ? CreateSetIterator(S, "key+value").
2748 return CreateSetIterator(S, 'key+value');
2752 // 23.2.3.6. Set.prototype.forEach ( callbackfn [ , thisArg ] )
2753 CreateMethodProperty(Set.prototype, 'forEach', function forEach(callbackFn /*[ , thisArg ]*/) {
2754 // 1. Let S be the this value.
2756 // 2. If Type(S) is not Object, throw a TypeError exception.
2757 if (typeof S !== 'object') {
2758 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
2760 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
2761 if (S._es6Set !== true) {
2762 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
2764 // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
2765 if (!IsCallable(callbackFn)) {
2766 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
2768 // 5. If thisArg is present, let T be thisArg; else let T be undefined.
2770 var T = arguments[1];
2772 // 6. Let entries be the List that is S.[[SetData]].
2773 var entries = S._values;
2774 // 7. For each e that is an element of entries, in original insertion order, do
2775 for (var i = 0; i < entries.length; i++) {
2777 // a. If e is not empty, then
2778 if (e !== undefMarker) {
2779 // i. Perform ? Call(callbackfn, T, « e, e, S »).
2780 callbackFn.call(T, e, e, S);
2783 // 8. Return undefined.
2788 // 23.2.3.7. Set.prototype.has ( value )
2789 CreateMethodProperty(Set.prototype, 'has', function has(value) {
2790 // 1. Let S be the this value.
2792 // 2. If Type(S) is not Object, throw a TypeError exception.
2793 if (typeof S !== 'object') {
2794 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
2796 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
2797 if (S._es6Set !== true) {
2798 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
2800 // 4. Let entries be the List that is S.[[SetData]].
2801 var entries = S._values;
2802 // 5. For each e that is an element of entries, do
2803 for (var i = 0; i < entries.length; i++) {
2805 // a. If e is not empty and SameValueZero(e, value) is true, return true.
2806 if (e !== undefMarker && SameValueZero(e, value)) {
2815 // Polyfill.io - We need to define Set.prototype.values before Set.prototype.keys because keys is a reference to values.
2816 // 23.2.3.10. Set.prototype.values()
2817 var values = function values() {
2818 // 1. Let S be the this value.
2820 // 2. Return ? CreateSetIterator(S, "value").
2821 return CreateSetIterator(S, "value");
2823 CreateMethodProperty(Set.prototype, 'values', values);
2825 // 23.2.3.8 Set.prototype.keys ( )
2826 // The initial value of the keys property is the same function object as the initial value of the values property.
2827 CreateMethodProperty(Set.prototype, 'keys', values);
2829 // 23.2.3.9. get Set.prototype.size
2830 if (supportsGetters) {
2831 Object.defineProperty(Set.prototype, 'size', {
2835 // 1. Let S be the this value.
2837 // 2. If Type(S) is not Object, throw a TypeError exception.
2838 if (typeof S !== 'object') {
2839 throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
2841 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
2842 if (S._es6Set !== true) {
2843 throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
2845 // 4. Let entries be the List that is S.[[SetData]].
2846 var entries = S._values;
2847 // 5. Let count be 0.
2849 // 6. For each e that is an element of entries, do
2850 for (var i = 0; i < entries.length; i++) {
2852 // a. If e is not empty, set count to count+1.
2853 if (e !== undefMarker) {
2864 // 23.2.3.11. Set.prototype [ @@iterator ] ( )
2865 // The initial value of the @@iterator property is the same function object as the initial value of the values property.
2866 CreateMethodProperty(Set.prototype, Symbol.iterator, values);
2868 // 23.2.3.12. Set.prototype [ @@toStringTag ]
2869 // The initial value of the @@toStringTag property is the String value "Set".
2870 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
2872 // Polyfill.io - Safari 8 implements Set.name but as a non-configurable property, which means it would throw an error if we try and configure it here.
2873 if (!('name' in Set)) {
2875 Object.defineProperty(Set, 'name', {
2883 // 23.2.5.1. CreateSetIterator ( set, kind )
2884 function CreateSetIterator(set, kind) {
2885 // 1. If Type(set) is not Object, throw a TypeError exception.
2886 if (typeof set !== 'object') {
2887 throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
2889 // 2. If set does not have a [[SetData]] internal slot, throw a TypeError exception.
2890 if (set._es6Set !== true) {
2891 throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
2893 // 3. Let iterator be ObjectCreate(%SetIteratorPrototype%, « [[IteratedSet]], [[SetNextIndex]], [[SetIterationKind]] »).
2894 var iterator = Object.create(SetIteratorPrototype);
2895 // 4. Set iterator.[[IteratedSet]] to set.
2896 Object.defineProperty(iterator, '[[IteratedSet]]', {
2902 // 5. Set iterator.[[SetNextIndex]] to 0.
2903 Object.defineProperty(iterator, '[[SetNextIndex]]', {
2909 // 6. Set iterator.[[SetIterationKind]] to kind.
2910 Object.defineProperty(iterator, '[[SetIterationKind]]', {
2916 // 7. Return iterator.
2920 // 23.2.5.2. The %SetIteratorPrototype% Object
2921 var SetIteratorPrototype = {};
2922 //Polyfill.io - We add this property to help us identify what is a set iterator.
2923 Object.defineProperty(SetIteratorPrototype, 'isSetIterator', {
2924 configurable: false,
2930 // 23.2.5.2.1. %SetIteratorPrototype%.next ( )
2931 CreateMethodProperty(SetIteratorPrototype, 'next', function next() {
2932 // 1. Let O be the this value.
2934 // 2. If Type(O) is not Object, throw a TypeError exception.
2935 if (typeof O !== 'object') {
2936 throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
2938 // 3. If O does not have all of the internal slots of a Set Iterator Instance (23.2.5.3), throw a TypeError exception.
2939 if (!O.isSetIterator) {
2940 throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
2942 // 4. Let s be O.[[IteratedSet]].
2943 var s = O['[[IteratedSet]]'];
2944 // 5. Let index be O.[[SetNextIndex]].
2945 var index = O['[[SetNextIndex]]'];
2946 // 6. Let itemKind be O.[[SetIterationKind]].
2947 var itemKind = O['[[SetIterationKind]]'];
2948 // 7. If s is undefined, return CreateIterResultObject(undefined, true).
2949 if (s === undefined) {
2950 return CreateIterResultObject(undefined, true);
2952 // 8. Assert: s has a [[SetData]] internal slot.
2954 throw new Error(Object.prototype.toString.call(s) + ' does not have [[SetData]] internal slot.');
2956 // 9. Let entries be the List that is s.[[SetData]].
2957 var entries = s._values;
2958 // 10. Let numEntries be the number of elements of entries.
2959 var numEntries = entries.length;
2960 // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
2961 // 12. Repeat, while index is less than numEntries,
2962 while (index < numEntries) {
2963 // a. Let e be entries[index].
2964 var e = entries[index];
2965 // b. Set index to index+1.
2967 // c. Set O.[[SetNextIndex]] to index.
2968 O['[[SetNextIndex]]'] = index;
2969 // d. If e is not empty, then
2970 if (e !== undefMarker) {
2971 // i. If itemKind is "key+value", then
2972 if (itemKind === 'key+value') {
2973 // 1. Return CreateIterResultObject(CreateArrayFromList(« e, e »), false).
2974 return CreateIterResultObject([e, e], false);
2976 // ii. Return CreateIterResultObject(e, false).
2977 return CreateIterResultObject(e, false);
2980 // 13. Set O.[[IteratedSet]] to undefined.
2981 O['[[IteratedSet]]'] = undefined;
2982 // 14. Return CreateIterResultObject(undefined, true).
2983 return CreateIterResultObject(undefined, true);
2986 // 23.2.5.2.2. %SetIteratorPrototype% [ @@toStringTag ]
2987 // The initial value of the @@toStringTag property is the String value "Set Iterator".
2988 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
2990 CreateMethodProperty(SetIteratorPrototype, Symbol.iterator, function iterator() {
2995 // Export the object
2997 CreateMethodProperty(global, 'Set', Set);
2999 // IE8 throws an error here if we set enumerable to false.
3000 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
3001 global['Set'] = Set;
3008 if (!('from' in Array && (function () {
3010 Array.from({ length: -Infinity });
3020 IsCallable, GetMethod, Symbol, IsConstructor, Construct, ArrayCreate, GetIterator, IteratorClose,
3021 ToString, IteratorStep, IteratorValue, Call, CreateDataPropertyOrThrow, ToObject, ToLength, Get, CreateMethodProperty
3024 var toString = Object.prototype.toString;
3025 var stringMatch = String.prototype.match;
3026 // A cross-realm friendly way to detect if a value is a String object or literal.
3027 function isString(value) {
3028 if (typeof value === 'string') { return true; }
3029 if (typeof value !== 'object') { return false; }
3030 return toString.call(value) === '[object String]';
3033 // 22.1.2.1. Array.from ( items [ , mapfn [ , thisArg ] ] )
3034 CreateMethodProperty(Array, 'from', function from(items /* [ , mapfn [ , thisArg ] ] */) { // eslint-disable-line no-undef
3035 // 1. Let C be the this value.
3037 // 2. If mapfn is undefined, let mapping be false.
3038 var mapfn = arguments.length > 1 ? arguments[1] : undefined;
3039 if (mapfn === undefined) {
3040 var mapping = false;
3043 // a. If IsCallable(mapfn) is false, throw a TypeError exception.
3044 if (IsCallable(mapfn) === false) {
3045 throw new TypeError(Object.prototype.toString.call(mapfn) + ' is not a function.');
3047 // b. If thisArg is present, let T be thisArg; else let T be undefined.
3048 var thisArg = arguments.length > 2 ? arguments[2] : undefined;
3049 if (thisArg !== undefined) {
3054 // c. Let mapping be true.
3058 // 4. Let usingIterator be ? GetMethod(items, @@iterator).
3059 var usingIterator = GetMethod(items, Symbol.iterator);
3060 // 5. If usingIterator is not undefined, then
3061 if (usingIterator !== undefined) {
3062 // a. If IsConstructor(C) is true, then
3063 if (IsConstructor(C)) {
3064 // i. Let A be ? Construct(C).
3065 var A = Construct(C);
3068 // i. Let A be ! ArrayCreate(0).
3071 // c. Let iteratorRecord be ? GetIterator(items, usingIterator).
3072 var iteratorRecord = GetIterator(items, usingIterator);
3077 // i. If k ≥ 2^53-1, then
3078 if (k >= (Math.pow(2, 53) - 1)) {
3079 // 1. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
3080 var error = new TypeError('Iteration count can not be greater than or equal 9007199254740991.');
3081 // 2. Return ? IteratorClose(iteratorRecord, error).
3082 return IteratorClose(iteratorRecord, error);
3084 // ii. Let Pk be ! ToString(k).
3085 var Pk = ToString(k);
3086 // iii. Let next be ? IteratorStep(iteratorRecord).
3087 var next = IteratorStep(iteratorRecord);
3088 // iv. If next is false, then
3089 if (next === false) {
3090 // 1. Perform ? Set(A, "length", k, true).
3095 // v. Let nextValue be ? IteratorValue(next).
3096 var nextValue = IteratorValue(next);
3097 // vi. If mapping is true, then
3100 // Polyfill.io - The try catch accounts for step 2.
3101 // 1. Let mappedValue be Call(mapfn, T, « nextValue, k »).
3102 var mappedValue = Call(mapfn, T, [nextValue, k]);
3103 // 2. If mappedValue is an abrupt completion, return ? IteratorClose(iteratorRecord, mappedValue).
3104 // 3. Let mappedValue be mappedValue.[[Value]].
3106 return IteratorClose(iteratorRecord, e);
3109 // vii. Else, let mappedValue be nextValue.
3111 mappedValue = nextValue;
3114 // Polyfill.io - The try catch accounts for step ix.
3115 // viii. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, mappedValue).
3116 CreateDataPropertyOrThrow(A, Pk, mappedValue);
3117 // ix. If defineStatus is an abrupt completion, return ? IteratorClose(iteratorRecord, defineStatus).
3119 return IteratorClose(iteratorRecord, e);
3121 // x. Increase k by 1.
3125 // 6. NOTE: items is not an Iterable so assume it is an array-like object.
3126 // 7. Let arrayLike be ! ToObject(items).
3127 // Polyfill.io - For Strings we need to split astral symbols into surrogate pairs.
3128 if (isString(items)) {
3129 var arrayLike = stringMatch.call(items, /[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g) || [];
3131 arrayLike = ToObject(items);
3133 // 8. Let len be ? ToLength(? Get(arrayLike, "length")).
3134 var len = ToLength(Get(arrayLike, "length"));
3135 // 9. If IsConstructor(C) is true, then
3136 if (IsConstructor(C)) {
3137 // a. Let A be ? Construct(C, « len »).
3138 A = Construct(C, [len]);
3141 // a. Let A be ? ArrayCreate(len).
3142 A = ArrayCreate(len);
3146 // 12. Repeat, while k < len
3148 // a. Let Pk be ! ToString(k).
3150 // b. Let kValue be ? Get(arrayLike, Pk).
3151 var kValue = Get(arrayLike, Pk);
3152 // c. If mapping is true, then
3153 if (mapping === true) {
3154 // i. Let mappedValue be ? Call(mapfn, T, « kValue, k »).
3155 mappedValue = Call(mapfn, T, [kValue, k]);
3156 // d. Else, let mappedValue be kValue.
3158 mappedValue = kValue;
3160 // e. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
3161 CreateDataPropertyOrThrow(A, Pk, mappedValue);
3162 // f. Increase k by 1.
3165 // 13. Perform ? Set(A, "length", len, true).
3174 if (!('of' in Array)) {
3177 /* global ArrayCreate, Construct, CreateDataPropertyOrThrow, CreateMethodProperty, IsConstructor, ToString */
3178 // 22.1.2.3. Array.of ( ...items )
3179 CreateMethodProperty(Array, 'of', function of() {
3180 // 1. Let len be the actual number of arguments passed to this function.
3181 var len = arguments.length;
3182 // 2. Let items be the List of arguments passed to this function.
3183 var items = arguments;
3184 // 3. Let C be the this value.
3186 // 4. If IsConstructor(C) is true, then
3187 if (IsConstructor(C)) {
3188 // a. Let A be ? Construct(C, « len »).
3189 var A = Construct(C, [len]);
3192 // a. Let A be ? ArrayCreate(len).
3193 var A = ArrayCreate(len);
3197 // 7. Repeat, while k < len
3199 // a. Let kValue be items[k].
3200 var kValue = items[k];
3201 // b. Let Pk be ! ToString(k).
3202 var Pk = ToString(k);
3203 // c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue).
3204 CreateDataPropertyOrThrow(A, Pk, kValue);
3205 // d. Increase k by 1.
3209 // 8. Perform ? Set(A, "length", len, true)
3217 if (!('assign' in Object)) {
3220 /* global CreateMethodProperty, Get, ToObject */
3221 // 19.1.2.1 Object.assign ( target, ...sources )
3222 CreateMethodProperty(Object, 'assign', function assign(target, source) { // eslint-disable-line no-unused-vars
3223 // 1. Let to be ? ToObject(target).
3224 var to = ToObject(target);
3226 // 2. If only one argument was passed, return to.
3227 if (arguments.length === 1) {
3231 // 3. Let sources be the List of argument values starting with the second argument
3232 var sources = Array.prototype.slice.call(arguments, 1);
3234 // 4. For each element nextSource of sources, in ascending index order, do
3239 for (index1 = 0; index1 < sources.length; index1++) {
3240 var nextSource = sources[index1];
3241 // a. If nextSource is undefined or null, let keys be a new empty List.
3242 if (nextSource === undefined || nextSource === null) {
3246 // i. Let from be ! ToObject(nextSource).
3247 from = ToObject(nextSource);
3248 // ii. Let keys be ? from.[[OwnPropertyKeys]]().
3250 This step in our polyfill is not complying with the specification.
3251 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
3252 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
3254 keys = Object.keys(from);
3257 // c. For each element nextKey of keys in List order, do
3258 for (index2 = 0; index2 < keys.length; index2++) {
3259 var nextKey = keys[index2];
3260 // i. Let desc be ? from.[[GetOwnProperty]](nextKey).
3261 var desc = Object.getOwnPropertyDescriptor(from, nextKey);
3262 // ii. If desc is not undefined and desc.[[Enumerable]] is true, then
3263 if (desc !== undefined && desc.enumerable) {
3264 // 1. Let propValue be ? Get(from, nextKey).
3265 var propValue = Get(from, nextKey);
3266 // 2. Perform ? Set(to, nextKey, propValue, true).
3267 to[nextKey] = propValue;
3277 if (!('Symbol' in this && 'toStringTag' in this.Symbol)) {
3279 // Symbol.toStringTag
3281 Object.defineProperty(Symbol, 'toStringTag', {
3282 value: Symbol('toStringTag')
3290 // A modification of https://github.com/medikoo/es6-iterator
3291 // Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
3293 var Iterator = (function () { // eslint-disable-line no-unused-vars
3294 var clear = function () {
3298 var callable = function (fn) {
3299 if (typeof fn !== 'function') throw new TypeError(fn + " is not a function");
3303 var Iterator = function (list, context) {
3304 if (!(this instanceof Iterator)) {
3305 return new Iterator(list, context);
3307 Object.defineProperties(this, {
3321 if (!context) return;
3322 callable(context.on);
3323 context.on('_add', this._onAdd.bind(this));
3324 context.on('_delete', this._onDelete.bind(this));
3325 context.on('_clear', this._onClear.bind(this));
3328 Object.defineProperties(Iterator.prototype, Object.assign({
3336 value: function () {
3338 if (!this.__list__) return;
3339 if (this.__redo__) {
3340 i = this.__redo__.shift();
3341 if (i !== undefined) return i;
3343 if (this.__nextIndex__ < this.__list__.length) return this.__nextIndex__++;
3351 value: function () {
3352 return this._createResult(this._next());
3359 value: function (i) {
3360 if (i === undefined) return {
3366 value: this._resolve(i)
3374 value: function (i) {
3375 return this.__list__[i];
3382 value: function () {
3383 this.__list__ = null;
3384 delete this.__redo__;
3385 if (!this.__context__) return;
3386 this.__context__.off('_add', this._onAdd.bind(this));
3387 this.__context__.off('_delete', this._onDelete.bind(this));
3388 this.__context__.off('_clear', this._onClear.bind(this));
3389 this.__context__ = null;
3396 value: function () {
3397 return '[object Iterator]';
3405 value: function (index) {
3406 if (index >= this.__nextIndex__) return;
3407 ++this.__nextIndex__;
3408 if (!this.__redo__) {
3409 Object.defineProperty(this, '__redo__', {
3417 this.__redo__.forEach(function (redo, i) {
3418 if (redo >= index) this.__redo__[i] = ++redo;
3420 this.__redo__.push(index);
3427 value: function (index) {
3429 if (index >= this.__nextIndex__) return;
3430 --this.__nextIndex__;
3431 if (!this.__redo__) return;
3432 i = this.__redo__.indexOf(index);
3433 if (i !== -1) this.__redo__.splice(i, 1);
3434 this.__redo__.forEach(function (redo, i) {
3435 if (redo > index) this.__redo__[i] = --redo;
3443 value: function () {
3444 if (this.__redo__) clear.call(this.__redo__);
3445 this.__nextIndex__ = 0;
3453 Object.defineProperty(Iterator.prototype, Symbol.iterator, {
3454 value: function () {
3461 Object.defineProperty(Iterator.prototype, Symbol.toStringTag, {
3463 configurable: false,
3471 // Object.setPrototypeOf
3472 /* global CreateMethodProperty */
3473 // ES6-shim 0.16.0 (c) 2013-2014 Paul Miller (http://paulmillr.com)
3474 // ES6-shim may be freely distributed under the MIT license.
3475 // For more details and documentation:
3476 // https://github.com/paulmillr/es6-shim/
3478 // NOTE: This versions needs object ownership
3479 // because every promoted object needs to be reassigned
3480 // otherwise uncompatible browsers cannot work as expected
3482 // NOTE: This might need es5-shim or polyfills upfront
3483 // because it's based on ES5 API.
3484 // (probably just an IE <= 8 problem)
3486 // NOTE: nodejs is fine in version 0.8, 0.10, and future versions.
3488 if (Object.setPrototypeOf) { return; }
3490 /*jshint proto: true */
3491 // @author Andrea Giammarchi - @WebReflection
3493 var getOwnPropertyNames = Object.getOwnPropertyNames;
3494 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
3495 var create = Object.create;
3496 var defineProperty = Object.defineProperty;
3497 var getPrototypeOf = Object.getPrototypeOf;
3498 var objProto = Object.prototype;
3500 var copyDescriptors = function (target, source) {
3501 // define into target descriptors from source
3502 getOwnPropertyNames(source).forEach(function (key) {
3506 getOwnPropertyDescriptor(source, key)
3511 // used as fallback when no promotion is possible
3512 var createAndCopy = function setPrototypeOf(origin, proto) {
3513 return copyDescriptors(create(proto), origin);
3517 // this might fail for various reasons
3518 // ignore if Chrome cought it at runtime
3519 set = getOwnPropertyDescriptor(objProto, '__proto__').set;
3521 // setter not poisoned, it can promote
3523 sPOf = function setPrototypeOf(origin, proto) {
3524 set.call(origin, proto);
3528 // do one or more feature detections
3529 set = { __proto__: null };
3530 // if proto does not work, needs to fallback
3531 // some Opera, Rhino, ducktape
3532 if (set instanceof Object) {
3533 sPOf = createAndCopy;
3535 // verify if null objects are buggy
3536 /* eslint-disable no-proto */
3537 set.__proto__ = objProto;
3538 /* eslint-enable no-proto */
3539 // if null objects are buggy
3540 // nodejs 0.8 to 0.10
3541 if (set instanceof Object) {
3542 sPOf = function setPrototypeOf(origin, proto) {
3543 // use such bug to promote
3544 /* eslint-disable no-proto */
3545 origin.__proto__ = proto;
3546 /* eslint-enable no-proto */
3550 // try to use proto or fallback
3551 // Safari, old Firefox, many others
3552 sPOf = function setPrototypeOf(origin, proto) {
3553 // if proto is not null
3554 if (getPrototypeOf(origin)) {
3555 // use __proto__ to promote
3556 /* eslint-disable no-proto */
3557 origin.__proto__ = proto;
3558 /* eslint-enable no-proto */
3561 // otherwise unable to promote: fallback
3562 return createAndCopy(origin, proto);
3568 CreateMethodProperty(Object, 'setPrototypeOf', sPOf);
3571 // _ESAbstract.RequireObjectCoercible
3572 // 7.2.1. RequireObjectCoercible ( argument )
3573 // The abstract operation ToObject converts argument to a value of type Object according to Table 12:
3574 // Table 12: ToObject Conversions
3576 |----------------------------------------------------------------------------------------------------------------------------------------------------|
3577 | Argument Type | Result |
3578 |----------------------------------------------------------------------------------------------------------------------------------------------------|
3579 | Undefined | Throw a TypeError exception. |
3580 | Null | Throw a TypeError exception. |
3581 | Boolean | Return argument. |
3582 | Number | Return argument. |
3583 | String | Return argument. |
3584 | Symbol | Return argument. |
3585 | Object | Return argument. |
3586 |----------------------------------------------------------------------------------------------------------------------------------------------------|
3588 function RequireObjectCoercible(argument) { // eslint-disable-line no-unused-vars
3589 if (argument === null || argument === undefined) {
3595 // _ESAbstract.IsRegExp
3596 /* global Type, Get, ToBoolean */
3597 // 7.2.8. IsRegExp ( argument )
3598 function IsRegExp(argument) { // eslint-disable-line no-unused-vars
3599 // 1. If Type(argument) is not Object, return false.
3600 if (Type(argument) !== 'object') {
3603 // 2. Let matcher be ? Get(argument, @@match).
3604 var matcher = 'Symbol' in this && 'match' in this.Symbol ? Get(argument, this.Symbol.match) : undefined;
3605 // 3. If matcher is not undefined, return ToBoolean(matcher).
3606 if (matcher !== undefined) {
3607 return ToBoolean(matcher);
3609 // 4. If argument has a [[RegExpMatcher]] internal slot, return true.
3611 var lastIndex = argument.lastIndex;
3612 argument.lastIndex = 0;
3613 RegExp.prototype.exec.call(argument);
3615 } catch (e) {} finally {
3616 argument.lastIndex = lastIndex;
3621 if (!('includes' in String.prototype)) {
3623 // String.prototype.includes
3624 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
3625 // 21.1.3.7. String.prototype.includes ( searchString [ , position ] )
3626 CreateMethodProperty(String.prototype, 'includes', function includes(searchString /* [ , position ] */) {
3628 var position = arguments.length > 1 ? arguments[1] : undefined;
3629 // 1. Let O be ? RequireObjectCoercible(this value).
3630 var O = RequireObjectCoercible(this);
3631 // 2. Let S be ? ToString(O).
3632 var S = ToString(O);
3633 // 3. Let isRegExp be ? IsRegExp(searchString).
3634 var isRegExp = IsRegExp(searchString);
3635 // 4. If isRegExp is true, throw a TypeError exception.
3637 throw new TypeError('First argument to String.prototype.includes must not be a regular expression');
3639 // 5. Let searchStr be ? ToString(searchString).
3640 var searchStr = ToString(searchString);
3641 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
3642 var pos = ToInteger(position);
3643 // 7. Let len be the length of S.
3645 // 8. Let start be min(max(pos, 0), len).
3646 var start = Math.min(Math.max(pos, 0), len);
3647 // 9. Let searchLen be the length of searchStr.
3648 // var searchLength = searchStr.length;
3649 // 10. If there exists any integer k not smaller than start such that k + searchLen is not greater than len, and for all nonnegative integers j less than searchLen, the code unit at index k+j within S is the same as the code unit at index j within searchStr, return true; but if there is no such integer k, return false.
3650 return String.prototype.indexOf.call(S, searchStr, start) !== -1;
3657 /* global Iterator */
3658 // A modification of https://github.com/medikoo/es6-iterator
3659 // Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
3661 var ArrayIterator = (function() { // eslint-disable-line no-unused-vars
3663 var ArrayIterator = function(arr, kind) {
3664 if (!(this instanceof ArrayIterator)) return new ArrayIterator(arr, kind);
3665 Iterator.call(this, arr);
3666 if (!kind) kind = 'value';
3667 else if (String.prototype.includes.call(kind, 'key+value')) kind = 'key+value';
3668 else if (String.prototype.includes.call(kind, 'key')) kind = 'key';
3669 else kind = 'value';
3670 Object.defineProperty(this, '__kind__', {
3672 configurable: false,
3677 if (Object.setPrototypeOf) Object.setPrototypeOf(ArrayIterator, Iterator.prototype);
3679 ArrayIterator.prototype = Object.create(Iterator.prototype, {
3681 value: ArrayIterator,
3687 value: function(i) {
3688 if (this.__kind__ === 'value') return this.__list__[i];
3689 if (this.__kind__ === 'key+value') return [i, this.__list__[i]];
3698 return '[object Array Iterator]';
3706 return ArrayIterator;
3708 if (!('values' in Array.prototype)) {
3710 // Array.prototype.values
3711 /* global CreateMethodProperty, Symbol, ToObject */
3712 // 22.1.3.30/ Array.prototype.values ( )
3713 // Polyfill.io - Firefox, Chrome and Opera have Array.prototype[Symbol.iterator], which is the exact same function as Array.prototype.values.
3714 if ('Symbol' in this && 'iterator' in Symbol && typeof Array.prototype[Symbol.iterator] === 'function') {
3715 CreateMethodProperty(Array.prototype, 'values', Array.prototype[Symbol.iterator]);
3717 CreateMethodProperty(Array.prototype, 'values', function values () {
3718 // 1. Let O be ? ToObject(this value).
3719 var O = ToObject(this);
3720 // 2. Return CreateArrayIterator(O, "value").
3721 // TODO: Add CreateArrayIterator
3722 return new ArrayIterator(O, 'value');
3728 if (!('Symbol' in this && 'iterator' in this.Symbol && !!Array.prototype[Symbol.iterator])) {
3730 // Array.prototype.@@iterator
3731 /* global Symbol, CreateMethodProperty */
3732 // 22.1.3.31. Array.prototype [ @@iterator ] ( )
3733 // The initial value of the @@iterator property is the same function object as the initial value of the Array.prototype.values property.
3734 CreateMethodProperty(Array.prototype, Symbol.iterator, Array.prototype.values);
3738 if (!('copyWithin' in Array.prototype && (function () {
3740 var Parent = function Parent() {};
3741 Parent.prototype[0] = 'foo';
3742 var sparse = new Parent();
3746 var result = Array.prototype.copyWithin.call(sparse, 1, 0);
3747 if (result['0'] && !Object.prototype.hasOwnProperty.call(result, '0') && Object.prototype.hasOwnProperty.call(result, '1') && result[0] === 'foo' && result[1] === 'foo' && result[2] === 1 && result.length === 3) {
3757 // Array.prototype.copyWithin
3758 /* global CreateMethodProperty, HasProperty, ToInteger */
3759 // 22.1.3.3 Array.prototype.copyWithin ( target, start [ , end ] )
3760 CreateMethodProperty(Array.prototype, 'copyWithin', function copyWithin(target, start /* [ , end ] */ ) {
3762 var end = arguments[2];
3764 // 22.1.3.3.1 Let O be ? ToObject(this value).
3765 if (this === null || this === undefined) {
3766 throw new TypeError('Cannot call method on ' + this);
3769 var o = Object(this);
3771 // 22.1.3.3.2 Let len be ? ToLength(? Get(O, "length")).
3772 var len = ToInteger(o.length);
3776 if (len === Infinity) {
3777 len = Math.pow(2, 53) - 1;
3779 len = Math.min(len, Math.pow(2, 53) - 1);
3781 len = Math.max(len, 0);
3783 // 22.1.3.3.3 Let relativeTarget be ? ToInteger(target).
3784 var relativeTarget = ToInteger(target);
3786 // 22.1.3.3.4 If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let to be min(relativeTarget, len).
3788 if (relativeTarget < 0) {
3789 to = Math.max(len + relativeTarget, 0);
3791 to = Math.min(relativeTarget, len);
3794 // 22.1.3.3.5 Let relativeStart be ? ToInteger(start).
3795 var relativeStart = ToInteger(start);
3797 // 22.1.3.3.6 If relativeStart < 0, let from be max((len + relativeStart), 0); else let from be min(relativeStart, len).
3799 if (relativeStart < 0) {
3800 from = Math.max(len + relativeStart, 0);
3802 from = Math.min(relativeStart, len);
3805 // 22.1.3.3.7 If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
3807 if (end === undefined) {
3810 relativeEnd = ToInteger(end);
3813 // 22.1.3.3.8 If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
3815 if (relativeEnd < 0) {
3816 final = Math.max(len + relativeEnd, 0);
3818 final = Math.min(relativeEnd, len);
3821 // 22.1.3.3.9 Let count be min(final-from, len-to).
3822 var count = Math.min(final - from, len - to);
3824 // 22.1.3.3.10 If from<to and to<from+count, then
3826 if (from < to && to < from + count) {
3827 // 22.1.3.3.10.a Let direction be -1.
3830 // 22.1.3.3.10.b Let from be from + count - 1.
3831 from = from + count - 1;
3833 // 22.1.3.3.10.c Let to be to + count - 1.
3834 to = to + count - 1;
3836 // 22.1.3.3.11 Else,
3837 // 22.1.3.3.11.a Let direction be 1.
3841 // 22.1.3.3.12 Repeat, while count > 0
3843 // 22.1.3.3.12.a Let fromKey be ! ToString(from).
3844 var fromKey = String(from);
3845 // 22.1.3.3.12.b Let toKey be ! ToString(to).
3846 var toKey = String(to);
3847 // 22.1.3.3.12.c Let fromPresent be ? HasProperty(O, fromKey).
3848 var fromPresent = HasProperty(o, fromKey);
3849 // 22.1.3.3.12.d If fromPresent is true, then
3851 // 22.1.3.3.12.d.i Let fromVal be ? Get(O, fromKey).
3852 var fromVal = o[fromKey];
3853 // 22.1.3.3.12.d.ii Perform ? Set(O, toKey, fromVal, true).
3856 // 22.1.3.3.12.e Else fromPresent is false,
3857 // 22.1.3.3.12.e.i Perform ? DeletePropertyOrThrow(O, toKey).
3860 // 22.1.3.3.12.f Let from be from + direction.
3861 from = from + direction;
3862 // 22.1.3.3.12.g Let to be to + direction.
3863 to = to + direction;
3864 // 22.1.3.3.12.h Let count be count - 1.
3867 // 22.1.3.3.13 Return O.
3873 if (!('Symbol' in this && 'iterator' in this.Symbol && !!Array.prototype.entries)) {
3875 // Array.prototype.entries
3876 /* global CreateMethodProperty, ToObject */
3877 // 22.1.3.4. Array.prototype.entries ( )
3878 CreateMethodProperty(Array.prototype, 'entries', function entries() {
3879 // 1. Let O be ? ToObject(this value).
3880 var O = ToObject(this);
3881 // 2. Return CreateArrayIterator(O, "key+value").
3882 // TODO: Add CreateArrayIterator
3883 return new ArrayIterator(O, 'key+value');
3888 if (!('fill' in Array.prototype)) {
3890 // Array.prototype.fill
3891 /* global CreateMethodProperty, Get, ToInteger, ToLength, ToObject, ToString */
3892 // 22.1.3.6. Array.prototype.fill ( value [ , start [ , end ] ] )
3893 CreateMethodProperty(Array.prototype, 'fill', function fill(value /* [ , start [ , end ] ] */) {
3894 var start = arguments[1];
3895 var end = arguments[2];
3896 // 1. Let O be ? ToObject(this value).
3897 var O = ToObject(this);
3898 // 2. Let len be ? ToLength(? Get(O, "length")).
3899 var len = ToLength(Get(O, "length"));
3900 // 3. Let relativeStart be ? ToInteger(start).
3901 var relativeStart = ToInteger(start);
3902 // 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be min(relativeStart, len)
3903 var k = relativeStart < 0 ? Math.max((len + relativeStart), 0) : Math.min(relativeStart, len);
3904 // 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
3905 var relativeEnd = end === undefined ? len : ToInteger(end);
3906 // 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
3907 var final = relativeEnd < 0 ? Math.max((len + relativeEnd), 0) : Math.min(relativeEnd, len);
3908 // 7. Repeat, while k < final
3910 // a. Let Pk be ! ToString(k).
3911 var Pk = ToString(k);
3912 // b. Perform ? Set(O, Pk, value, true).
3914 // c. Increase k by 1.
3923 if (!('find' in Array.prototype)) {
3925 // Array.prototype.find
3926 /* global Call, CreateMethodProperty, Get, IsCallable, ToBoolean, ToLength, ToObject, ToString */
3927 // 22.1.3.8 Array.prototype.find ( predicate [ , thisArg ] )
3928 CreateMethodProperty(Array.prototype, 'find', function find( predicate /* [ , thisArg ] */) {
3929 // 1. Let O be ? ToObject(this value).
3930 var O = ToObject(this);
3931 // 2. Let len be ? ToLength(? Get(O, "length")).
3932 var len = ToLength(Get(O, "length"));
3933 // 3. If IsCallable(predicate) is false, throw a TypeError exception.
3934 if (IsCallable(predicate) === false) {
3935 throw new TypeError(predicate + ' is not a function');
3937 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
3938 var T = arguments.length > 1 ? arguments[1] : undefined;
3941 // 6. Repeat, while k < len
3943 // a. Let Pk be ! ToString(k).
3944 var Pk = ToString(k);
3945 // b. Let kValue be ? Get(O, Pk).
3946 var kValue = Get(O, Pk);
3947 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
3948 var testResult = ToBoolean(Call(predicate, T, [kValue, k, O ]));
3949 // d. If testResult is true, return kValue.
3953 // e. Increase k by 1.
3956 // 7. Return undefined.
3962 if (!('findIndex' in Array.prototype)) {
3964 // Array.prototype.findIndex
3965 /* global Call, CreateMethodProperty, Get, IsCallable, ToBoolean, ToLength, ToObject, ToString */
3966 // 22.1.3.9. Array.prototype.findIndex ( predicate [ , thisArg ] )
3967 CreateMethodProperty(Array.prototype, 'findIndex', function findIndex(predicate /* [ , thisArg ] */) {
3968 // 1. Let O be ? ToObject(this value).
3969 var O = ToObject(this);
3970 // 2. Let len be ? ToLength(? Get(O, "length")).
3971 var len = ToLength(Get(O, "length"));
3972 // 3. If IsCallable(predicate) is false, throw a TypeError exception.
3973 if (IsCallable(predicate) === false) {
3974 throw new TypeError(predicate + ' is not a function');
3976 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
3977 var T = arguments.length > 1 ? arguments[1] : undefined;
3980 // 6. Repeat, while k < len
3982 // a. Let Pk be ! ToString(k).
3983 var Pk = ToString(k);
3984 // b. Let kValue be ? Get(O, Pk).
3985 var kValue = Get(O, Pk);
3986 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
3987 var testResult = ToBoolean(Call(predicate, T, [kValue, k, O]));
3988 // d. If testResult is true, return k.
3992 // e. Increase k by 1.
4001 if (!('Symbol' in this && 'iterator' in this.Symbol && !!Array.prototype.keys)) {
4003 // Array.prototype.keys
4004 /* global CreateMethodProperty, ToObject */
4005 // 22.1.3.14. Array.prototype.keys ( )
4006 CreateMethodProperty(Array.prototype, 'keys', function keys() {
4007 // 1. Let O be ? ToObject(this value).
4008 var O = ToObject(this);
4009 // 2. Return CreateArrayIterator(O, "key").
4010 // TODO: Add CreateArrayIterator.
4011 return new ArrayIterator(O, 'key');
4016 if (!('name' in Function.prototype && (function x() {}).name === 'x')) {
4022 accessorName = 'name',
4023 fnNameMatchRegex = /^\s*function\s+([^\(\s]*)\s*/,
4024 $Function = Function,
4025 FunctionName = 'Function',
4026 FunctionProto = $Function.prototype,
4027 FunctionProtoCtor = FunctionProto.constructor,
4029 getFunctionName = function(fn) {
4032 if (fn === $Function || fn === FunctionProtoCtor) {
4033 name = FunctionName;
4035 else if (fn !== FunctionProto) {
4036 match = ('' + fn).match(fnNameMatchRegex);
4037 name = match && match[1];
4043 Object.defineProperty(FunctionProto, accessorName, {
4044 get: function Function$name() {
4047 fnName = getFunctionName(fn);
4049 // Since named function definitions have immutable names, also memoize the
4050 // output by defining the `name` property directly on this Function
4051 // instance so the accessor function will not need to be invoked again.
4052 if (fn !== FunctionProto) {
4053 Object.defineProperty(fn, accessorName, {
4068 if (!('acosh' in Math)) {
4071 /* global CreateMethodProperty */
4072 // 20.2.2.3. Math.acosh ( x )
4073 CreateMethodProperty(Math, 'acosh', function acosh(x) {
4074 // If x is NaN, the result is NaN.
4078 // If x is less than 1, the result is NaN.
4082 // If x is 1, the result is +0.
4086 // If x is +∞, the result is +∞.
4087 if (x === Infinity) {
4090 return Math.log(x + Math.sqrt(x * x - 1));
4095 if (!('asinh' in Math)) {
4098 /* global CreateMethodProperty */
4099 // 20.2.2.5. Math.asinh ( x )
4100 CreateMethodProperty(Math, 'asinh', function asinh(x) {
4101 // If x is NaN, the result is NaN.
4105 // If x is +0, the result is +0.
4106 if (x === 0 && 1/x === Infinity) {
4109 // If x is -0, the result is -0.
4110 if (x === 0 && 1/x === -Infinity) {
4113 // If x is +∞, the result is +∞.
4114 if (x === Infinity) {
4117 // If x is -∞, the result is -∞.
4118 if (x === -Infinity) {
4121 return Math.log(x + Math.sqrt(x * x + 1));
4126 if (!('atanh' in Math)) {
4129 /* global CreateMethodProperty */
4130 // 20.2.2.7. Math.atanh ( x )
4131 CreateMethodProperty(Math, 'atanh', function atanh(x) {
4132 // If x is NaN, the result is NaN.
4136 // If x is less than -1, the result is NaN.
4140 // If x is greater than 1, the result is NaN.
4144 // If x is -1, the result is -∞.
4148 // If x is +1, the result is +∞.
4152 // If x is +0, the result is +0.
4153 if (x === 0 && 1/x === Infinity) {
4156 // If x is -0, the result is -0.
4157 if (x === 0 && 1/x === -Infinity) {
4160 return Math.log((1 + x) / (1 - x)) / 2;
4165 if (!('cbrt' in Math)) {
4168 /* global CreateMethodProperty */
4169 // 20.2.2.9. Math.cbrt ( x )
4170 CreateMethodProperty(Math, 'cbrt', function cbrt(x) {
4171 // If x is NaN, the result is NaN.
4175 // If x is +0, the result is +0.
4176 if (x === 0 && 1/x === Infinity) {
4179 // If x is -0, the result is -0.
4180 if (x === 0 && 1/x === -Infinity) {
4183 // If x is +∞, the result is +∞.
4184 if (x === Infinity) {
4187 // If x is -∞, the result is -∞.
4188 if (x === -Infinity) {
4191 var y = Math.pow(Math.abs(x), 1 / 3);
4192 return x < 0 ? -y : y;
4198 // _ESAbstract.ToUint32
4199 // 7.1.6. ToUint32 ( argument )
4200 function ToUint32(argument) { // eslint-disable-line no-unused-vars
4201 // 1. Let number be ? ToNumber(argument).
4202 var number = Number(argument);
4203 // 2. If number is NaN, +0, -0, +∞, or -∞, return +0.
4204 if (isNaN(number) || 1/number === Infinity || 1/number === -Infinity || number === Infinity || number === -Infinity) {
4207 // 3. Let int be the mathematical value that is the same sign as number and whose magnitude is floor(abs(number)).
4208 var int = ((number < 0) ? -1 : 1) * Math.floor(Math.abs(number));
4209 // 4. Let int32bit be int modulo 2^32.
4210 var int32bit = int >>> 0;
4211 // 5. Return int32bit.
4214 if (!('clz32' in Math)) {
4217 /* global CreateMethodProperty, ToUint32 */
4218 // 20.2.2.11. Math.clz32 ( x )
4219 CreateMethodProperty(Math, 'clz32', function clz32(x) {
4220 // 1. Let n be ToUint32(x).
4221 var n = ToUint32(x);
4222 // 2. Let p be the number of leading zero bits in the 32-bit binary representation of n.
4223 var p = n ? 32 - n.toString(2).length : 32;
4230 if (!('cosh' in Math)) {
4233 /* global CreateMethodProperty */
4234 // 20.2.2.1. 3Math.cosh ( x )
4235 CreateMethodProperty(Math, 'cosh', function cosh(x) {
4236 // If x is NaN, the result is NaN.
4240 // If x is +0, the result is 1.
4241 if (x === 0 && 1/x === Infinity) {
4244 // If x is -0, the result is 1.
4245 if (x === 0 && 1/x === -Infinity) {
4248 // If x is +∞, the result is +∞.
4249 if (x === Infinity) {
4252 // If x is -∞, the result is +∞.
4253 if (x === -Infinity) {
4258 var y = Math.exp(0.5 * x);
4261 var y = Math.exp(x);
4262 return (y + 1 / y) / 2;
4267 if (!('expm1' in Math)) {
4270 /* global CreateMethodProperty */
4271 // 20.2.2.15. Math.expm1 ( x )
4272 CreateMethodProperty(Math, 'expm1', function expm1(x) {
4273 // If x is NaN, the result is NaN.
4277 // If x is +0, the result is +0.
4278 if (x === 0 && 1/x === Infinity) {
4281 // If x is -0, the result is -0.
4282 if (x === 0 && 1/x === -Infinity) {
4285 // If x is +∞, the result is +∞.
4286 if (x === Infinity) {
4289 // If x is -∞, the result is -1.
4290 if (x === -Infinity) {
4294 if (x > -1e-6 && x < 1e-6) {
4295 return x + x * x / 2;
4297 return Math.exp(x) - 1;
4306 Copyright (c) 2010, Linden Research, Inc.
4307 Copyright (c) 2014, Joshua Bell
4309 Permission is hereby granted, free of charge, to any person obtaining a copy
4310 of this software and associated documentation files (the "Software"), to deal
4311 in the Software without restriction, including without limitation the rights
4312 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4313 copies of the Software, and to permit persons to whom the Software is
4314 furnished to do so, subject to the following conditions:
4316 The above copyright notice and this permission notice shall be included in
4317 all copies or substantial portions of the Software.
4319 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4320 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4321 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4322 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4323 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4324 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4329 // Original can be found at:
4330 // https://bitbucket.org/lindenlab/llsd
4331 // Modifications by Joshua Bell inexorabletash@gmail.com
4332 // https://github.com/inexorabletash/polyfill
4334 // ES3/ES5 implementation of the Krhonos Typed Array Specification
4335 // Ref: http://www.khronos.org/registry/typedarray/specs/latest/
4339 // * Allows typed_array.get/set() as alias for subscripts (typed_array[])
4340 // * Gradually migrating structure from Khronos spec to ES2015 spec
4343 // * Beyond 10000 or so entries, polyfilled array accessors (ta[0],
4344 // etc) become memory-prohibitive, so array creation will fail. Set
4345 // self.TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS=true to disable
4346 // creation of accessors. Your code will need to use the
4347 // non-standard get()/set() instead, and will need to add those to
4348 // native arrays for interop.
4351 var undefined = (void 0); // Paranoia
4353 // Beyond this value, index getters/setters (i.e. array[0], array[1]) are so slow to
4354 // create, and consume so much memory, that the browser appears frozen.
4355 var MAX_ARRAY_LENGTH = 1e5;
4357 // Approximations of internal ECMAScript conversion functions
4360 case 'undefined': return 'undefined';
4361 case 'boolean': return 'boolean';
4362 case 'number': return 'number';
4363 case 'string': return 'string';
4364 default: return v === null ? 'null' : 'object';
4368 // Class returns internal [[Class]] property, used to avoid cross-frame instanceof issues:
4369 function Class(v) { return Object.prototype.toString.call(v).replace(/^\[object *|\]$/g, ''); }
4370 function IsCallable(o) { return typeof o === 'function'; }
4371 function ToObject(v) {
4372 if (v === null || v === undefined) throw TypeError();
4375 function ToInt32(v) { return v >> 0; }
4376 function ToUint32(v) { return v >>> 0; }
4378 // Snapshot intrinsics
4388 // emulate ES5 getter/setter API using legacy APIs
4389 // http://blogs.msdn.com/b/ie/archive/2010/09/07/transitioning-existing-code-to-the-es5-getter-setter-apis.aspx
4390 // (second clause tests for Object.defineProperty() in IE<9 that only supports extending DOM prototypes, but
4391 // note that IE<9 does not support __defineGetter__ or __defineSetter__ so it just renders the method harmless)
4394 var orig = Object.defineProperty;
4395 var dom_only = !(function(){try{return Object.defineProperty({},'x',{});}catch(_){return false;}}());
4397 if (!orig || dom_only) {
4398 Object.defineProperty = function (o, prop, desc) {
4399 // In IE8 try built-in implementation for defining properties on DOM prototypes.
4401 try { return orig(o, prop, desc); } catch (_) {}
4402 if (o !== Object(o))
4403 throw TypeError('Object.defineProperty called on non-object');
4404 if (Object.prototype.__defineGetter__ && ('get' in desc))
4405 Object.prototype.__defineGetter__.call(o, prop, desc.get);
4406 if (Object.prototype.__defineSetter__ && ('set' in desc))
4407 Object.prototype.__defineSetter__.call(o, prop, desc.set);
4408 if ('value' in desc)
4409 o[prop] = desc.value;
4415 // ES5: Make obj[index] an alias for obj._getter(index)/obj._setter(index, value)
4416 // for index in 0 ... obj.length
4417 function makeArrayAccessors(obj) {
4418 if ('TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS' in global)
4421 if (obj.length > MAX_ARRAY_LENGTH) throw RangeError('Array too large for polyfill');
4423 function makeArrayAccessor(index) {
4424 Object.defineProperty(obj, index, {
4425 'get': function() { return obj._getter(index); },
4426 'set': function(v) { obj._setter(index, v); },
4433 for (i = 0; i < obj.length; i += 1) {
4434 makeArrayAccessor(i);
4438 // Internal conversion functions:
4439 // pack<Type>() - take a number (interpreted as Type), output a byte array
4440 // unpack<Type>() - take a byte array, output a Type-like number
4442 function as_signed(value, bits) { var s = 32 - bits; return (value << s) >> s; }
4443 function as_unsigned(value, bits) { var s = 32 - bits; return (value << s) >>> s; }
4445 function packI8(n) { return [n & 0xff]; }
4446 function unpackI8(bytes) { return as_signed(bytes[0], 8); }
4448 function packU8(n) { return [n & 0xff]; }
4449 function unpackU8(bytes) { return as_unsigned(bytes[0], 8); }
4451 function packU8Clamped(n) { n = round(Number(n)); return [n < 0 ? 0 : n > 0xff ? 0xff : n & 0xff]; }
4453 function packI16(n) { return [n & 0xff, (n >> 8) & 0xff]; }
4454 function unpackI16(bytes) { return as_signed(bytes[1] << 8 | bytes[0], 16); }
4456 function packU16(n) { return [n & 0xff, (n >> 8) & 0xff]; }
4457 function unpackU16(bytes) { return as_unsigned(bytes[1] << 8 | bytes[0], 16); }
4459 function packI32(n) { return [n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, (n >> 24) & 0xff]; }
4460 function unpackI32(bytes) { return as_signed(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0], 32); }
4462 function packU32(n) { return [n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, (n >> 24) & 0xff]; }
4463 function unpackU32(bytes) { return as_unsigned(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0], 32); }
4465 function packIEEE754(v, ebits, fbits) {
4467 var bias = (1 << (ebits - 1)) - 1;
4469 function roundToEven(n) {
4470 var w = floor(n), f = n - w;
4475 return w % 2 ? w + 1 : w;
4478 // Compute sign, exponent, fraction
4482 // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping
4483 e = (1 << ebits) - 1; f = pow(2, fbits - 1); s = 0;
4484 } else if (v === Infinity || v === -Infinity) {
4485 e = (1 << ebits) - 1; f = 0; s = (v < 0) ? 1 : 0;
4486 } else if (v === 0) {
4487 e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0;
4492 if (v >= pow(2, 1 - bias)) {
4494 e = min(floor(log(v) / LN2), 1023);
4495 var significand = v / pow(2, e);
4496 if (significand < 1) {
4500 if (significand >= 2) {
4504 var d = pow(2, fbits);
4505 f = roundToEven(significand * d) - d;
4513 e = (1 << ebits) - 1;
4519 f = roundToEven(v / pow(2, 1 - bias - fbits));
4523 // Pack sign, exponent, fraction
4525 for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = floor(f / 2); }
4526 for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = floor(e / 2); }
4527 bits.push(s ? 1 : 0);
4529 var str = bits.join('');
4533 while (str.length) {
4534 bytes.unshift(parseInt(str.substring(0, 8), 2));
4535 str = str.substring(8);
4540 function unpackIEEE754(bytes, ebits, fbits) {
4542 var bits = [], i, j, b, str,
4545 for (i = 0; i < bytes.length; ++i) {
4547 for (j = 8; j; j -= 1) {
4548 bits.push(b % 2 ? 1 : 0); b = b >> 1;
4552 str = bits.join('');
4554 // Unpack sign, exponent, fraction
4555 bias = (1 << (ebits - 1)) - 1;
4556 s = parseInt(str.substring(0, 1), 2) ? -1 : 1;
4557 e = parseInt(str.substring(1, 1 + ebits), 2);
4558 f = parseInt(str.substring(1 + ebits), 2);
4561 if (e === (1 << ebits) - 1) {
4562 return f !== 0 ? NaN : s * Infinity;
4565 return s * pow(2, e - bias) * (1 + f / pow(2, fbits));
4566 } else if (f !== 0) {
4568 return s * pow(2, -(bias - 1)) * (f / pow(2, fbits));
4570 return s < 0 ? -0 : 0;
4574 function unpackF64(b) { return unpackIEEE754(b, 11, 52); }
4575 function packF64(v) { return packIEEE754(v, 11, 52); }
4576 function unpackF32(b) { return unpackIEEE754(b, 8, 23); }
4577 function packF32(v) { return packIEEE754(v, 8, 23); }
4580 // 3 The ArrayBuffer Type
4585 function ArrayBuffer(length) {
4586 length = ToInt32(length);
4587 if (length < 0) throw RangeError('ArrayBuffer size is not a small enough positive integer.');
4588 Object.defineProperty(this, 'byteLength', {value: length});
4589 Object.defineProperty(this, '_bytes', {value: Array(length)});
4591 for (var i = 0; i < length; i += 1)
4595 global.ArrayBuffer = global.ArrayBuffer || ArrayBuffer;
4598 // 5 The Typed Array View Types
4601 function $TypedArray$() {
4603 // %TypedArray% ( length )
4604 if (!arguments.length || typeof arguments[0] !== 'object') {
4605 return (function(length) {
4606 length = ToInt32(length);
4607 if (length < 0) throw RangeError('length is not a small enough positive integer.');
4608 Object.defineProperty(this, 'length', {value: length});
4609 Object.defineProperty(this, 'byteLength', {value: length * this.BYTES_PER_ELEMENT});
4610 Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(this.byteLength)});
4611 Object.defineProperty(this, 'byteOffset', {value: 0});
4613 }).apply(this, arguments);
4616 // %TypedArray% ( typedArray )
4617 if (arguments.length >= 1 &&
4618 Type(arguments[0]) === 'object' &&
4619 arguments[0] instanceof $TypedArray$) {
4620 return (function(typedArray){
4621 if (this.constructor !== typedArray.constructor) throw TypeError();
4623 var byteLength = typedArray.length * this.BYTES_PER_ELEMENT;
4624 Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(byteLength)});
4625 Object.defineProperty(this, 'byteLength', {value: byteLength});
4626 Object.defineProperty(this, 'byteOffset', {value: 0});
4627 Object.defineProperty(this, 'length', {value: typedArray.length});
4629 for (var i = 0; i < this.length; i += 1)
4630 this._setter(i, typedArray._getter(i));
4632 }).apply(this, arguments);
4635 // %TypedArray% ( array )
4636 if (arguments.length >= 1 &&
4637 Type(arguments[0]) === 'object' &&
4638 !(arguments[0] instanceof $TypedArray$) &&
4639 !(arguments[0] instanceof ArrayBuffer || Class(arguments[0]) === 'ArrayBuffer')) {
4640 return (function(array) {
4642 var byteLength = array.length * this.BYTES_PER_ELEMENT;
4643 Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(byteLength)});
4644 Object.defineProperty(this, 'byteLength', {value: byteLength});
4645 Object.defineProperty(this, 'byteOffset', {value: 0});
4646 Object.defineProperty(this, 'length', {value: array.length});
4648 for (var i = 0; i < this.length; i += 1) {
4650 this._setter(i, Number(s));
4652 }).apply(this, arguments);
4655 // %TypedArray% ( buffer, byteOffset=0, length=undefined )
4656 if (arguments.length >= 1 &&
4657 Type(arguments[0]) === 'object' &&
4658 (arguments[0] instanceof ArrayBuffer || Class(arguments[0]) === 'ArrayBuffer')) {
4659 return (function(buffer, byteOffset, length) {
4661 byteOffset = ToUint32(byteOffset);
4662 if (byteOffset > buffer.byteLength)
4663 throw RangeError('byteOffset out of range');
4665 // The given byteOffset must be a multiple of the element
4666 // size of the specific type, otherwise an exception is raised.
4667 if (byteOffset % this.BYTES_PER_ELEMENT)
4668 throw RangeError('buffer length minus the byteOffset is not a multiple of the element size.');
4670 if (length === undefined) {
4671 var byteLength = buffer.byteLength - byteOffset;
4672 if (byteLength % this.BYTES_PER_ELEMENT)
4673 throw RangeError('length of buffer minus byteOffset not a multiple of the element size');
4674 length = byteLength / this.BYTES_PER_ELEMENT;
4677 length = ToUint32(length);
4678 byteLength = length * this.BYTES_PER_ELEMENT;
4681 if ((byteOffset + byteLength) > buffer.byteLength)
4682 throw RangeError('byteOffset and length reference an area beyond the end of the buffer');
4684 Object.defineProperty(this, 'buffer', {value: buffer});
4685 Object.defineProperty(this, 'byteLength', {value: byteLength});
4686 Object.defineProperty(this, 'byteOffset', {value: byteOffset});
4687 Object.defineProperty(this, 'length', {value: length});
4689 }).apply(this, arguments);
4692 // %TypedArray% ( all other argument combinations )
4696 // Properties of the %TypedArray Instrinsic Object
4698 // %TypedArray%.from ( source , mapfn=undefined, thisArg=undefined )
4699 Object.defineProperty($TypedArray$, 'from', {value: function(iterable) {
4700 return new this(iterable);
4703 // %TypedArray%.of ( ...items )
4704 Object.defineProperty($TypedArray$, 'of', {value: function(/*...items*/) {
4705 return new this(arguments);
4708 // %TypedArray%.prototype
4709 var $TypedArrayPrototype$ = {};
4710 $TypedArray$.prototype = $TypedArrayPrototype$;
4712 // WebIDL: getter type (unsigned long index);
4713 Object.defineProperty($TypedArray$.prototype, '_getter', {value: function(index) {
4714 if (arguments.length < 1) throw SyntaxError('Not enough arguments');
4716 index = ToUint32(index);
4717 if (index >= this.length)
4720 var bytes = [], i, o;
4721 for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT;
4722 i < this.BYTES_PER_ELEMENT;
4724 bytes.push(this.buffer._bytes[o]);
4726 return this._unpack(bytes);
4729 // NONSTANDARD: convenience alias for getter: type get(unsigned long index);
4730 Object.defineProperty($TypedArray$.prototype, 'get', {value: $TypedArray$.prototype._getter});
4732 // WebIDL: setter void (unsigned long index, type value);
4733 Object.defineProperty($TypedArray$.prototype, '_setter', {value: function(index, value) {
4734 if (arguments.length < 2) throw SyntaxError('Not enough arguments');
4736 index = ToUint32(index);
4737 if (index >= this.length)
4740 var bytes = this._pack(value), i, o;
4741 for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT;
4742 i < this.BYTES_PER_ELEMENT;
4744 this.buffer._bytes[o] = bytes[i];
4748 // get %TypedArray%.prototype.buffer
4749 // get %TypedArray%.prototype.byteLength
4750 // get %TypedArray%.prototype.byteOffset
4751 // -- applied directly to the object in the constructor
4753 // %TypedArray%.prototype.constructor
4754 Object.defineProperty($TypedArray$.prototype, 'constructor', {value: $TypedArray$});
4756 // %TypedArray%.prototype.copyWithin (target, start, end = this.length )
4757 Object.defineProperty($TypedArray$.prototype, 'copyWithin', {value: function(target, start) {
4758 var end = arguments[2];
4760 var o = ToObject(this);
4761 var lenVal = o.length;
4762 var len = ToUint32(lenVal);
4764 var relativeTarget = ToInt32(target);
4766 if (relativeTarget < 0)
4767 to = max(len + relativeTarget, 0);
4769 to = min(relativeTarget, len);
4770 var relativeStart = ToInt32(start);
4772 if (relativeStart < 0)
4773 from = max(len + relativeStart, 0);
4775 from = min(relativeStart, len);
4777 if (end === undefined)
4780 relativeEnd = ToInt32(end);
4782 if (relativeEnd < 0)
4783 final = max(len + relativeEnd, 0);
4785 final = min(relativeEnd, len);
4786 var count = min(final - from, len - to);
4788 if (from < to && to < from + count) {
4790 from = from + count - 1;
4791 to = to + count - 1;
4796 o._setter(to, o._getter(from));
4797 from = from + direction;
4798 to = to + direction;
4804 // %TypedArray%.prototype.entries ( )
4805 // -- defined in es6.js to shim browsers w/ native TypedArrays
4807 // %TypedArray%.prototype.every ( callbackfn, thisArg = undefined )
4808 Object.defineProperty($TypedArray$.prototype, 'every', {value: function(callbackfn) {
4809 if (this === undefined || this === null) throw TypeError();
4810 var t = Object(this);
4811 var len = ToUint32(t.length);
4812 if (!IsCallable(callbackfn)) throw TypeError();
4813 var thisArg = arguments[1];
4814 for (var i = 0; i < len; i++) {
4815 if (!callbackfn.call(thisArg, t._getter(i), i, t))
4821 // %TypedArray%.prototype.fill (value, start = 0, end = this.length )
4822 Object.defineProperty($TypedArray$.prototype, 'fill', {value: function(value) {
4823 var start = arguments[1],
4826 var o = ToObject(this);
4827 var lenVal = o.length;
4828 var len = ToUint32(lenVal);
4830 var relativeStart = ToInt32(start);
4832 if (relativeStart < 0)
4833 k = max((len + relativeStart), 0);
4835 k = min(relativeStart, len);
4837 if (end === undefined)
4840 relativeEnd = ToInt32(end);
4842 if (relativeEnd < 0)
4843 final = max((len + relativeEnd), 0);
4845 final = min(relativeEnd, len);
4847 o._setter(k, value);
4853 // %TypedArray%.prototype.filter ( callbackfn, thisArg = undefined )
4854 Object.defineProperty($TypedArray$.prototype, 'filter', {value: function(callbackfn) {
4855 if (this === undefined || this === null) throw TypeError();
4856 var t = Object(this);
4857 var len = ToUint32(t.length);
4858 if (!IsCallable(callbackfn)) throw TypeError();
4860 var thisp = arguments[1];
4861 for (var i = 0; i < len; i++) {
4862 var val = t._getter(i); // in case fun mutates this
4863 if (callbackfn.call(thisp, val, i, t))
4866 return new this.constructor(res);
4869 // %TypedArray%.prototype.find (predicate, thisArg = undefined)
4870 Object.defineProperty($TypedArray$.prototype, 'find', {value: function(predicate) {
4871 var o = ToObject(this);
4872 var lenValue = o.length;
4873 var len = ToUint32(lenValue);
4874 if (!IsCallable(predicate)) throw TypeError();
4875 var t = arguments.length > 1 ? arguments[1] : undefined;
4878 var kValue = o._getter(k);
4879 var testResult = predicate.call(t, kValue, k, o);
4880 if (Boolean(testResult))
4887 // %TypedArray%.prototype.findIndex ( predicate, thisArg = undefined )
4888 Object.defineProperty($TypedArray$.prototype, 'findIndex', {value: function(predicate) {
4889 var o = ToObject(this);
4890 var lenValue = o.length;
4891 var len = ToUint32(lenValue);
4892 if (!IsCallable(predicate)) throw TypeError();
4893 var t = arguments.length > 1 ? arguments[1] : undefined;
4896 var kValue = o._getter(k);
4897 var testResult = predicate.call(t, kValue, k, o);
4898 if (Boolean(testResult))
4905 // %TypedArray%.prototype.forEach ( callbackfn, thisArg = undefined )
4906 Object.defineProperty($TypedArray$.prototype, 'forEach', {value: function(callbackfn) {
4907 if (this === undefined || this === null) throw TypeError();
4908 var t = Object(this);
4909 var len = ToUint32(t.length);
4910 if (!IsCallable(callbackfn)) throw TypeError();
4911 var thisp = arguments[1];
4912 for (var i = 0; i < len; i++)
4913 callbackfn.call(thisp, t._getter(i), i, t);
4916 // %TypedArray%.prototype.indexOf (searchElement, fromIndex = 0 )
4917 Object.defineProperty($TypedArray$.prototype, 'indexOf', {value: function(searchElement) {
4918 if (this === undefined || this === null) throw TypeError();
4919 var t = Object(this);
4920 var len = ToUint32(t.length);
4921 if (len === 0) return -1;
4923 if (arguments.length > 0) {
4924 n = Number(arguments[1]);
4927 } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
4928 n = (n > 0 || -1) * floor(abs(n));
4931 if (n >= len) return -1;
4932 var k = n >= 0 ? n : max(len - abs(n), 0);
4933 for (; k < len; k++) {
4934 if (t._getter(k) === searchElement) {
4941 // %TypedArray%.prototype.join ( separator )
4942 Object.defineProperty($TypedArray$.prototype, 'join', {value: function(separator) {
4943 if (this === undefined || this === null) throw TypeError();
4944 var t = Object(this);
4945 var len = ToUint32(t.length);
4946 var tmp = Array(len);
4947 for (var i = 0; i < len; ++i)
4948 tmp[i] = t._getter(i);
4949 return tmp.join(separator === undefined ? ',' : separator); // Hack for IE7
4952 // %TypedArray%.prototype.keys ( )
4953 // -- defined in es6.js to shim browsers w/ native TypedArrays
4955 // %TypedArray%.prototype.lastIndexOf ( searchElement, fromIndex = this.length-1 )
4956 Object.defineProperty($TypedArray$.prototype, 'lastIndexOf', {value: function(searchElement) {
4957 if (this === undefined || this === null) throw TypeError();
4958 var t = Object(this);
4959 var len = ToUint32(t.length);
4960 if (len === 0) return -1;
4962 if (arguments.length > 1) {
4963 n = Number(arguments[1]);
4966 } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
4967 n = (n > 0 || -1) * floor(abs(n));
4970 var k = n >= 0 ? min(n, len - 1) : len - abs(n);
4971 for (; k >= 0; k--) {
4972 if (t._getter(k) === searchElement)
4978 // get %TypedArray%.prototype.length
4979 // -- applied directly to the object in the constructor
4981 // %TypedArray%.prototype.map ( callbackfn, thisArg = undefined )
4982 Object.defineProperty($TypedArray$.prototype, 'map', {value: function(callbackfn) {
4983 if (this === undefined || this === null) throw TypeError();
4984 var t = Object(this);
4985 var len = ToUint32(t.length);
4986 if (!IsCallable(callbackfn)) throw TypeError();
4987 var res = []; res.length = len;
4988 var thisp = arguments[1];
4989 for (var i = 0; i < len; i++)
4990 res[i] = callbackfn.call(thisp, t._getter(i), i, t);
4991 return new this.constructor(res);
4994 // %TypedArray%.prototype.reduce ( callbackfn [, initialValue] )
4995 Object.defineProperty($TypedArray$.prototype, 'reduce', {value: function(callbackfn) {
4996 if (this === undefined || this === null) throw TypeError();
4997 var t = Object(this);
4998 var len = ToUint32(t.length);
4999 if (!IsCallable(callbackfn)) throw TypeError();
5000 // no value to return if no initial value and an empty array
5001 if (len === 0 && arguments.length === 1) throw TypeError();
5004 if (arguments.length >= 2) {
5005 accumulator = arguments[1];
5007 accumulator = t._getter(k++);
5010 accumulator = callbackfn.call(undefined, accumulator, t._getter(k), k, t);
5016 // %TypedArray%.prototype.reduceRight ( callbackfn [, initialValue] )
5017 Object.defineProperty($TypedArray$.prototype, 'reduceRight', {value: function(callbackfn) {
5018 if (this === undefined || this === null) throw TypeError();
5019 var t = Object(this);
5020 var len = ToUint32(t.length);
5021 if (!IsCallable(callbackfn)) throw TypeError();
5022 // no value to return if no initial value, empty array
5023 if (len === 0 && arguments.length === 1) throw TypeError();
5026 if (arguments.length >= 2) {
5027 accumulator = arguments[1];
5029 accumulator = t._getter(k--);
5032 accumulator = callbackfn.call(undefined, accumulator, t._getter(k), k, t);
5038 // %TypedArray%.prototype.reverse ( )
5039 Object.defineProperty($TypedArray$.prototype, 'reverse', {value: function() {
5040 if (this === undefined || this === null) throw TypeError();
5041 var t = Object(this);
5042 var len = ToUint32(t.length);
5043 var half = floor(len / 2);
5044 for (var i = 0, j = len - 1; i < half; ++i, --j) {
5045 var tmp = t._getter(i);
5046 t._setter(i, t._getter(j));
5052 // %TypedArray%.prototype.set(array, offset = 0 )
5053 // %TypedArray%.prototype.set(typedArray, offset = 0 )
5054 // WebIDL: void set(TypedArray array, optional unsigned long offset);
5055 // WebIDL: void set(sequence<type> array, optional unsigned long offset);
5056 Object.defineProperty($TypedArray$.prototype, 'set', {value: function(index, value) {
5057 if (arguments.length < 1) throw SyntaxError('Not enough arguments');
5058 var array, sequence, offset, len,
5060 byteOffset, byteLength, tmp;
5062 if (typeof arguments[0] === 'object' && arguments[0].constructor === this.constructor) {
5063 // void set(TypedArray array, optional unsigned long offset);
5064 array = arguments[0];
5065 offset = ToUint32(arguments[1]);
5067 if (offset + array.length > this.length) {
5068 throw RangeError('Offset plus length of array is out of range');
5071 byteOffset = this.byteOffset + offset * this.BYTES_PER_ELEMENT;
5072 byteLength = array.length * this.BYTES_PER_ELEMENT;
5074 if (array.buffer === this.buffer) {
5076 for (i = 0, s = array.byteOffset; i < byteLength; i += 1, s += 1) {
5077 tmp[i] = array.buffer._bytes[s];
5079 for (i = 0, d = byteOffset; i < byteLength; i += 1, d += 1) {
5080 this.buffer._bytes[d] = tmp[i];
5083 for (i = 0, s = array.byteOffset, d = byteOffset;
5084 i < byteLength; i += 1, s += 1, d += 1) {
5085 this.buffer._bytes[d] = array.buffer._bytes[s];
5088 } else if (typeof arguments[0] === 'object' && typeof arguments[0].length !== 'undefined') {
5089 // void set(sequence<type> array, optional unsigned long offset);
5090 sequence = arguments[0];
5091 len = ToUint32(sequence.length);
5092 offset = ToUint32(arguments[1]);
5094 if (offset + len > this.length) {
5095 throw RangeError('Offset plus length of array is out of range');
5098 for (i = 0; i < len; i += 1) {
5100 this._setter(offset + i, Number(s));
5103 throw TypeError('Unexpected argument type(s)');
5107 // %TypedArray%.prototype.slice ( start, end )
5108 Object.defineProperty($TypedArray$.prototype, 'slice', {value: function(start, end) {
5109 var o = ToObject(this);
5110 var lenVal = o.length;
5111 var len = ToUint32(lenVal);
5112 var relativeStart = ToInt32(start);
5113 var k = (relativeStart < 0) ? max(len + relativeStart, 0) : min(relativeStart, len);
5114 var relativeEnd = (end === undefined) ? len : ToInt32(end);
5115 var final = (relativeEnd < 0) ? max(len + relativeEnd, 0) : min(relativeEnd, len);
5116 var count = final - k;
5117 var c = o.constructor;
5118 var a = new c(count);
5121 var kValue = o._getter(k);
5122 a._setter(n, kValue);
5129 // %TypedArray%.prototype.some ( callbackfn, thisArg = undefined )
5130 Object.defineProperty($TypedArray$.prototype, 'some', {value: function(callbackfn) {
5131 if (this === undefined || this === null) throw TypeError();
5132 var t = Object(this);
5133 var len = ToUint32(t.length);
5134 if (!IsCallable(callbackfn)) throw TypeError();
5135 var thisp = arguments[1];
5136 for (var i = 0; i < len; i++) {
5137 if (callbackfn.call(thisp, t._getter(i), i, t)) {
5144 // %TypedArray%.prototype.sort ( comparefn )
5145 Object.defineProperty($TypedArray$.prototype, 'sort', {value: function(comparefn) {
5146 if (this === undefined || this === null) throw TypeError();
5147 var t = Object(this);
5148 var len = ToUint32(t.length);
5149 var tmp = Array(len);
5150 for (var i = 0; i < len; ++i)
5151 tmp[i] = t._getter(i);
5152 function sortCompare(x, y) {
5153 if (x !== x && y !== y) return +0;
5154 if (x !== x) return 1;
5155 if (y !== y) return -1;
5156 if (comparefn !== undefined) {
5157 return comparefn(x, y);
5159 if (x < y) return -1;
5160 if (x > y) return 1;
5163 tmp.sort(sortCompare);
5164 for (i = 0; i < len; ++i)
5165 t._setter(i, tmp[i]);
5169 // %TypedArray%.prototype.subarray(begin = 0, end = this.length )
5170 // WebIDL: TypedArray subarray(long begin, optional long end);
5171 Object.defineProperty($TypedArray$.prototype, 'subarray', {value: function(start, end) {
5172 function clamp(v, min, max) { return v < min ? min : v > max ? max : v; }
5174 start = ToInt32(start);
5177 if (arguments.length < 1) { start = 0; }
5178 if (arguments.length < 2) { end = this.length; }
5180 if (start < 0) { start = this.length + start; }
5181 if (end < 0) { end = this.length + end; }
5183 start = clamp(start, 0, this.length);
5184 end = clamp(end, 0, this.length);
5186 var len = end - start;
5191 return new this.constructor(
5192 this.buffer, this.byteOffset + start * this.BYTES_PER_ELEMENT, len);
5195 // %TypedArray%.prototype.toLocaleString ( )
5196 // %TypedArray%.prototype.toString ( )
5197 // %TypedArray%.prototype.values ( )
5198 // %TypedArray%.prototype [ @@iterator ] ( )
5199 // get %TypedArray%.prototype [ @@toStringTag ]
5200 // -- defined in es6.js to shim browsers w/ native TypedArrays
5202 function makeTypedArray(elementSize, pack, unpack) {
5203 // Each TypedArray type requires a distinct constructor instance with
5204 // identical logic, which this produces.
5205 var TypedArray = function() {
5206 Object.defineProperty(this, 'constructor', {value: TypedArray});
5207 $TypedArray$.apply(this, arguments);
5208 makeArrayAccessors(this);
5210 if ('__proto__' in TypedArray) {
5211 TypedArray.__proto__ = $TypedArray$;
5213 TypedArray.from = $TypedArray$.from;
5214 TypedArray.of = $TypedArray$.of;
5217 TypedArray.BYTES_PER_ELEMENT = elementSize;
5219 var TypedArrayPrototype = function() {};
5220 TypedArrayPrototype.prototype = $TypedArrayPrototype$;
5222 TypedArray.prototype = new TypedArrayPrototype();
5224 Object.defineProperty(TypedArray.prototype, 'BYTES_PER_ELEMENT', {value: elementSize});
5225 Object.defineProperty(TypedArray.prototype, '_pack', {value: pack});
5226 Object.defineProperty(TypedArray.prototype, '_unpack', {value: unpack});
5231 var Int8Array = makeTypedArray(1, packI8, unpackI8);
5232 var Uint8Array = makeTypedArray(1, packU8, unpackU8);
5233 var Uint8ClampedArray = makeTypedArray(1, packU8Clamped, unpackU8);
5234 var Int16Array = makeTypedArray(2, packI16, unpackI16);
5235 var Uint16Array = makeTypedArray(2, packU16, unpackU16);
5236 var Int32Array = makeTypedArray(4, packI32, unpackI32);
5237 var Uint32Array = makeTypedArray(4, packU32, unpackU32);
5238 var Float32Array = makeTypedArray(4, packF32, unpackF32);
5239 var Float64Array = makeTypedArray(8, packF64, unpackF64);
5241 global.Int8Array = global.Int8Array || Int8Array;
5242 global.Uint8Array = global.Uint8Array || Uint8Array;
5243 global.Uint8ClampedArray = global.Uint8ClampedArray || Uint8ClampedArray;
5244 global.Int16Array = global.Int16Array || Int16Array;
5245 global.Uint16Array = global.Uint16Array || Uint16Array;
5246 global.Int32Array = global.Int32Array || Int32Array;
5247 global.Uint32Array = global.Uint32Array || Uint32Array;
5248 global.Float32Array = global.Float32Array || Float32Array;
5249 global.Float64Array = global.Float64Array || Float64Array;
5253 // 6 The DataView View Type
5257 function r(array, index) {
5258 return IsCallable(array.get) ? array.get(index) : array[index];
5261 var IS_BIG_ENDIAN = (function() {
5262 var u16array = new Uint16Array([0x1234]),
5263 u8array = new Uint8Array(u16array.buffer);
5264 return r(u8array, 0) === 0x12;
5267 // DataView(buffer, byteOffset=0, byteLength=undefined)
5268 // WebIDL: Constructor(ArrayBuffer buffer,
5269 // optional unsigned long byteOffset,
5270 // optional unsigned long byteLength)
5271 function DataView(buffer, byteOffset, byteLength) {
5272 if (!(buffer instanceof ArrayBuffer || Class(buffer) === 'ArrayBuffer')) throw TypeError();
5274 byteOffset = ToUint32(byteOffset);
5275 if (byteOffset > buffer.byteLength)
5276 throw RangeError('byteOffset out of range');
5278 if (byteLength === undefined)
5279 byteLength = buffer.byteLength - byteOffset;
5281 byteLength = ToUint32(byteLength);
5283 if ((byteOffset + byteLength) > buffer.byteLength)
5284 throw RangeError('byteOffset and length reference an area beyond the end of the buffer');
5286 Object.defineProperty(this, 'buffer', {value: buffer});
5287 Object.defineProperty(this, 'byteLength', {value: byteLength});
5288 Object.defineProperty(this, 'byteOffset', {value: byteOffset});
5291 // get DataView.prototype.buffer
5292 // get DataView.prototype.byteLength
5293 // get DataView.prototype.byteOffset
5294 // -- applied directly to instances by the constructor
5296 function makeGetter(arrayType) {
5297 return function GetViewValue(byteOffset, littleEndian) {
5298 byteOffset = ToUint32(byteOffset);
5300 if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength)
5301 throw RangeError('Array index out of range');
5303 byteOffset += this.byteOffset;
5305 var uint8Array = new Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT),
5307 for (var i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1)
5308 bytes.push(r(uint8Array, i));
5310 if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN))
5313 return r(new arrayType(new Uint8Array(bytes).buffer), 0);
5317 Object.defineProperty(DataView.prototype, 'getUint8', {value: makeGetter(Uint8Array)});
5318 Object.defineProperty(DataView.prototype, 'getInt8', {value: makeGetter(Int8Array)});
5319 Object.defineProperty(DataView.prototype, 'getUint16', {value: makeGetter(Uint16Array)});
5320 Object.defineProperty(DataView.prototype, 'getInt16', {value: makeGetter(Int16Array)});
5321 Object.defineProperty(DataView.prototype, 'getUint32', {value: makeGetter(Uint32Array)});
5322 Object.defineProperty(DataView.prototype, 'getInt32', {value: makeGetter(Int32Array)});
5323 Object.defineProperty(DataView.prototype, 'getFloat32', {value: makeGetter(Float32Array)});
5324 Object.defineProperty(DataView.prototype, 'getFloat64', {value: makeGetter(Float64Array)});
5326 function makeSetter(arrayType) {
5327 return function SetViewValue(byteOffset, value, littleEndian) {
5328 byteOffset = ToUint32(byteOffset);
5329 if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength)
5330 throw RangeError('Array index out of range');
5333 var typeArray = new arrayType([value]),
5334 byteArray = new Uint8Array(typeArray.buffer),
5335 bytes = [], i, byteView;
5337 for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1)
5338 bytes.push(r(byteArray, i));
5340 // Flip if necessary
5341 if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN))
5345 byteView = new Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT);
5346 byteView.set(bytes);
5350 Object.defineProperty(DataView.prototype, 'setUint8', {value: makeSetter(Uint8Array)});
5351 Object.defineProperty(DataView.prototype, 'setInt8', {value: makeSetter(Int8Array)});
5352 Object.defineProperty(DataView.prototype, 'setUint16', {value: makeSetter(Uint16Array)});
5353 Object.defineProperty(DataView.prototype, 'setInt16', {value: makeSetter(Int16Array)});
5354 Object.defineProperty(DataView.prototype, 'setUint32', {value: makeSetter(Uint32Array)});
5355 Object.defineProperty(DataView.prototype, 'setInt32', {value: makeSetter(Int32Array)});
5356 Object.defineProperty(DataView.prototype, 'setFloat32', {value: makeSetter(Float32Array)});
5357 Object.defineProperty(DataView.prototype, 'setFloat64', {value: makeSetter(Float64Array)});
5359 global.DataView = global.DataView || DataView;
5364 if (!('fround' in Math)) {
5367 /* global Float32Array */
5368 // 20.2.2.17 Math.fround ( x )
5369 CreateMethodProperty(Math, 'fround', function (x) {
5370 // 1. If x is NaN, return NaN.
5374 // 2. If x is one of +0, -0, +∞, -∞, return x.
5375 if (1 / x === +Infinity || 1 / x === -Infinity || x === +Infinity || x === -Infinity) {
5378 // 3. Let x32 be the result of converting x to a value in IEEE 754-2008 binary32 format using roundTiesToEven.
5379 // 4. Let x64 be the result of converting x32 to a value in IEEE 754-2008 binary64 format.
5380 // 5. Return the ECMAScript Number value corresponding to x64.
5381 return (new Float32Array([x]))[0];
5386 if (!('hypot' in Math)) {
5389 /* global CreateMethodProperty */
5390 // 20.2.2.18. Math.hypot ( value1, value2, ...values )
5391 CreateMethodProperty(Math, 'hypot', function hypot(value1, value2) { // eslint-disable-line no-unused-vars
5392 // If no arguments are passed, the result is +0.
5393 if (arguments.length === 0) {
5398 for (var i = 0; i < arguments.length; ++i) {
5399 // If any argument is +∞, the result is +∞.
5400 if (arguments[i] === Infinity) {
5404 // If any argument is -∞, the result is +∞.
5405 if (arguments[i] === -Infinity) {
5409 // If no argument is +∞ or -∞, and any argument is NaN, the result is NaN.
5410 // If all arguments are either +0 or -0, the result is +0.
5411 // Polyfill.io - The two conditions above are handled in the math.
5413 var arg = Math.abs(Number(arguments[i]));
5415 y = y * Math.pow(max / arg, 2);
5418 if (arg !== 0 || max !== 0) {
5419 y = y + Math.pow(arg / max, 2);
5423 return max * Math.sqrt(y);
5428 if (!('imul' in Math)) {
5431 /* global CreateMethodProperty, ToUint32 */
5432 // 20.2.2.19. Math.imul ( x, y )
5433 CreateMethodProperty(Math, 'imul', function imul(x, y) {
5434 // 1. Let a be ToUint32(x).
5435 var a = ToUint32(x);
5436 // 2. Let b be ToUint32(y).
5437 var b = ToUint32(y);
5438 // 3. Let product be (a × b) modulo 2^32.
5439 var product = (a * b) % Math.pow(2, 32);
5440 // 4. If product ≥ 2^31, return product - 2^32; otherwise return product.
5441 return (product >= Math.pow(2, 31)) ? product - Math.pow(2, 32) : product;
5446 if (!('log10' in Math)) {
5449 /* global CreateMethodProperty */
5450 // 20.2.2.22. Math.log10 ( x )
5451 CreateMethodProperty(Math, 'log10', function log10(x) {
5452 return Math.log(x) / Math.LN10;
5457 if (!('log1p' in Math)) {
5460 /* global CreateMethodProperty */
5461 // 20.2.2.21. Math.log1p ( x )
5462 CreateMethodProperty(Math, 'log1p', function log1p(x) {
5463 return Math.log(1 + x);
5468 if (!('log2' in Math)) {
5471 /* global CreateMethodProperty */
5472 // 20.2.2.23. Math.log2 ( x )
5473 CreateMethodProperty(Math, 'log2', function log2(x) {
5474 return Math.log(x) / Math.LN2;
5479 if (!('sign' in Math)) {
5482 /* global CreateMethodProperty */
5483 // 20.2.2.29. Math.sign ( x )
5484 CreateMethodProperty(Math, 'sign', function sign(x) {
5486 // If x is NaN, the result is NaN.
5490 // If x is -0, the result is -0.
5491 if (1 / x === -Infinity) {
5494 // If x is +0, the result is +0.
5495 if (1 / x === Infinity) {
5498 // If x is negative and not -0, the result is -1.
5502 // If x is positive and not +0, the result is +1.
5510 if (!('sinh' in Math)) {
5513 /* global CreateMethodProperty */
5514 // 20.2.2.31. Math.sinh ( x )
5515 CreateMethodProperty(Math, 'sinh', function sinh(x) {
5516 var s = (x < 0) ? -1 : 1;
5517 var absx = Math.abs(x);
5519 if (absx < Math.pow(2, -28)) {
5522 var t = Math.exp(absx) - 1;
5524 return (s * (2 * t - t * t / (t + 1)))/2;
5526 return (s * (t + t / (t + 1)))/2;
5528 if (absx < 709.7822265625) {
5529 return (s * Math.exp(absx))/2;
5531 var w = Math.exp(0.5 * absx);
5538 if (!('tanh' in Math)) {
5541 /* global CreateMethodProperty */
5542 // 20.2.2.34. Math.tanh ( x )
5543 CreateMethodProperty(Math, 'tanh', function tanh(x) {
5546 return x === Infinity ? 1 : x === -Infinity ? -1 : (y = Math.exp(2 * x), (y - 1) / (y + 1));
5551 if (!('trunc' in Math)) {
5554 /* global CreateMethodProperty */
5555 CreateMethodProperty(Math, 'trunc', function trunc(x) {
5556 return x < 0 ? Math.ceil(x) : Math.floor(x);
5561 if (!('EPSILON' in Number)) {
5564 // 20.1.2.1. Number.EPSILON
5565 // The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 that is representable as a Number value, which is approximately 2.2204460492503130808472633361816 x 10-16.
5566 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
5567 Object.defineProperty(Number, 'EPSILON', {
5569 configurable: false,
5571 value: Math.pow(2, -52)
5576 if (!('MAX_SAFE_INTEGER' in Number)) {
5578 // Number.MAX_SAFE_INTEGER
5579 // 20.1.2.6. Number.MAX_SAFE_INTEGER
5580 // The value of Number.MAX_SAFE_INTEGER is 9007199254740991 (2^53-1).
5581 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
5582 Object.defineProperty(Number, 'MAX_SAFE_INTEGER', {
5584 configurable: false,
5586 value: Math.pow(2, 53) - 1
5591 if (!('MIN_SAFE_INTEGER' in Number)) {
5593 // Number.MIN_SAFE_INTEGER
5594 // 20.1.2.8. Number.MIN_SAFE_INTEGER
5595 // The value of Number.MIN_SAFE_INTEGER is -9007199254740991 (-(253-1)).
5596 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
5597 Object.defineProperty(Number, 'MIN_SAFE_INTEGER', {
5599 configurable: false,
5601 value: -(Math.pow(2, 53) - 1)
5606 if (!('isFinite' in Number)) {
5609 /* global CreateMethodProperty, Type */
5612 // 20.1.2.2. Number.isFinite ( number )
5613 CreateMethodProperty(Number, 'isFinite', function isFinite(number) {
5614 // 1. If Type(number) is not Number, return false.
5615 if (Type(number) !== 'number') {
5618 // 2. If number is NaN, +∞, or -∞, return false.
5619 // 3. Otherwise, return true.
5620 // Polyfill.io - We use isFinite as it implements steps 2 and 3.
5621 return that.isFinite(number);
5627 if (!('isInteger' in Number)) {
5630 /* global CreateMethodProperty, ToInteger, Type */
5631 // 20.1.2.3. Number.isInteger ( number )
5632 CreateMethodProperty(Number, 'isInteger', function isInteger(number) {
5633 // 1. If Type(number) is not Number, return false.
5634 if (Type(number) !== 'number') {
5637 // 2. If number is NaN, +∞, or -∞, return false.
5638 if (isNaN(number) || number === Infinity || number === -Infinity) {
5641 // 3. Let integer be ToInteger(number).
5642 var integer = ToInteger(number);
5643 // 4. If integer is not equal to number, return false.
5644 if (integer !== number) {
5647 // 5. Otherwise, return true.
5653 if (!('isNaN' in Number)) {
5656 /* global CreateMethodProperty, Type */
5659 // 20.1.2.4. Number.isNaN ( number )
5660 CreateMethodProperty(Number, 'isNaN', function isNaN(number) {
5661 // 1. If Type(number) is not Number, return false.
5662 if (Type(number) !== 'number') {
5665 // 2. If number is NaN, return true.
5666 if (that.isNaN(number)) {
5669 // 3. Otherwise, return false.
5676 if (!('isSafeInteger' in Number)) {
5678 // Number.isSafeInteger
5679 /* global CreateMethodProperty, Type, ToInteger */
5680 // 20.1.2.5. Number.isSafeInteger ( number )
5681 CreateMethodProperty(Number, 'isSafeInteger', function isSafeInteger(number) {
5682 // 1. If Type(number) is not Number, return false.
5683 if (Type(number) !== 'number') {
5686 // 2. If number is NaN, +∞, or -∞, return false.
5687 if (isNaN(number) || number === Infinity || number === -Infinity) {
5690 // 3. Let integer be ToInteger(number).
5691 var integer = ToInteger(number);
5692 // 4. If integer is not equal to number, return false.
5693 if (integer !== number) {
5696 // 5. If abs(integer) ≤ 2^53-1, return true.
5697 if (Math.abs(integer) <= (Math.pow(2, 53) - 1)) {
5700 // 6. Otherwise, return false.
5706 if (!('parseFloat' in Number)) {
5708 // Number.parseFloat
5709 /* global CreateMethodProperty */
5710 // 20.1.2.12. Number.parseFloat ( string )
5711 // The value of the Number.parseFloat data property is the same built-in function object that is the value of the parseFloat property of the global object defined in 18.2.4.
5712 CreateMethodProperty(Number, 'parseFloat', parseFloat);
5716 if (!('parseInt' in Number)) {
5719 /* global CreateMethodProperty */
5720 // 20.1.2.13. Number.parseInt ( string, radix )
5721 // The value of the Number.parseInt data property is the same built-in function object that is the value of the parseInt property of the global object defined in 18.2.5.
5722 CreateMethodProperty(Number, 'parseInt', parseInt);
5727 // _ESAbstract.SameValue
5728 /* global Type, SameValueNonNumber */
5729 // 7.2.10. SameValue ( x, y )
5730 function SameValue(x, y) { // eslint-disable-line no-unused-vars
5731 // 1. If Type(x) is different from Type(y), return false.
5732 if (Type(x) !== Type(y)) {
5735 // 2. If Type(x) is Number, then
5736 if (Type(x) === 'number') {
5737 // a. If x is NaN and y is NaN, return true.
5738 if (isNaN(x) && isNaN(y)) {
5741 // Polyfill.io - 0 === -0 is true, but they are not the same value.
5742 // b. If x is +0 and y is -0, return false.
5743 // c. If x is -0 and y is +0, return false.
5744 if (x === 0 && y === 0 && 1/x !== 1/y) {
5747 // d. If x is the same Number value as y, return true.
5754 // 3. Return SameValueNonNumber(x, y).
5755 return SameValueNonNumber(x, y);
5757 if (!('is' in Object)) {
5760 /* global CreateMethodProperty, SameValue */
5761 // 19.1.2.12. Object.is ( value1, value2 )
5762 CreateMethodProperty(Object, 'is', function is(value1, value2) {
5763 // 1. Return SameValue(value1, value2).
5764 return SameValue(value1, value2);
5769 if (!('Promise' in this)) {
5772 !function(n){function t(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var e={};t.m=n,t.c=e,t.i=function(n){return n},t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:r})},t.n=function(n){var e=n&&n.__esModule?function(){return n["default"]}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},t.p="",t(t.s=100)}({100:/*!***********************!*\
5773 !*** ./src/global.js ***!
5774 \***********************/
5775 function(n,t,e){(function(n){var t=e(/*! ./yaku */5);try{n.Promise=t,window.Promise=t}catch(r){}}).call(t,e(/*! ./../~/webpack/buildin/global.js */2))},2:/*!***********************************!*\
5776 !*** (webpack)/buildin/global.js ***!
5777 \***********************************/
5778 function(n,t){var e;e=function(){return this}();try{e=e||Function("return this")()||(0,eval)("this")}catch(r){"object"==typeof window&&(e=window)}n.exports=e},5:/*!*********************!*\
5779 !*** ./src/yaku.js ***!
5780 \*********************/
5781 function(n,t,e){(function(t){!function(){"use strict";function e(){return rn[q][B]||D}function r(n){return n&&"object"==typeof n}function o(n){return"function"==typeof n}function i(n,t){return n instanceof t}function u(n){return i(n,M)}function c(n,t,e){if(!t(n))throw h(e)}function f(){try{return R.apply(S,arguments)}catch(n){return nn.e=n,nn}}function s(n,t){return R=n,S=t,f}function a(n,t){function e(){for(var e=0;e<o;)t(r[e],r[e+1]),r[e++]=P,r[e++]=P;o=0,r.length>n&&(r.length=n)}var r=A(n),o=0;return function(n,t){r[o++]=n,r[o++]=t,2===o&&rn.nextTick(e)}}function l(n,t){var e,r,u,c,f=0;if(!n)throw h(Q);var a=n[rn[q][z]];if(o(a))r=a.call(n);else{if(!o(n.next)){if(i(n,A)){for(e=n.length;f<e;)t(n[f],f++);return f}throw h(Q)}r=n}for(;!(u=r.next()).done;)if((c=s(t)(u.value,f++))===nn)throw o(r[G])&&r[G](),c.e;return f}function h(n){return new TypeError(n)}function v(n){return(n?"":V)+(new M).stack}function _(n,t){var e="on"+n.toLowerCase(),r=O[e];H&&H.listeners(n).length?n===Z?H.emit(n,t._v,t):H.emit(n,t):r?r({reason:t._v,promise:t}):rn[n](t._v,t)}function p(n){return n&&n._s}function d(n){if(p(n))return new n(tn);var t,e,r;return t=new n(function(n,o){if(t)throw h();e=n,r=o}),c(e,o),c(r,o),t}function w(n,t){var e=!1;return function(r){e||(e=!0,L&&(n[N]=v(!0)),t===Y?k(n,r):x(n,t,r))}}function y(n,t,e,r){return o(e)&&(t._onFulfilled=e),o(r)&&(n[J]&&_(X,n),t._onRejected=r),L&&(t._p=n),n[n._c++]=t,n._s!==$&&on(n,t),t}function m(n){if(n._umark)return!0;n._umark=!0;for(var t,e=0,r=n._c;e<r;)if(t=n[e++],t._onRejected||m(t))return!0}function j(n,t){function e(n){return r.push(n.replace(/^\s+|\s+$/g,""))}var r=[];return L&&(t[N]&&e(t[N]),function o(n){n&&K in n&&(o(n._next),e(n[K]+""),o(n._p))}(t)),(n&&n.stack?n.stack:n)+("\n"+r.join("\n")).replace(en,"")}function g(n,t){return n(t)}function x(n,t,e){var r=0,o=n._c;if(n._s===$)for(n._s=t,n._v=e,t===U&&(L&&u(e)&&(e.longStack=j(e,n)),un(n));r<o;)on(n,n[r++]);return n}function k(n,t){if(t===n&&t)return x(n,U,h(W)),n;if(t!==C&&(o(t)||r(t))){var e=s(b)(t);if(e===nn)return x(n,U,e.e),n;o(e)?(L&&p(t)&&(n._next=t),p(t)?T(n,t,e):rn.nextTick(function(){T(n,t,e)})):x(n,Y,t)}else x(n,Y,t);return n}function b(n){return n.then}function T(n,t,e){var r=s(e,t)(function(e){t&&(t=C,k(n,e))},function(e){t&&(t=C,x(n,U,e))});r===nn&&t&&(x(n,U,r.e),t=C)}var P,R,S,C=null,F="object"==typeof self,O=F?self:t,E=O.Promise,H=O.process,I=O.console,L=!1,A=Array,M=Error,U=1,Y=2,$=3,q="Symbol",z="iterator",B="species",D=q+"("+B+")",G="return",J="_uh",K="_pt",N="_st",Q="Invalid argument",V="\nFrom previous ",W="Chaining cycle detected for promise",X="rejectionHandled",Z="unhandledRejection",nn={e:C},tn=function(){},en=/^.+\/node_modules\/yaku\/.+\n?/gm,rn=function(n){var t,e=this;if(!r(e)||e._s!==P)throw h("Invalid this");if(e._s=$,L&&(e[K]=v()),n!==tn){if(!o(n))throw h(Q);t=s(n)(w(e,Y),w(e,U)),t===nn&&x(e,U,t.e)}};rn["default"]=rn,function(n,t){for(var e in t)n[e]=t[e]}(rn.prototype,{then:function(n,t){if(this._s===undefined)throw h();return y(this,d(rn.speciesConstructor(this,rn)),n,t)},"catch":function(n){return this.then(P,n)},"finally":function(n){return this.then(function(t){return rn.resolve(n()).then(function(){return t})},function(t){return rn.resolve(n()).then(function(){throw t})})},_c:0,_p:C}),rn.resolve=function(n){return p(n)?n:k(d(this),n)},rn.reject=function(n){return x(d(this),U,n)},rn.race=function(n){var t=this,e=d(t),r=function(n){x(e,Y,n)},o=function(n){x(e,U,n)},i=s(l)(n,function(n){t.resolve(n).then(r,o)});return i===nn?t.reject(i.e):e},rn.all=function(n){function t(n){x(o,U,n)}var e,r=this,o=d(r),i=[];return(e=s(l)(n,function(n,u){r.resolve(n).then(function(n){i[u]=n,--e||x(o,Y,i)},t)}))===nn?r.reject(e.e):(e||x(o,Y,[]),o)},rn.Symbol=O[q]||{},s(function(){Object.defineProperty(rn,e(),{get:function(){return this}})})(),rn.speciesConstructor=function(n,t){var r=n.constructor;return r?r[e()]||t:t},rn.unhandledRejection=function(n,t){I&&I.error("Uncaught (in promise)",L?t.longStack:j(n,t))},rn.rejectionHandled=tn,rn.enableLongStackTrace=function(){L=!0},rn.nextTick=F?function(n){E?new E(function(n){n()}).then(n):setTimeout(n)}:H.nextTick,rn._s=1;var on=a(999,function(n,t){var e,r;return(r=n._s!==U?t._onFulfilled:t._onRejected)===P?void x(t,n._s,n._v):(e=s(g)(r,n._v))===nn?void x(t,U,e.e):void k(t,e)}),un=a(9,function(n){m(n)||(n[J]=1,_(Z,n))});try{n.exports=rn}catch(cn){O.Yaku=rn}}()}).call(t,e(/*! ./../~/webpack/buildin/global.js */2))}});
5784 if (!('flags' in RegExp.prototype)) {
5786 // RegExp.prototype.flags
5787 /* global Get, ToBoolean, Type */
5788 Object.defineProperty(RegExp.prototype, 'flags', {
5792 // 21.2.5.3.1 Let R be the this value.
5795 // 21.2.5.3.2 If Type(R) is not Object, throw a TypeError exception.
5796 if (Type(R) !== 'object') {
5797 throw new TypeError('Method called on incompatible type: must be an object.');
5799 // 21.2.5.3.3 Let result be the empty String.
5802 // 21.2.5.3.4 Let global be ToBoolean(? Get(R, "global")).
5803 var global = ToBoolean(Get(R, 'global'));
5805 // 21.2.5.3.5 If global is true, append the code unit 0x0067 (LATIN SMALL LETTER G) as the last code unit of result.
5810 // 21.2.5.3.6 Let ignoreCase be ToBoolean(? Get(R, "ignoreCase")).
5811 var ignoreCase = ToBoolean(Get(R, 'ignoreCase'));
5813 // 21.2.5.3.7 If ignoreCase is true, append the code unit 0x0069 (LATIN SMALL LETTER I) as the last code unit of result.
5818 // 21.2.5.3.8 Let multiline be ToBoolean(? Get(R, "multiline")).
5819 var multiline = ToBoolean(Get(R, 'multiline'));
5821 // 21.2.5.3.9 If multiline is true, append the code unit 0x006D (LATIN SMALL LETTER M) as the last code unit of result.
5826 // 21.2.5.3.10 Let unicode be ToBoolean(? Get(R, "unicode")).
5827 var unicode = ToBoolean(Get(R, 'unicode'));
5829 // 21.2.5.3.11 If unicode is true, append the code unit 0x0075 (LATIN SMALL LETTER U) as the last code unit of result.
5834 // 21.2.5.3.12 Let sticky be ToBoolean(? Get(R, "sticky")).
5835 var sticky = ToBoolean(Get(R, 'sticky'));
5837 // 21.2.5.3.13 If sticky is true, append the code unit 0x0079 (LATIN SMALL LETTER Y) as the last code unit of result.
5842 // 21.2.5.3.14 Return result.
5851 // A modification of https://github.com/medikoo/es6-iterator
5852 // Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
5854 /* global Iterator */
5856 var StringIterator = (function() { // eslint-disable-line no-unused-vars
5858 var StringIterator = function (str) {
5859 if (!(this instanceof StringIterator)) return new StringIterator(str);
5861 Iterator.call(this, str);
5862 Object.defineProperty(this, '__length__', {
5864 configurable: false,
5869 if (Object.setPrototypeOf) Object.setPrototypeOf(StringIterator, Iterator);
5871 StringIterator.prototype = Object.create(Iterator.prototype, {
5873 value: StringIterator,
5880 if (!this.__list__) return;
5881 if (this.__nextIndex__ < this.__length__) return this.__nextIndex__++;
5889 value: function (i) {
5890 var char = this.__list__[i], code;
5891 if (this.__nextIndex__ === this.__length__) return char;
5892 code = char.charCodeAt(0);
5893 if ((code >= 0xD800) && (code <= 0xDBFF)) return char + this.__list__[this.__nextIndex__++];
5902 return '[object String Iterator]';
5910 return StringIterator;
5912 if (!('Symbol' in this && 'iterator' in this.Symbol && !!String.prototype[Symbol.iterator])) {
5914 // String.prototype.@@iterator
5915 /* global CreateMethodProperty, RequireObjectCoercible, ToString, StringIterator, Symbol */
5916 // 21.1.3.29. String.prototype [ @@iterator ] ( )
5917 CreateMethodProperty(String.prototype, Symbol.iterator, function () {
5918 // 1. Let O be ? RequireObjectCoercible(this value).
5919 var O = RequireObjectCoercible(this);
5920 // 2. Let S be ? ToString(O).
5921 var S = ToString(O);
5922 // 3. Return CreateStringIterator(S).
5923 // TODO: Add CreateStringIterator.
5924 return new StringIterator(S);
5930 // _ESAbstract.UTF16Decode
5931 // 10.1.2. Static Semantics: UTF16Decode( lead, trail )
5932 function UTF16Decode(lead, trail) { // eslint-disable-line no-unused-vars
5933 // 1. Assert: 0xD800 ≤ lead ≤ 0xDBFF and 0xDC00 ≤ trail ≤ 0xDFFF.
5934 // 2. Let cp be (lead - 0xD800) × 0x400 + (trail - 0xDC00) + 0x10000.
5935 var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
5936 // 3. Return the code point cp.
5939 if (!('codePointAt' in String.prototype)) {
5941 // String.prototype.codePointAt
5942 /* global CreateMethodProperty, RequireObjectCoercible, ToInteger, ToString, UTF16Decode */
5943 // 21.1.3.3. String.prototype.codePointAt ( pos )
5944 CreateMethodProperty(String.prototype, 'codePointAt', function codePointAt(pos) {
5945 // 1. Let O be ? RequireObjectCoercible(this value).
5946 var O = RequireObjectCoercible(this);
5947 // 2. Let S be ? ToString(O).
5948 var S = ToString(O);
5949 // 3. Let position be ? ToInteger(pos).
5950 var position = ToInteger(pos);
5951 // 4. Let size be the length of S.
5952 var size = S.length;
5953 // 5. If position < 0 or position ≥ size, return undefined.
5954 if (position < 0 || position >= size) {
5957 // 6. Let first be the numeric value of the code unit at index position within the String S.
5958 var first = String.prototype.charCodeAt.call(S, position);
5959 // 7. If first < 0xD800 or first > 0xDBFF or position+1 = size, return first.
5960 if (first < 0xD800 || first > 0xDBFF || position + 1 === size) {
5963 // 8. Let second be the numeric value of the code unit at index position+1 within the String S.
5964 var second = String.prototype.charCodeAt.call(S, position + 1);
5965 // 9. If second < 0xDC00 or second > 0xDFFF, return first.
5966 if (second < 0xDC00 || second > 0xDFFF) {
5969 // 10. Return UTF16Decode(first, second).
5970 // 21.1.3.3.10 Return UTF16Decode(first, second).
5971 return UTF16Decode(first, second);
5976 if (!('endsWith' in String.prototype)) {
5978 // String.prototype.endsWith
5979 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
5980 // 21.1.3.6. String.prototype.endsWith ( searchString [ , endPosition ] )
5981 CreateMethodProperty(String.prototype, 'endsWith', function endsWith(searchString /* [ , endPosition ] */) {
5983 var endPosition = arguments.length > 1 ? arguments[1] : undefined;
5984 // 1. Let O be ? RequireObjectCoercible(this value).
5985 var O = RequireObjectCoercible(this);
5986 // 2. Let S be ? ToString(O).
5987 var S = ToString(O);
5988 // 3. Let isRegExp be ? IsRegExp(searchString).
5989 var isRegExp = IsRegExp(searchString);
5990 // 4. If isRegExp is true, throw a TypeError exception.
5992 throw new TypeError('First argument to String.prototype.endsWith must not be a regular expression');
5994 // 5. Let searchStr be ? ToString(searchString).
5995 var searchStr = ToString(searchString);
5996 // 6. Let len be the length of S.
5998 // 7. If endPosition is undefined, let pos be len, else let pos be ? ToInteger(endPosition).
5999 var pos = endPosition === undefined ? len : ToInteger(endPosition);
6000 // 8. Let end be min(max(pos, 0), len).
6001 var end = Math.min(Math.max(pos, 0), len);
6002 // 9. Let searchLength be the length of searchStr.
6003 var searchLength = searchStr.length;
6004 // 10. Let start be end - searchLength.
6005 var start = end - searchLength;
6006 // 11. If start is less than 0, return false.
6010 // 12. If the sequence of elements of S starting at start of length searchLength is the same as the full element sequence of searchStr, return true.
6011 if (S.substr(start, searchLength) === searchStr) {
6014 // 13. Otherwise, return false.
6020 if (!('repeat' in String.prototype)) {
6022 // String.prototype.repeat
6023 /* global CreateMethodProperty, RequireObjectCoercible, ToInteger, ToString */
6024 // 21.1.3.15String.prototype.repeat ( count )
6025 CreateMethodProperty(String.prototype, 'repeat', function repeat(count) {
6027 // 1. Let O be ? RequireObjectCoercible(this value).
6028 var O = RequireObjectCoercible(this);
6029 // 2. Let S be ? ToString(O).
6030 var S = ToString(O);
6031 // 3. Let n be ? ToInteger(count).
6032 var n = ToInteger(count);
6033 // 4. If n < 0, throw a RangeError exception.
6035 throw new RangeError('Invalid count value');
6037 // 5. If n is +∞, throw a RangeError exception.
6038 if (n === Infinity) {
6039 throw new RangeError('Invalid count value');
6041 // 6. Let T be the String value that is made from n copies of S appended together. If n is 0, T is the empty String.
6042 var T = n === 0 ? '' : new Array(n + 1).join(S);
6049 if (!('startsWith' in String.prototype)) {
6051 // String.prototype.startsWith
6052 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
6053 // 21.1.3.20. String.prototype.startsWith ( searchString [ , position ] )
6054 CreateMethodProperty(String.prototype, 'startsWith', function startsWith(searchString /* [ , position ] */) {
6056 var position = arguments.length > 1 ? arguments[1] : undefined;
6057 // 1. Let O be ? RequireObjectCoercible(this value).
6058 var O = RequireObjectCoercible(this);
6059 // 2. Let S be ? ToString(O).
6060 var S = ToString(O);
6061 // 3. Let isRegExp be ? IsRegExp(searchString).
6062 var isRegExp = IsRegExp(searchString);
6063 // 4. If isRegExp is true, throw a TypeError exception.
6065 throw new TypeError('First argument to String.prototype.startsWith must not be a regular expression');
6067 // 5. Let searchStr be ? ToString(searchString).
6068 var searchStr = ToString(searchString);
6069 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
6070 var pos = ToInteger(position);
6071 // 7. Let len be the length of S.
6073 // 8. Let start be min(max(pos, 0), len).
6074 var start = Math.min(Math.max(pos, 0), len);
6075 // 9. Let searchLength be the length of searchStr.
6076 var searchLength = searchStr.length;
6077 // 10. If searchLength+start is greater than len, return false.
6078 if (searchLength + start > len) {
6081 // 11. If the sequence of elements of S starting at start of length searchLength is the same as the full element sequence of searchStr, return true.
6082 if (S.substr(start).indexOf(searchString) === 0) {
6085 // 12. Otherwise, return false.
6091 if (!('Symbol' in this && 'hasInstance' in this.Symbol)) {
6093 // Symbol.hasInstance
6095 Object.defineProperty(Symbol, 'hasInstance', { value: Symbol('hasInstance') });
6099 if (!('Symbol' in this && 'isConcatSpreadable' in this.Symbol)) {
6101 // Symbol.isConcatSpreadable
6103 Object.defineProperty(Symbol, 'isConcatSpreadable', { value: Symbol('isConcatSpreadable') });
6107 if (!('Symbol' in this && 'match' in this.Symbol)) {
6111 Object.defineProperty(Symbol, 'match', { value: Symbol('match') });
6115 if (!('Symbol' in this && 'replace' in this.Symbol)) {
6119 Object.defineProperty(Symbol, 'replace', { value: Symbol('replace') });
6123 if (!('Symbol' in this && 'search' in this.Symbol)) {
6127 Object.defineProperty(Symbol, 'search', { value: Symbol('search') });
6131 if (!('Symbol' in this && 'split' in this.Symbol)) {
6135 Object.defineProperty(Symbol, 'split', { value: Symbol('split') });
6139 if (!('Symbol' in this && 'toPrimitive' in this.Symbol)) {
6141 // Symbol.toPrimitive
6143 Object.defineProperty(Symbol, 'toPrimitive', { value: Symbol('toPrimitive') });
6147 if (!('Symbol' in this && 'unscopables' in this.Symbol)) {
6149 // Symbol.unscopables
6151 Object.defineProperty(Symbol, 'unscopables', { value: Symbol('unscopables') });
6155 if (!((function(global) {
6157 if ("WeakMap" in global && WeakMap.length === 0) {
6159 var wm = new WeakMap([[o, 'test']]);
6160 return (wm.get(o) === 'test' && wm["delete"](0) === false);
6170 /* globals Symbol, OrdinaryCreateFromConstructor, IsCallable, GetIterator, IteratorStep, IteratorValue, IteratorClose, Get, Call, CreateMethodProperty, Type, SameValue */
6171 (function (global) {
6172 // Deleted map items mess with iterator pointers, so rather than removing them mark them as deleted. Can't use undefined or null since those both valid keys so use a private symbol.
6173 var undefMarker = Symbol('undef');
6174 // 23.3.1.1 WeakMap ( [ iterable ] )
6175 var WeakMap = function WeakMap(/* iterable */) {
6176 // 1. If NewTarget is undefined, throw a TypeError exception.
6177 if (!(this instanceof WeakMap)) {
6178 throw new TypeError('Constructor WeakMap requires "new"');
6180 // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakMapPrototype%", « [[WeakMapData]] »).
6181 var map = OrdinaryCreateFromConstructor(this, WeakMap.prototype, {
6187 // 3. Set map.[[WeakMapData]] to a new empty List.
6188 // Polyfill.io - This step was done as part of step two.
6190 // 4. If iterable is not present, let iterable be undefined.
6191 var iterable = arguments.length > 0 ? arguments[0] : undefined;
6193 // 5. If iterable is either undefined or null, return map.
6194 if (iterable === null || iterable === undefined) {
6198 // 6. Let adder be ? Get(map, "set").
6199 var adder = Get(map, "set");
6201 // 7. If IsCallable(adder) is false, throw a TypeError exception.
6202 if (!IsCallable(adder)) {
6203 throw new TypeError("WeakMap.prototype.set is not a function");
6206 // 8. Let iteratorRecord be ? GetIterator(iterable).
6208 var iteratorRecord = GetIterator(iterable);
6211 // a. Let next be ? IteratorStep(iteratorRecord).
6212 var next = IteratorStep(iteratorRecord);
6213 // b. If next is false, return map.
6214 if (next === false) {
6217 // c. Let nextItem be ? IteratorValue(next).
6218 var nextItem = IteratorValue(next);
6219 // d. If Type(nextItem) is not Object, then
6220 if (Type(nextItem) !== 'object') {
6221 // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
6223 throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
6225 // ii. Return ? IteratorClose(iteratorRecord, error).
6226 return IteratorClose(iteratorRecord, error);
6230 // Polyfill.io - The try catch accounts for steps: f, h, and j.
6232 // e. Let k be Get(nextItem, "0").
6233 var k = Get(nextItem, "0");
6234 // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
6235 // g. Let v be Get(nextItem, "1").
6236 var v = Get(nextItem, "1");
6237 // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
6238 // i. Let status be Call(adder, map, « k.[[Value]], v.[[Value]] »).
6239 Call(adder, map, [k, v]);
6241 // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
6242 return IteratorClose(iteratorRecord, e);
6246 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
6247 if (Array.isArray(iterable) ||
6248 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
6249 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
6250 (!!iterable.callee)) {
6252 var length = iterable.length;
6253 for (index = 0; index < length; index++) {
6254 var k = iterable[index][0];
6255 var v = iterable[index][1];
6256 Call(adder, map, [k, v]);
6263 // 23.3.2.1 WeakMap.prototype
6264 // The initial value of WeakMap.prototype is the intrinsic object %WeakMapPrototype%.
6265 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
6266 Object.defineProperty(WeakMap, 'prototype', {
6267 configurable: false,
6273 // 23.3.3.1 WeakMap.prototype.constructor
6274 CreateMethodProperty(WeakMap.prototype, 'constructor', WeakMap);
6276 // 23.3.3.2 WeakMap.prototype.delete ( key )
6277 CreateMethodProperty(WeakMap.prototype, 'delete', function (key) {
6278 // 1. Let M be the this value.
6280 // 2. If Type(M) is not Object, throw a TypeError exception.
6281 if (Type(M) !== 'object') {
6282 throw new TypeError('Method WeakMap.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
6284 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
6285 if (M._es6WeakMap !== true) {
6286 throw new TypeError('Method WeakMap.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
6288 // 4. Let entries be the List that is M.[[WeakMapData]].
6289 var entries = M._keys;
6290 // 5. If Type(key) is not Object, return false.
6291 if (Type(key) !== 'object') {
6294 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
6295 for (var i = 0; i < entries.length; i++) {
6296 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, then
6297 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
6298 // i. Set p.[[Key]] to empty.
6299 this._keys[i] = undefMarker;
6300 // ii. Set p.[[Value]] to empty.
6301 this._values[i] = undefMarker;
6302 this._size = --this._size;
6303 // iii. Return true.
6311 // 23.3.3.3 WeakMap.prototype.get ( key )
6312 CreateMethodProperty(WeakMap.prototype, 'get', function get(key) {
6313 // 1. Let M be the this value.
6315 // 2. If Type(M) is not Object, throw a TypeError exception.
6316 if (Type(M) !== 'object') {
6317 throw new TypeError('Method WeakMap.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
6319 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
6320 if (M._es6WeakMap !== true) {
6321 throw new TypeError('Method WeakMap.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
6323 // 4. Let entries be the List that is M.[[WeakMapData]].
6324 var entries = M._keys;
6325 // 5. If Type(key) is not Object, return undefined.
6326 if (Type(key) !== 'object') {
6329 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
6330 for (var i = 0; i < entries.length; i++) {
6331 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
6332 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
6333 return M._values[i];
6336 // 7. Return undefined.
6340 // 23.3.3.4 WeakMap.prototype.has ( key )
6341 CreateMethodProperty(WeakMap.prototype, 'has', function has(key) {
6342 // 1. Let M be the this value.
6344 // 2. If Type(M) is not Object, throw a TypeError exception.
6345 if (typeof M !== 'object') {
6346 throw new TypeError('Method WeakMap.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
6348 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
6349 if (M._es6WeakMap !== true) {
6350 throw new TypeError('Method WeakMap.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
6352 // 4. Let entries be the List that is M.[[WeakMapData]].
6353 var entries = M._keys;
6354 // 5. If Type(key) is not Object, return false.
6355 if (Type(key) !== 'object') {
6358 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
6359 for (var i = 0; i < entries.length; i++) {
6360 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return true.
6361 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
6369 // 23.3.3.5 WeakMap.prototype.set ( key, value )
6370 CreateMethodProperty(WeakMap.prototype, 'set', function set(key, value) {
6371 // 1. Let M be the this value.
6373 // 2. If Type(M) is not Object, throw a TypeError exception.
6374 if (Type(M) !== 'object') {
6375 throw new TypeError('Method WeakMap.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
6377 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
6378 if (M._es6WeakMap !== true) {
6379 throw new TypeError('Method WeakMap.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
6381 // 4. Let entries be the List that is M.[[WeakMapData]].
6382 var entries = M._keys;
6383 // 5. If Type(key) is not Object, throw a TypeError exception.
6384 if (Type(key) !== 'object') {
6385 throw new TypeError("Invalid value used as weak map key");
6387 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
6388 for (var i = 0; i < entries.length; i++) {
6389 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, then
6390 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
6391 // i. Set p.[[Value]] to value.
6392 M._values[i] = value;
6397 // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
6402 // 8. Append p as the last element of entries.
6403 M._keys.push(p['[[Key]]']);
6404 M._values.push(p['[[Value]]']);
6409 // 23.3.3.6 WeakMap.prototype [ @@toStringTag ]
6410 // The initial value of the @@toStringTag property is the String value "WeakMap".
6411 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
6413 // Polyfill.io - Safari 8 implements WeakMap.name but as a non-writable property, which means it would throw an error if we try and write to it here.
6414 if (!('name' in WeakMap)) {
6416 Object.defineProperty(WeakMap, 'name', {
6424 // Export the object
6426 CreateMethodProperty(global, 'WeakMap', WeakMap);
6428 // IE8 throws an error here if we set enumerable to false.
6429 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
6430 global['WeakMap'] = WeakMap;
6436 if (!((function(global) {
6438 if ("WeakSet" in global && WeakSet.length === 0) {
6440 var ws = new WeakSet([o]);
6441 return (ws.has(o) && ws["delete"](0) === false);
6451 /* global Call, CreateMethodProperty, Get, GetIterator, IsArray, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
6452 (function (global) {
6453 // Deleted set items mess with iterator pointers, so rather than removing them mark them as deleted. Can't use undefined or null since those both valid keys so use a private symbol.
6454 var undefMarker = Symbol('undef');
6455 // 23.4.1.1. WeakSet ( [ iterable ] )
6456 var WeakSet = function WeakSet() {
6457 // 1. If NewTarget is undefined, throw a TypeError exception.
6458 if (!(this instanceof WeakSet)) {
6459 throw new TypeError('Constructor WeakSet requires "new"');
6461 // 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakSetPrototype%", « [[WeakSetData]] »).
6462 var set = OrdinaryCreateFromConstructor(this, WeakSet.prototype, {
6468 // 3. Set set.[[WeakSetData]] to a new empty List.
6469 // Polyfill.io - This step was done as part of step two.
6471 // 4. If iterable is not present, let iterable be undefined.
6472 var iterable = arguments.length > 0 ? arguments[0] : undefined;
6473 // 5. If iterable is either undefined or null, return set.
6474 if (iterable === null || iterable === undefined) {
6477 // 6. Let adder be ? Get(set, "add").
6478 var adder = Get(set, 'add');
6479 // 7. If IsCallable(adder) is false, throw a TypeError exception.
6480 if (!IsCallable(adder)) {
6481 throw new TypeError("WeakSet.prototype.add is not a function");
6484 // 8. Let iteratorRecord be ? GetIterator(iterable).
6485 var iteratorRecord = GetIterator(iterable);
6488 // a. Let next be ? IteratorStep(iteratorRecord).
6489 var next = IteratorStep(iteratorRecord);
6490 // b. If next is false, return set.
6491 if (next === false) {
6494 // c. Let nextValue be ? IteratorValue(next).
6495 var nextValue = IteratorValue(next);
6496 // d. Let status be Call(adder, set, « nextValue »).
6498 Call(adder, set, [nextValue]);
6500 // e. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
6501 return IteratorClose(iteratorRecord, e);
6505 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
6506 if (IsArray(iterable) ||
6507 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
6508 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
6509 (!!iterable.callee)) {
6511 var length = iterable.length;
6512 for (index = 0; index < length; index++) {
6513 Call(adder, set, [iterable[index]]);
6520 // 23.4.2.1. WeakSet.prototype
6521 // The initial value of WeakSet.prototype is the intrinsic %WeakSetPrototype% object.
6522 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
6523 Object.defineProperty(WeakSet, 'prototype', {
6524 configurable: false,
6530 // 23.4.3.1. WeakSet.prototype.add ( value )
6531 CreateMethodProperty(WeakSet.prototype, 'add', function add(value) {
6532 // 1. Let S be the this value.
6534 // 2. If Type(S) is not Object, throw a TypeError exception.
6535 if (Type(S) !== 'object') {
6536 throw new TypeError('Method WeakSet.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
6538 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
6539 if (S._es6WeakSet !== true) {
6540 throw new TypeError('Method WeakSet.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
6542 // 4. If Type(value) is not Object, throw a TypeError exception.
6543 if (Type(value) !== 'object') {
6544 throw new TypeError('Invalid value used in weak set');
6546 // 5. Let entries be the List that is S.[[WeakSetData]].
6547 var entries = S._values;
6548 // 6. For each e that is an element of entries, do
6549 for (var i = 0; i < entries.length; i++) {
6551 // a. If e is not empty and SameValue(e, value) is true, then
6552 if (e !== undefMarker && SameValueZero(e, value)) {
6557 // 7. Append value as the last element of entries.
6558 S._values.push(value);
6563 // 23.4.3.2. WeakSet.prototype.constructor
6564 CreateMethodProperty(WeakSet.prototype, 'constructor', WeakSet);
6566 // 23.4.3.3. WeakSet.prototype.delete ( value )
6567 CreateMethodProperty(WeakSet.prototype, 'delete', function (value) {
6568 // 1. Let S be the this value.
6570 // 2. If Type(S) is not Object, throw a TypeError exception.
6571 if (Type(S) !== 'object') {
6572 throw new TypeError('Method WeakSet.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
6574 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
6575 if (S._es6WeakSet !== true) {
6576 throw new TypeError('Method WeakSet.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
6578 // 4. If Type(value) is not Object, return false.
6579 if (Type(value) !== 'object') {
6582 // 5. Let entries be the List that is S.[[WeakSetData]].
6583 var entries = S._values;
6584 // 6. For each e that is an element of entries, do
6585 for (var i = 0; i < entries.length; i++) {
6587 // a. If e is not empty and SameValue(e, value) is true, then
6588 if (e !== undefMarker && SameValueZero(e, value)) {
6589 // i. Replace the element of entries whose value is e with an element whose value is empty.
6590 entries[i] = undefMarker;
6599 // 23.4.3.4. WeakSet.prototype.has ( value )
6600 CreateMethodProperty(WeakSet.prototype, 'has', function has(value) {
6601 // 1. Let S be the this value.
6603 // 2. If Type(S) is not Object, throw a TypeError exception.
6604 if (Type(S) !== 'object') {
6605 throw new TypeError('Method WeakSet.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(S));
6607 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
6608 if (S._es6WeakSet !== true) {
6609 throw new TypeError('Method WeakSet.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(S));
6611 // 4. Let entries be the List that is S.[[WeakSetData]].
6612 var entries = S._values;
6613 // 5. If Type(value) is not Object, return false.
6614 if (Type(value) !== 'object') {
6617 // 6. For each e that is an element of entries, do
6618 for (var i = 0; i < entries.length; i++) {
6620 // a. If e is not empty and SameValue(e, value) is true, return true.
6621 if (e !== undefMarker && SameValueZero(e, value)) {
6629 // 23.4.3.5. WeakSet.prototype [ @@toStringTag ]
6630 // The initial value of the @@toStringTag property is the String value "WeakSet".
6631 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
6633 // Polyfill.io - Safari 8 implements Set.name but as a non-configurable property, which means it would throw an error if we try and configure it here.
6634 if (!('name' in WeakSet)) {
6636 Object.defineProperty(WeakSet, 'name', {
6644 // Export the object
6646 CreateMethodProperty(global, 'WeakSet', WeakSet);
6648 // IE8 throws an error here if we set enumerable to false.
6649 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
6650 global['WeakSet'] = WeakSet;
6658 .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});