1 /* Polyfill service v3.34.0
2 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
4 * Features requested: es6
6 * - _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")
7 * - _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")
8 * - _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")
9 * - _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")
10 * - _ESAbstract.IsArray, License: CC0 (required by "String.fromCodePoint", "es6", "WeakMap", "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")
11 * - _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")
12 * - _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")
13 * - _ESAbstract.SameValueNonNumber, License: CC0 (required by "_ESAbstract.SameValueZero", "Map", "es6", "Array.from", "Set", "WeakSet", "_ESAbstract.SameValue", "Object.is", "String.fromCodePoint", "WeakMap")
14 * - _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")
15 * - _ESAbstract.ToInteger, License: CC0 (required by "Array.prototype.copyWithin", "es6", "Array.prototype.fill", "Number.isInteger", "Number.isSafeInteger", "String.fromCodePoint", "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")
16 * - _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")
17 * - _ESAbstract.ToNumber, License: CC0 (required by "String.fromCodePoint", "es6")
18 * - _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")
19 * - _ESAbstract.GetV, License: CC0 (required by "_ESAbstract.GetMethod", "Array.from", "es6", "Map", "Set", "_ESAbstract.GetIterator", "WeakMap", "WeakSet")
20 * - _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")
21 * - _ESAbstract.ToUint32, License: CC0 (required by "Math.clz32", "es6", "Math.imul")
22 * - _ESAbstract.Type, License: CC0 (required by "Map", "es6", "Array.from", "Number.isFinite", "Number.isInteger", "Number.isNaN", "Number.isSafeInteger", "Object.seal", "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", "String.fromCodePoint", "_ESAbstract.IsRegExp", "_ESAbstract.ToPrimitive", "_ESAbstract.GetPrototypeFromConstructor", "Object.defineProperties", "_Iterator", "_StringIterator", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.OrdinaryToPrimitive")
23 * - _ESAbstract.GetPrototypeFromConstructor, License: CC0 (required by "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "es6", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
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.IsRegExp, License: CC0 (required by "String.prototype.endsWith", "es6", "String.prototype.includes", "String.prototype.startsWith")
26 * - _ESAbstract.IteratorClose, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
27 * - _ESAbstract.IteratorComplete, License: CC0 (required by "Map", "es6", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet")
28 * - _ESAbstract.IteratorNext, License: CC0 (required by "Map", "es6", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet")
29 * - _ESAbstract.IteratorStep, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
30 * - _ESAbstract.IteratorValue, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
31 * - _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")
32 * - _ESAbstract.SameValue, License: CC0 (required by "Object.is", "es6", "String.fromCodePoint", "WeakMap")
33 * - _ESAbstract.SameValueZero, License: CC0 (required by "Map", "es6", "Array.from", "Set", "WeakSet")
34 * - _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")
35 * - _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")
36 * - _ESAbstract.UTF16Decode, License: CC0 (required by "String.prototype.codePointAt", "es6")
37 * - _ESAbstract.UTF16Encoding, License: CC0 (required by "String.fromCodePoint", "es6")
38 * - _TypedArray, License: MIT (required by "Math.fround", "es6")
39 * - Object.defineProperty, License: CC0 (required by "Function.prototype.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", "Object.seal", "String.fromCodePoint", "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")
40 * - _ESAbstract.CreateDataProperty, License: CC0 (required by "_ESAbstract.CreateDataPropertyOrThrow", "Array.from", "es6", "Array.of", "_ESAbstract.CreateIterResultObject", "Map", "Set")
41 * - _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")
42 * - _ESAbstract.CreateIterResultObject, License: CC0 (required by "Map", "es6", "Array.from", "Set")
43 * - _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.seal", "Object.setPrototypeOf", "Set", "String.fromCodePoint", "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", "Object.keys", "Array.prototype.forEach", "Object.getPrototypeOf", "Object.getOwnPropertyNames", "Array.prototype.filter", "Array.prototype.map", "Object.freeze", "Function.prototype.bind", "Object.defineProperties", "_Iterator", "_StringIterator")
44 * - Array.isArray, License: CC0 (required by "Map", "es6", "Array.from", "Set", "WeakMap")
45 * - Array.prototype.copyWithin, License: MIT (required by "es6")
46 * - Array.prototype.fill, License: CC0 (required by "es6")
47 * - Array.prototype.find, License: CC0 (required by "es6")
48 * - Array.prototype.findIndex, License: CC0 (required by "es6")
49 * - 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")
50 * - 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")
51 * - Math.acosh, License: CC0 (required by "es6")
52 * - Math.asinh, License: CC0 (required by "es6")
53 * - Math.atanh, License: CC0 (required by "es6")
54 * - Math.cbrt, License: CC0 (required by "es6")
55 * - Math.clz32, License: CC0 (required by "es6")
56 * - Math.cosh, License: CC0 (required by "es6")
57 * - Math.expm1, License: CC0 (required by "es6")
58 * - Math.fround, License: CC0 (required by "es6")
59 * - Math.hypot, License: CC0 (required by "es6")
60 * - Math.imul, License: CC0 (required by "es6")
61 * - Math.log10, License: CC0 (required by "es6")
62 * - Math.log1p, License: CC0 (required by "es6")
63 * - Math.log2, License: CC0 (required by "es6")
64 * - Math.sign, License: CC0 (required by "es6")
65 * - Math.sinh, License: CC0 (required by "es6")
66 * - Math.tanh, License: CC0 (required by "es6")
67 * - Math.trunc, License: CC0 (required by "es6")
68 * - Number.isFinite, License: MIT (required by "es6")
69 * - Number.isInteger, License: MIT (required by "es6")
70 * - Number.isNaN, License: MIT (required by "es6")
71 * - Number.isSafeInteger, License: MIT (required by "es6")
72 * - Number.parseFloat, License: MIT (required by "es6")
73 * - Number.parseInt, License: MIT (required by "es6")
74 * - Function.prototype.name, License: MIT (required by "es6")
75 * - Number.Epsilon, License: MIT (required by "es6")
76 * - Number.MAX_SAFE_INTEGER, License: MIT (required by "es6")
77 * - Number.MIN_SAFE_INTEGER, License: MIT (required by "es6")
78 * - 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")
79 * - 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")
80 * - 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")
81 * - Object.getPrototypeOf, License: CC0 (required by "Object.setPrototypeOf", "es6", "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
82 * - Object.is, License: CC0 (required by "es6")
83 * - 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")
84 * - 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")
85 * - 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")
86 * - 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")
87 * - _ESAbstract.GetIterator, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
88 * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "Map", "es6", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
89 * - _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")
90 * - _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")
91 * - 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")
92 * - 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")
93 * - Array.of, License: CC0 (required by "es6")
94 * - Object.seal, License: MIT (required by "es6")
95 * - Object.setPrototypeOf, License: MIT (required by "es6", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
96 * - Promise, License: MIT (required by "es6")
97 * - RegExp.prototype.flags, License: MIT (required by "es6")
98 * - String.fromCodePoint, License: MIT (required by "es6")
99 * - String.prototype.codePointAt, License: MIT (required by "es6")
100 * - String.prototype.endsWith, License: CC0 (required by "es6")
101 * - String.prototype.includes, License: CC0 (required by "es6", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
102 * - String.prototype.repeat, License: CC0 (required by "es6")
103 * - String.prototype.startsWith, License: CC0 (required by "es6")
104 * - 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")
105 * - Symbol.hasInstance, License: MIT (required by "es6")
106 * - Symbol.isConcatSpreadable, License: MIT (required by "es6")
107 * - 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")
108 * - Symbol.match, License: MIT (required by "es6")
109 * - Symbol.replace, License: MIT (required by "es6")
110 * - Symbol.search, License: MIT (required by "es6")
111 * - Symbol.species, License: MIT (required by "es6", "Map", "Array.from", "Set")
112 * - Map, License: CC0 (required by "es6", "Array.from")
113 * - Set, License: CC0 (required by "es6", "Array.from")
114 * - Array.from, License: CC0 (required by "es6")
115 * - Symbol.split, License: MIT (required by "es6")
116 * - Symbol.toPrimitive, License: MIT (required by "es6")
117 * - 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")
118 * - _Iterator, License: MIT (required by "_ArrayIterator", "Array.prototype.entries", "es6", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
119 * - _ArrayIterator, License: MIT (required by "Array.prototype.entries", "es6", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
120 * - Array.prototype.entries, License: CC0 (required by "es6")
121 * - Array.prototype.keys, License: CC0 (required by "es6")
122 * - Array.prototype.values, License: MIT (required by "es6", "Array.prototype.@@iterator")
123 * - Array.prototype.@@iterator, License: CC0 (required by "es6")
124 * - _StringIterator, License: MIT (required by "String.prototype.@@iterator", "es6")
125 * - String.prototype.@@iterator, License: CC0 (required by "es6")
126 * - Symbol.unscopables, License: MIT (required by "es6")
127 * - WeakMap, License: MIT (required by "es6")
128 * - WeakSet, License: MIT (required by "es6") */
130 (function(undefined) {
132 // _ESAbstract.ArrayCreate
133 // 9.4.2.2. ArrayCreate ( length [ , proto ] )
134 function ArrayCreate(length /* [, proto] */) { // eslint-disable-line no-unused-vars
135 // 1. Assert: length is an integer Number ≥ 0.
136 // 2. If length is -0, set length to +0.
137 if (1 / length === -Infinity) {
140 // 3. If length>2^32-1, throw a RangeError exception.
141 if (length > (Math.pow(2, 32) - 1)) {
142 throw new RangeError('Invalid array length');
144 // 4. If proto is not present, set proto to the intrinsic object %ArrayPrototype%.
145 // 5. Let A be a newly created Array exotic object.
147 // 6. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.
148 // 7. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1.
149 // 8. Set A.[[Prototype]] to proto.
150 // 9. Set A.[[Extensible]] to true.
151 // 10. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
158 /* global IsCallable */
159 // 7.3.12. Call ( F, V [ , argumentsList ] )
160 function Call(F, V /* [, argumentsList] */) { // eslint-disable-line no-unused-vars
161 // 1. If argumentsList is not present, set argumentsList to a new empty List.
162 var argumentsList = arguments.length > 2 ? arguments[2] : [];
163 // 2. If IsCallable(F) is false, throw a TypeError exception.
164 if (IsCallable(F) === false) {
165 throw new TypeError(Object.prototype.toString.call(F) + 'is not a function.');
167 // 3. Return ? F.[[Call]](V, argumentsList).
168 return F.apply(V, argumentsList);
172 // 7.3.1. Get ( O, P )
173 function Get(O, P) { // eslint-disable-line no-unused-vars
174 // 1. Assert: Type(O) is Object.
175 // 2. Assert: IsPropertyKey(P) is true.
176 // 3. Return ? O.[[Get]](P, O).
180 // _ESAbstract.HasProperty
181 // 7.3.10. HasProperty ( O, P )
182 function HasProperty(O, P) { // eslint-disable-line no-unused-vars
183 // Assert: Type(O) is Object.
184 // Assert: IsPropertyKey(P) is true.
185 // Return ? O.[[HasProperty]](P).
189 // _ESAbstract.IsArray
190 // 7.2.2. IsArray ( argument )
191 function IsArray(argument) { // eslint-disable-line no-unused-vars
192 // 1. If Type(argument) is not Object, return false.
193 // 2. If argument is an Array exotic object, return true.
194 // 3. If argument is a Proxy exotic object, then
195 // a. If argument.[[ProxyHandler]] is null, throw a TypeError exception.
196 // b. Let target be argument.[[ProxyTarget]].
197 // c. Return ? IsArray(target).
200 // Polyfill.io - We can skip all the above steps and check the string returned from Object.prototype.toString().
201 return Object.prototype.toString.call(argument) === '[object Array]';
204 // _ESAbstract.IsCallable
205 // 7.2.3. IsCallable ( argument )
206 function IsCallable(argument) { // eslint-disable-line no-unused-vars
207 // 1. If Type(argument) is not Object, return false.
208 // 2. If argument has a [[Call]] internal method, return true.
211 // 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.
212 return typeof argument === 'function';
215 // _ESAbstract.RequireObjectCoercible
216 // 7.2.1. RequireObjectCoercible ( argument )
217 // The abstract operation ToObject converts argument to a value of type Object according to Table 12:
218 // Table 12: ToObject Conversions
220 |----------------------------------------------------------------------------------------------------------------------------------------------------|
221 | Argument Type | Result |
222 |----------------------------------------------------------------------------------------------------------------------------------------------------|
223 | Undefined | Throw a TypeError exception. |
224 | Null | Throw a TypeError exception. |
225 | Boolean | Return argument. |
226 | Number | Return argument. |
227 | String | Return argument. |
228 | Symbol | Return argument. |
229 | Object | Return argument. |
230 |----------------------------------------------------------------------------------------------------------------------------------------------------|
232 function RequireObjectCoercible(argument) { // eslint-disable-line no-unused-vars
233 if (argument === null || argument === undefined) {
239 // _ESAbstract.SameValueNonNumber
240 // 7.2.12. SameValueNonNumber ( x, y )
241 function SameValueNonNumber(x, y) { // eslint-disable-line no-unused-vars
242 // 1. Assert: Type(x) is not Number.
243 // 2. Assert: Type(x) is the same as Type(y).
244 // 3. If Type(x) is Undefined, return true.
245 // 4. If Type(x) is Null, return true.
246 // 5. If Type(x) is String, then
247 // 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.
248 // 6. If Type(x) is Boolean, then
249 // a. If x and y are both true or both false, return true; otherwise, return false.
250 // 7. If Type(x) is Symbol, then
251 // a. If x and y are both the same Symbol value, return true; otherwise, return false.
252 // 8. If x and y are the same Object value, return true. Otherwise, return false.
254 // Polyfill.io - We can skip all above steps because the === operator does it all for us.
258 // _ESAbstract.ToBoolean
259 // 7.1.2. ToBoolean ( argument )
260 // The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 9:
262 --------------------------------------------------------------------------------------------------------------
263 | Argument Type | Result |
264 --------------------------------------------------------------------------------------------------------------
265 | Undefined | Return false. |
266 | Null | Return false. |
267 | Boolean | Return argument. |
268 | Number | If argument is +0, -0, or NaN, return false; otherwise return true. |
269 | String | If argument is the empty String (its length is zero), return false; otherwise return true. |
270 | Symbol | Return true. |
271 | Object | Return true. |
272 --------------------------------------------------------------------------------------------------------------
274 function ToBoolean(argument) { // eslint-disable-line no-unused-vars
275 return Boolean(argument);
278 // _ESAbstract.ToInteger
279 // 7.1.4. ToInteger ( argument )
280 function ToInteger(argument) { // eslint-disable-line no-unused-vars
281 // 1. Let number be ? ToNumber(argument).
282 var number = Number(argument);
283 // 2. If number is NaN, return +0.
287 // 3. If number is +0, -0, +∞, or -∞, return number.
288 if (1/number === Infinity || 1/number === -Infinity || number === Infinity || number === -Infinity) {
291 // 4. Return the number value that is the same sign as number and whose magnitude is floor(abs(number)).
292 return ((number < 0) ? -1 : 1) * Math.floor(Math.abs(number));
295 // _ESAbstract.ToLength
296 /* global ToInteger */
297 // 7.1.15. ToLength ( argument )
298 function ToLength(argument) { // eslint-disable-line no-unused-vars
299 // 1. Let len be ? ToInteger(argument).
300 var len = ToInteger(argument);
301 // 2. If len ≤ +0, return +0.
305 // 3. Return min(len, 253-1).
306 return Math.min(len, Math.pow(2, 53) -1);
309 // _ESAbstract.ToNumber
310 // 7.1.3. ToNumber ( argument )
311 function ToNumber(argument) { // eslint-disable-line no-unused-vars
312 return Number(argument);
315 // _ESAbstract.ToObject
316 // 7.1.13 ToObject ( argument )
317 // The abstract operation ToObject converts argument to a value of type Object according to Table 12:
318 // Table 12: ToObject Conversions
320 |----------------------------------------------------------------------------------------------------------------------------------------------------|
321 | Argument Type | Result |
322 |----------------------------------------------------------------------------------------------------------------------------------------------------|
323 | Undefined | Throw a TypeError exception. |
324 | Null | Throw a TypeError exception. |
325 | Boolean | Return a new Boolean object whose [[BooleanData]] internal slot is set to argument. See 19.3 for a description of Boolean objects. |
326 | Number | Return a new Number object whose [[NumberData]] internal slot is set to argument. See 20.1 for a description of Number objects. |
327 | String | Return a new String object whose [[StringData]] internal slot is set to argument. See 21.1 for a description of String objects. |
328 | Symbol | Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 19.4 for a description of Symbol objects. |
329 | Object | Return argument. |
330 |----------------------------------------------------------------------------------------------------------------------------------------------------|
332 function ToObject(argument) { // eslint-disable-line no-unused-vars
333 if (argument === null || argument === undefined) {
336 return Object(argument);
340 /* global ToObject */
342 function GetV(v, p) { // eslint-disable-line no-unused-vars
343 // 1. Assert: IsPropertyKey(P) is true.
344 // 2. Let O be ? ToObject(V).
346 // 3. Return ? O.[[Get]](P, V).
350 // _ESAbstract.GetMethod
351 /* global GetV, IsCallable */
352 // 7.3.9. GetMethod ( V, P )
353 function GetMethod(V, P) { // eslint-disable-line no-unused-vars
354 // 1. Assert: IsPropertyKey(P) is true.
355 // 2. Let func be ? GetV(V, P).
356 var func = GetV(V, P);
357 // 3. If func is either undefined or null, return undefined.
358 if (func === null || func === undefined) {
361 // 4. If IsCallable(func) is false, throw a TypeError exception.
362 if (IsCallable(func) === false) {
363 throw new TypeError('Method not callable: ' + P);
369 // _ESAbstract.ToUint32
370 // 7.1.6. ToUint32 ( argument )
371 function ToUint32(argument) { // eslint-disable-line no-unused-vars
372 // 1. Let number be ? ToNumber(argument).
373 var number = Number(argument);
374 // 2. If number is NaN, +0, -0, +∞, or -∞, return +0.
375 if (isNaN(number) || 1/number === Infinity || 1/number === -Infinity || number === Infinity || number === -Infinity) {
378 // 3. Let int be the mathematical value that is the same sign as number and whose magnitude is floor(abs(number)).
379 var int = ((number < 0) ? -1 : 1) * Math.floor(Math.abs(number));
380 // 4. Let int32bit be int modulo 2^32.
381 var int32bit = int >>> 0;
382 // 5. Return int32bit.
387 // "Type(x)" is used as shorthand for "the type of x"...
388 function Type(x) { // eslint-disable-line no-unused-vars
401 // typeof null is 'object'
402 if (x === null) return 'null';
403 // Polyfill.io - This is here because a Symbol polyfill will have a typeof `object`.
404 if ('Symbol' in this && x instanceof this.Symbol) return 'symbol';
409 // _ESAbstract.GetPrototypeFromConstructor
410 /* global Get, Type */
411 // 9.1.14. GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
412 function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
413 // 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.
414 // 2. Assert: IsCallable(constructor) is true.
415 // 3. Let proto be ? Get(constructor, "prototype").
416 var proto = Get(constructor, "prototype");
417 // 4. If Type(proto) is not Object, then
418 if (Type(proto) !== 'object') {
419 // a. Let realm be ? GetFunctionRealm(constructor).
420 // b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
421 proto = intrinsicDefaultProto;
427 // _ESAbstract.IsConstructor
429 // 7.2.4. IsConstructor ( argument )
430 function IsConstructor(argument) { // eslint-disable-line no-unused-vars
431 // 1. If Type(argument) is not Object, return false.
432 if (Type(argument) !== 'object') {
435 // 2. If argument has a [[Construct]] internal method, return true.
438 // Polyfill.io - `new argument` is the only way to truly test if a function is a constructor.
439 // We choose to not use`new argument` because the argument could have side effects when called.
440 // Instead we check to see if the argument is a function and if it has a prototype.
441 // Arrow functions do not have a [[Construct]] internal method, nor do they have a prototype.
442 return typeof argument === 'function' && !!argument.prototype;
445 // _ESAbstract.IsRegExp
446 /* global Type, Get, ToBoolean */
447 // 7.2.8. IsRegExp ( argument )
448 function IsRegExp(argument) { // eslint-disable-line no-unused-vars
449 // 1. If Type(argument) is not Object, return false.
450 if (Type(argument) !== 'object') {
453 // 2. Let matcher be ? Get(argument, @@match).
454 var matcher = 'Symbol' in this && 'match' in this.Symbol ? Get(argument, this.Symbol.match) : undefined;
455 // 3. If matcher is not undefined, return ToBoolean(matcher).
456 if (matcher !== undefined) {
457 return ToBoolean(matcher);
459 // 4. If argument has a [[RegExpMatcher]] internal slot, return true.
461 var lastIndex = argument.lastIndex;
462 argument.lastIndex = 0;
463 RegExp.prototype.exec.call(argument);
465 } catch (e) {} finally {
466 argument.lastIndex = lastIndex;
472 // _ESAbstract.IteratorClose
473 /* global GetMethod, Type, Call */
474 // 7.4.6. IteratorClose ( iteratorRecord, completion )
475 function IteratorClose(iteratorRecord, completion) { // eslint-disable-line no-unused-vars
476 // 1. Assert: Type(iteratorRecord.[[Iterator]]) is Object.
477 if (Type(iteratorRecord['[[Iterator]]']) !== 'object') {
478 throw new Error(Object.prototype.toString.call(iteratorRecord['[[Iterator]]']) + 'is not an Object.');
480 // 2. Assert: completion is a Completion Record.
481 // Polyfill.io - Ignoring this step as there is no way to check if something is a Completion Record in userland JavaScript.
483 // 3. Let iterator be iteratorRecord.[[Iterator]].
484 var iterator = iteratorRecord['[[Iterator]]'];
485 // 4. Let return be ? GetMethod(iterator, "return").
486 // 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).
487 var returnMethod = GetMethod(iterator, "return");
488 // 5. If return is undefined, return Completion(completion).
489 if (returnMethod === undefined) {
492 // 6. Let innerResult be Call(return, iterator, « »).
494 var innerResult = Call(returnMethod, iterator);
496 var innerException = error;
498 // 7. If completion.[[Type]] is throw, return Completion(completion).
502 // 8. If innerResult.[[Type]] is throw, return Completion(innerResult).
503 if (innerException) {
504 throw innerException;
506 // 9. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
507 if (Type(innerResult) !== 'object') {
508 throw new TypeError("Iterator's return method returned a non-object.");
510 // 10. Return Completion(completion).
514 // _ESAbstract.IteratorComplete
515 /* global Type, ToBoolean, Get */
516 // 7.4.3 IteratorComplete ( iterResult )
517 function IteratorComplete(iterResult) { // eslint-disable-line no-unused-vars
518 // 1. Assert: Type(iterResult) is Object.
519 if (Type(iterResult) !== 'object') {
520 throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
522 // 2. Return ToBoolean(? Get(iterResult, "done")).
523 return ToBoolean(Get(iterResult, "done"));
526 // _ESAbstract.IteratorNext
527 /* global Call, Type */
528 // 7.4.2. IteratorNext ( iteratorRecord [ , value ] )
529 function IteratorNext(iteratorRecord /* [, value] */) { // eslint-disable-line no-unused-vars
530 // 1. If value is not present, then
531 if (arguments.length < 2) {
532 // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « »).
533 var result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']);
536 // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « value »).
537 result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]);
539 // 3. If Type(result) is not Object, throw a TypeError exception.
540 if (Type(result) !== 'object') {
541 throw new TypeError('bad iterator');
547 // _ESAbstract.IteratorStep
548 /* global IteratorNext, IteratorComplete */
549 // 7.4.5. IteratorStep ( iteratorRecord )
550 function IteratorStep(iteratorRecord) { // eslint-disable-line no-unused-vars
551 // 1. Let result be ? IteratorNext(iteratorRecord).
552 var result = IteratorNext(iteratorRecord);
553 // 2. Let done be ? IteratorComplete(result).
554 var done = IteratorComplete(result);
555 // 3. If done is true, return false.
563 // _ESAbstract.IteratorValue
564 /* global Type, Get */
565 // 7.4.4 IteratorValue ( iterResult )
566 function IteratorValue(iterResult) { // eslint-disable-line no-unused-vars
567 // Assert: Type(iterResult) is Object.
568 if (Type(iterResult) !== 'object') {
569 throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
571 // Return ? Get(iterResult, "value").
572 return Get(iterResult, "value");
575 // _ESAbstract.OrdinaryToPrimitive
576 /* global Get, IsCallable, Call, Type */
577 // 7.1.1.1. OrdinaryToPrimitive ( O, hint )
578 function OrdinaryToPrimitive(O, hint) { // eslint-disable-line no-unused-vars
579 // 1. Assert: Type(O) is Object.
580 // 2. Assert: Type(hint) is String and its value is either "string" or "number".
581 // 3. If hint is "string", then
582 if (hint === 'string') {
583 // a. Let methodNames be « "toString", "valueOf" ».
584 var methodNames = ['toString', 'valueOf'];
587 // a. Let methodNames be « "valueOf", "toString" ».
588 methodNames = ['valueOf', 'toString'];
590 // 5. For each name in methodNames in List order, do
591 for (var i = 0; i < methodNames.length; ++i) {
592 var name = methodNames[i];
593 // a. Let method be ? Get(O, name).
594 var method = Get(O, name);
595 // b. If IsCallable(method) is true, then
596 if (IsCallable(method)) {
597 // i. Let result be ? Call(method, O).
598 var result = Call(method, O);
599 // ii. If Type(result) is not Object, return result.
600 if (Type(result) !== 'object') {
605 // 6. Throw a TypeError exception.
606 throw new TypeError('Cannot convert to primitive.');
609 // _ESAbstract.SameValue
610 /* global Type, SameValueNonNumber */
611 // 7.2.10. SameValue ( x, y )
612 function SameValue(x, y) { // eslint-disable-line no-unused-vars
613 // 1. If Type(x) is different from Type(y), return false.
614 if (Type(x) !== Type(y)) {
617 // 2. If Type(x) is Number, then
618 if (Type(x) === 'number') {
619 // a. If x is NaN and y is NaN, return true.
620 if (isNaN(x) && isNaN(y)) {
623 // Polyfill.io - 0 === -0 is true, but they are not the same value.
624 // b. If x is +0 and y is -0, return false.
625 // c. If x is -0 and y is +0, return false.
626 if (x === 0 && y === 0 && 1/x !== 1/y) {
629 // d. If x is the same Number value as y, return true.
636 // 3. Return SameValueNonNumber(x, y).
637 return SameValueNonNumber(x, y);
640 // _ESAbstract.SameValueZero
641 /* global Type, SameValueNonNumber */
642 // 7.2.11. SameValueZero ( x, y )
643 function SameValueZero (x, y) { // eslint-disable-line no-unused-vars
644 // 1. If Type(x) is different from Type(y), return false.
645 if (Type(x) !== Type(y)) {
648 // 2. If Type(x) is Number, then
649 if (Type(x) === 'number') {
650 // a. If x is NaN and y is NaN, return true.
651 if (isNaN(x) && isNaN(y)) {
654 // b. If x is +0 and y is -0, return true.
655 if (1/x === Infinity && 1/y === -Infinity) {
658 // c. If x is -0 and y is +0, return true.
659 if (1/x === -Infinity && 1/y === Infinity) {
662 // d. If x is the same Number value as y, return true.
669 // 3. Return SameValueNonNumber(x, y).
670 return SameValueNonNumber(x, y);
673 // _ESAbstract.ToPrimitive
674 /* global Type, GetMethod, Call, OrdinaryToPrimitive */
675 // 7.1.1. ToPrimitive ( input [ , PreferredType ] )
676 function ToPrimitive(input /* [, PreferredType] */) { // eslint-disable-line no-unused-vars
677 var PreferredType = arguments.length > 1 ? arguments[1] : undefined;
678 // 1. Assert: input is an ECMAScript language value.
679 // 2. If Type(input) is Object, then
680 if (Type(input) === 'object') {
681 // a. If PreferredType is not present, let hint be "default".
682 if (arguments.length < 2) {
683 var hint = 'default';
684 // b. Else if PreferredType is hint String, let hint be "string".
685 } else if (PreferredType === String) {
687 // c. Else PreferredType is hint Number, let hint be "number".
688 } else if (PreferredType === Number) {
691 // d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
692 var exoticToPrim = typeof this.Symbol === 'function' && typeof this.Symbol.toPrimitive === 'symbol' ? GetMethod(input, this.Symbol.toPrimitive) : undefined;
693 // e. If exoticToPrim is not undefined, then
694 if (exoticToPrim !== undefined) {
695 // i. Let result be ? Call(exoticToPrim, input, « hint »).
696 var result = Call(exoticToPrim, input, [hint]);
697 // ii. If Type(result) is not Object, return result.
698 if (Type(result) !== 'object') {
701 // iii. Throw a TypeError exception.
702 throw new TypeError('Cannot convert exotic object to primitive.');
704 // f. If hint is "default", set hint to "number".
705 if (hint === 'default') {
708 // g. Return ? OrdinaryToPrimitive(input, hint).
709 return OrdinaryToPrimitive(input, hint);
715 // _ESAbstract.ToString
716 /* global Type, ToPrimitive */
717 // 7.1.12. ToString ( argument )
718 // The abstract operation ToString converts argument to a value of type String according to Table 11:
719 // Table 11: ToString Conversions
721 |---------------|--------------------------------------------------------|
722 | Argument Type | Result |
723 |---------------|--------------------------------------------------------|
724 | Undefined | Return "undefined". |
725 |---------------|--------------------------------------------------------|
726 | Null | Return "null". |
727 |---------------|--------------------------------------------------------|
728 | Boolean | If argument is true, return "true". |
729 | | If argument is false, return "false". |
730 |---------------|--------------------------------------------------------|
731 | Number | Return NumberToString(argument). |
732 |---------------|--------------------------------------------------------|
733 | String | Return argument. |
734 |---------------|--------------------------------------------------------|
735 | Symbol | Throw a TypeError exception. |
736 |---------------|--------------------------------------------------------|
737 | Object | Apply the following steps: |
738 | | Let primValue be ? ToPrimitive(argument, hint String). |
739 | | Return ? ToString(primValue). |
740 |---------------|--------------------------------------------------------|
742 function ToString(argument) { // eslint-disable-line no-unused-vars
743 switch(Type(argument)) {
745 throw new TypeError('Cannot convert a Symbol value to a string');
748 var primValue = ToPrimitive(argument, 'string');
749 return ToString(primValue);
751 return String(argument);
755 // _ESAbstract.UTF16Decode
756 // 10.1.2. Static Semantics: UTF16Decode( lead, trail )
757 function UTF16Decode(lead, trail) { // eslint-disable-line no-unused-vars
758 // 1. Assert: 0xD800 ≤ lead ≤ 0xDBFF and 0xDC00 ≤ trail ≤ 0xDFFF.
759 // 2. Let cp be (lead - 0xD800) × 0x400 + (trail - 0xDC00) + 0x10000.
760 var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
761 // 3. Return the code point cp.
765 // _ESAbstract.UTF16Encoding
766 // 10.1.1. Static Semantics: UTF16Encoding ( cp )
767 function UTF16Encoding(cp) { // eslint-disable-line no-unused-vars
768 // 1. Assert: 0 ≤ cp ≤ 0x10FFFF.
769 // 2. If cp ≤ 0xFFFF, return cp.
773 // 3. Let cu1 be floor((cp - 0x10000) / 0x400) + 0xD800.
774 var cu1 = Math.floor((cp - 0x10000) / 0x400) + 0xD800;
775 // 4. Let cu2 be ((cp - 0x10000) modulo 0x400) + 0xDC00.
776 var cu2 = ((cp - 0x10000) % 0x400) + 0xDC00;
777 // 5. Return the code unit sequence consisting of cu1 followed by cu2.
784 Copyright (c) 2010, Linden Research, Inc.
785 Copyright (c) 2014, Joshua Bell
787 Permission is hereby granted, free of charge, to any person obtaining a copy
788 of this software and associated documentation files (the "Software"), to deal
789 in the Software without restriction, including without limitation the rights
790 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
791 copies of the Software, and to permit persons to whom the Software is
792 furnished to do so, subject to the following conditions:
794 The above copyright notice and this permission notice shall be included in
795 all copies or substantial portions of the Software.
797 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
798 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
799 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
800 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
801 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
802 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
807 // Original can be found at:
808 // https://bitbucket.org/lindenlab/llsd
809 // Modifications by Joshua Bell inexorabletash@gmail.com
810 // https://github.com/inexorabletash/polyfill
812 // ES3/ES5 implementation of the Krhonos Typed Array Specification
813 // Ref: http://www.khronos.org/registry/typedarray/specs/latest/
817 // * Allows typed_array.get/set() as alias for subscripts (typed_array[])
818 // * Gradually migrating structure from Khronos spec to ES2015 spec
821 // * Beyond 10000 or so entries, polyfilled array accessors (ta[0],
822 // etc) become memory-prohibitive, so array creation will fail. Set
823 // self.TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS=true to disable
824 // creation of accessors. Your code will need to use the
825 // non-standard get()/set() instead, and will need to add those to
826 // native arrays for interop.
829 var undefined = (void 0); // Paranoia
831 // Beyond this value, index getters/setters (i.e. array[0], array[1]) are so slow to
832 // create, and consume so much memory, that the browser appears frozen.
833 var MAX_ARRAY_LENGTH = 1e5;
835 // Approximations of internal ECMAScript conversion functions
838 case 'undefined': return 'undefined';
839 case 'boolean': return 'boolean';
840 case 'number': return 'number';
841 case 'string': return 'string';
842 default: return v === null ? 'null' : 'object';
846 // Class returns internal [[Class]] property, used to avoid cross-frame instanceof issues:
847 function Class(v) { return Object.prototype.toString.call(v).replace(/^\[object *|\]$/g, ''); }
848 function IsCallable(o) { return typeof o === 'function'; }
849 function ToObject(v) {
850 if (v === null || v === undefined) throw TypeError();
853 function ToInt32(v) { return v >> 0; }
854 function ToUint32(v) { return v >>> 0; }
856 // Snapshot intrinsics
866 // emulate ES5 getter/setter API using legacy APIs
867 // http://blogs.msdn.com/b/ie/archive/2010/09/07/transitioning-existing-code-to-the-es5-getter-setter-apis.aspx
868 // (second clause tests for Object.defineProperty() in IE<9 that only supports extending DOM prototypes, but
869 // note that IE<9 does not support __defineGetter__ or __defineSetter__ so it just renders the method harmless)
872 var orig = Object.defineProperty;
873 var dom_only = !(function(){try{return Object.defineProperty({},'x',{});}catch(_){return false;}}());
875 if (!orig || dom_only) {
876 Object.defineProperty = function (o, prop, desc) {
877 // In IE8 try built-in implementation for defining properties on DOM prototypes.
879 try { return orig(o, prop, desc); } catch (_) {}
881 throw TypeError('Object.defineProperty called on non-object');
882 if (Object.prototype.__defineGetter__ && ('get' in desc))
883 Object.prototype.__defineGetter__.call(o, prop, desc.get);
884 if (Object.prototype.__defineSetter__ && ('set' in desc))
885 Object.prototype.__defineSetter__.call(o, prop, desc.set);
887 o[prop] = desc.value;
893 // ES5: Make obj[index] an alias for obj._getter(index)/obj._setter(index, value)
894 // for index in 0 ... obj.length
895 function makeArrayAccessors(obj) {
896 if ('TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS' in global)
899 if (obj.length > MAX_ARRAY_LENGTH) throw RangeError('Array too large for polyfill');
901 function makeArrayAccessor(index) {
902 Object.defineProperty(obj, index, {
903 'get': function() { return obj._getter(index); },
904 'set': function(v) { obj._setter(index, v); },
911 for (i = 0; i < obj.length; i += 1) {
912 makeArrayAccessor(i);
916 // Internal conversion functions:
917 // pack<Type>() - take a number (interpreted as Type), output a byte array
918 // unpack<Type>() - take a byte array, output a Type-like number
920 function as_signed(value, bits) { var s = 32 - bits; return (value << s) >> s; }
921 function as_unsigned(value, bits) { var s = 32 - bits; return (value << s) >>> s; }
923 function packI8(n) { return [n & 0xff]; }
924 function unpackI8(bytes) { return as_signed(bytes[0], 8); }
926 function packU8(n) { return [n & 0xff]; }
927 function unpackU8(bytes) { return as_unsigned(bytes[0], 8); }
929 function packU8Clamped(n) { n = round(Number(n)); return [n < 0 ? 0 : n > 0xff ? 0xff : n & 0xff]; }
931 function packI16(n) { return [n & 0xff, (n >> 8) & 0xff]; }
932 function unpackI16(bytes) { return as_signed(bytes[1] << 8 | bytes[0], 16); }
934 function packU16(n) { return [n & 0xff, (n >> 8) & 0xff]; }
935 function unpackU16(bytes) { return as_unsigned(bytes[1] << 8 | bytes[0], 16); }
937 function packI32(n) { return [n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, (n >> 24) & 0xff]; }
938 function unpackI32(bytes) { return as_signed(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0], 32); }
940 function packU32(n) { return [n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, (n >> 24) & 0xff]; }
941 function unpackU32(bytes) { return as_unsigned(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0], 32); }
943 function packIEEE754(v, ebits, fbits) {
945 var bias = (1 << (ebits - 1)) - 1;
947 function roundToEven(n) {
948 var w = floor(n), f = n - w;
953 return w % 2 ? w + 1 : w;
956 // Compute sign, exponent, fraction
960 // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping
961 e = (1 << ebits) - 1; f = pow(2, fbits - 1); s = 0;
962 } else if (v === Infinity || v === -Infinity) {
963 e = (1 << ebits) - 1; f = 0; s = (v < 0) ? 1 : 0;
964 } else if (v === 0) {
965 e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0;
970 if (v >= pow(2, 1 - bias)) {
972 e = min(floor(log(v) / LN2), 1023);
973 var significand = v / pow(2, e);
974 if (significand < 1) {
978 if (significand >= 2) {
982 var d = pow(2, fbits);
983 f = roundToEven(significand * d) - d;
991 e = (1 << ebits) - 1;
997 f = roundToEven(v / pow(2, 1 - bias - fbits));
1001 // Pack sign, exponent, fraction
1003 for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = floor(f / 2); }
1004 for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = floor(e / 2); }
1005 bits.push(s ? 1 : 0);
1007 var str = bits.join('');
1011 while (str.length) {
1012 bytes.unshift(parseInt(str.substring(0, 8), 2));
1013 str = str.substring(8);
1018 function unpackIEEE754(bytes, ebits, fbits) {
1020 var bits = [], i, j, b, str,
1023 for (i = 0; i < bytes.length; ++i) {
1025 for (j = 8; j; j -= 1) {
1026 bits.push(b % 2 ? 1 : 0); b = b >> 1;
1030 str = bits.join('');
1032 // Unpack sign, exponent, fraction
1033 bias = (1 << (ebits - 1)) - 1;
1034 s = parseInt(str.substring(0, 1), 2) ? -1 : 1;
1035 e = parseInt(str.substring(1, 1 + ebits), 2);
1036 f = parseInt(str.substring(1 + ebits), 2);
1039 if (e === (1 << ebits) - 1) {
1040 return f !== 0 ? NaN : s * Infinity;
1043 return s * pow(2, e - bias) * (1 + f / pow(2, fbits));
1044 } else if (f !== 0) {
1046 return s * pow(2, -(bias - 1)) * (f / pow(2, fbits));
1048 return s < 0 ? -0 : 0;
1052 function unpackF64(b) { return unpackIEEE754(b, 11, 52); }
1053 function packF64(v) { return packIEEE754(v, 11, 52); }
1054 function unpackF32(b) { return unpackIEEE754(b, 8, 23); }
1055 function packF32(v) { return packIEEE754(v, 8, 23); }
1058 // 3 The ArrayBuffer Type
1063 function ArrayBuffer(length) {
1064 length = ToInt32(length);
1065 if (length < 0) throw RangeError('ArrayBuffer size is not a small enough positive integer.');
1066 Object.defineProperty(this, 'byteLength', {value: length});
1067 Object.defineProperty(this, '_bytes', {value: Array(length)});
1069 for (var i = 0; i < length; i += 1)
1073 global.ArrayBuffer = global.ArrayBuffer || ArrayBuffer;
1076 // 5 The Typed Array View Types
1079 function $TypedArray$() {
1081 // %TypedArray% ( length )
1082 if (!arguments.length || typeof arguments[0] !== 'object') {
1083 return (function(length) {
1084 length = ToInt32(length);
1085 if (length < 0) throw RangeError('length is not a small enough positive integer.');
1086 Object.defineProperty(this, 'length', {value: length});
1087 Object.defineProperty(this, 'byteLength', {value: length * this.BYTES_PER_ELEMENT});
1088 Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(this.byteLength)});
1089 Object.defineProperty(this, 'byteOffset', {value: 0});
1091 }).apply(this, arguments);
1094 // %TypedArray% ( typedArray )
1095 if (arguments.length >= 1 &&
1096 Type(arguments[0]) === 'object' &&
1097 arguments[0] instanceof $TypedArray$) {
1098 return (function(typedArray){
1099 if (this.constructor !== typedArray.constructor) throw TypeError();
1101 var byteLength = typedArray.length * this.BYTES_PER_ELEMENT;
1102 Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(byteLength)});
1103 Object.defineProperty(this, 'byteLength', {value: byteLength});
1104 Object.defineProperty(this, 'byteOffset', {value: 0});
1105 Object.defineProperty(this, 'length', {value: typedArray.length});
1107 for (var i = 0; i < this.length; i += 1)
1108 this._setter(i, typedArray._getter(i));
1110 }).apply(this, arguments);
1113 // %TypedArray% ( array )
1114 if (arguments.length >= 1 &&
1115 Type(arguments[0]) === 'object' &&
1116 !(arguments[0] instanceof $TypedArray$) &&
1117 !(arguments[0] instanceof ArrayBuffer || Class(arguments[0]) === 'ArrayBuffer')) {
1118 return (function(array) {
1120 var byteLength = array.length * this.BYTES_PER_ELEMENT;
1121 Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(byteLength)});
1122 Object.defineProperty(this, 'byteLength', {value: byteLength});
1123 Object.defineProperty(this, 'byteOffset', {value: 0});
1124 Object.defineProperty(this, 'length', {value: array.length});
1126 for (var i = 0; i < this.length; i += 1) {
1128 this._setter(i, Number(s));
1130 }).apply(this, arguments);
1133 // %TypedArray% ( buffer, byteOffset=0, length=undefined )
1134 if (arguments.length >= 1 &&
1135 Type(arguments[0]) === 'object' &&
1136 (arguments[0] instanceof ArrayBuffer || Class(arguments[0]) === 'ArrayBuffer')) {
1137 return (function(buffer, byteOffset, length) {
1139 byteOffset = ToUint32(byteOffset);
1140 if (byteOffset > buffer.byteLength)
1141 throw RangeError('byteOffset out of range');
1143 // The given byteOffset must be a multiple of the element
1144 // size of the specific type, otherwise an exception is raised.
1145 if (byteOffset % this.BYTES_PER_ELEMENT)
1146 throw RangeError('buffer length minus the byteOffset is not a multiple of the element size.');
1148 if (length === undefined) {
1149 var byteLength = buffer.byteLength - byteOffset;
1150 if (byteLength % this.BYTES_PER_ELEMENT)
1151 throw RangeError('length of buffer minus byteOffset not a multiple of the element size');
1152 length = byteLength / this.BYTES_PER_ELEMENT;
1155 length = ToUint32(length);
1156 byteLength = length * this.BYTES_PER_ELEMENT;
1159 if ((byteOffset + byteLength) > buffer.byteLength)
1160 throw RangeError('byteOffset and length reference an area beyond the end of the buffer');
1162 Object.defineProperty(this, 'buffer', {value: buffer});
1163 Object.defineProperty(this, 'byteLength', {value: byteLength});
1164 Object.defineProperty(this, 'byteOffset', {value: byteOffset});
1165 Object.defineProperty(this, 'length', {value: length});
1167 }).apply(this, arguments);
1170 // %TypedArray% ( all other argument combinations )
1174 // Properties of the %TypedArray Instrinsic Object
1176 // %TypedArray%.from ( source , mapfn=undefined, thisArg=undefined )
1177 Object.defineProperty($TypedArray$, 'from', {value: function(iterable) {
1178 return new this(iterable);
1181 // %TypedArray%.of ( ...items )
1182 Object.defineProperty($TypedArray$, 'of', {value: function(/*...items*/) {
1183 return new this(arguments);
1186 // %TypedArray%.prototype
1187 var $TypedArrayPrototype$ = {};
1188 $TypedArray$.prototype = $TypedArrayPrototype$;
1190 // WebIDL: getter type (unsigned long index);
1191 Object.defineProperty($TypedArray$.prototype, '_getter', {value: function(index) {
1192 if (arguments.length < 1) throw SyntaxError('Not enough arguments');
1194 index = ToUint32(index);
1195 if (index >= this.length)
1198 var bytes = [], i, o;
1199 for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT;
1200 i < this.BYTES_PER_ELEMENT;
1202 bytes.push(this.buffer._bytes[o]);
1204 return this._unpack(bytes);
1207 // NONSTANDARD: convenience alias for getter: type get(unsigned long index);
1208 Object.defineProperty($TypedArray$.prototype, 'get', {value: $TypedArray$.prototype._getter});
1210 // WebIDL: setter void (unsigned long index, type value);
1211 Object.defineProperty($TypedArray$.prototype, '_setter', {value: function(index, value) {
1212 if (arguments.length < 2) throw SyntaxError('Not enough arguments');
1214 index = ToUint32(index);
1215 if (index >= this.length)
1218 var bytes = this._pack(value), i, o;
1219 for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT;
1220 i < this.BYTES_PER_ELEMENT;
1222 this.buffer._bytes[o] = bytes[i];
1226 // get %TypedArray%.prototype.buffer
1227 // get %TypedArray%.prototype.byteLength
1228 // get %TypedArray%.prototype.byteOffset
1229 // -- applied directly to the object in the constructor
1231 // %TypedArray%.prototype.constructor
1232 Object.defineProperty($TypedArray$.prototype, 'constructor', {value: $TypedArray$});
1234 // %TypedArray%.prototype.copyWithin (target, start, end = this.length )
1235 Object.defineProperty($TypedArray$.prototype, 'copyWithin', {value: function(target, start) {
1236 var end = arguments[2];
1238 var o = ToObject(this);
1239 var lenVal = o.length;
1240 var len = ToUint32(lenVal);
1242 var relativeTarget = ToInt32(target);
1244 if (relativeTarget < 0)
1245 to = max(len + relativeTarget, 0);
1247 to = min(relativeTarget, len);
1248 var relativeStart = ToInt32(start);
1250 if (relativeStart < 0)
1251 from = max(len + relativeStart, 0);
1253 from = min(relativeStart, len);
1255 if (end === undefined)
1258 relativeEnd = ToInt32(end);
1260 if (relativeEnd < 0)
1261 final = max(len + relativeEnd, 0);
1263 final = min(relativeEnd, len);
1264 var count = min(final - from, len - to);
1266 if (from < to && to < from + count) {
1268 from = from + count - 1;
1269 to = to + count - 1;
1274 o._setter(to, o._getter(from));
1275 from = from + direction;
1276 to = to + direction;
1282 // %TypedArray%.prototype.entries ( )
1283 // -- defined in es6.js to shim browsers w/ native TypedArrays
1285 // %TypedArray%.prototype.every ( callbackfn, thisArg = undefined )
1286 Object.defineProperty($TypedArray$.prototype, 'every', {value: function(callbackfn) {
1287 if (this === undefined || this === null) throw TypeError();
1288 var t = Object(this);
1289 var len = ToUint32(t.length);
1290 if (!IsCallable(callbackfn)) throw TypeError();
1291 var thisArg = arguments[1];
1292 for (var i = 0; i < len; i++) {
1293 if (!callbackfn.call(thisArg, t._getter(i), i, t))
1299 // %TypedArray%.prototype.fill (value, start = 0, end = this.length )
1300 Object.defineProperty($TypedArray$.prototype, 'fill', {value: function(value) {
1301 var start = arguments[1],
1304 var o = ToObject(this);
1305 var lenVal = o.length;
1306 var len = ToUint32(lenVal);
1308 var relativeStart = ToInt32(start);
1310 if (relativeStart < 0)
1311 k = max((len + relativeStart), 0);
1313 k = min(relativeStart, len);
1315 if (end === undefined)
1318 relativeEnd = ToInt32(end);
1320 if (relativeEnd < 0)
1321 final = max((len + relativeEnd), 0);
1323 final = min(relativeEnd, len);
1325 o._setter(k, value);
1331 // %TypedArray%.prototype.filter ( callbackfn, thisArg = undefined )
1332 Object.defineProperty($TypedArray$.prototype, 'filter', {value: function(callbackfn) {
1333 if (this === undefined || this === null) throw TypeError();
1334 var t = Object(this);
1335 var len = ToUint32(t.length);
1336 if (!IsCallable(callbackfn)) throw TypeError();
1338 var thisp = arguments[1];
1339 for (var i = 0; i < len; i++) {
1340 var val = t._getter(i); // in case fun mutates this
1341 if (callbackfn.call(thisp, val, i, t))
1344 return new this.constructor(res);
1347 // %TypedArray%.prototype.find (predicate, thisArg = undefined)
1348 Object.defineProperty($TypedArray$.prototype, 'find', {value: function(predicate) {
1349 var o = ToObject(this);
1350 var lenValue = o.length;
1351 var len = ToUint32(lenValue);
1352 if (!IsCallable(predicate)) throw TypeError();
1353 var t = arguments.length > 1 ? arguments[1] : undefined;
1356 var kValue = o._getter(k);
1357 var testResult = predicate.call(t, kValue, k, o);
1358 if (Boolean(testResult))
1365 // %TypedArray%.prototype.findIndex ( predicate, thisArg = undefined )
1366 Object.defineProperty($TypedArray$.prototype, 'findIndex', {value: function(predicate) {
1367 var o = ToObject(this);
1368 var lenValue = o.length;
1369 var len = ToUint32(lenValue);
1370 if (!IsCallable(predicate)) throw TypeError();
1371 var t = arguments.length > 1 ? arguments[1] : undefined;
1374 var kValue = o._getter(k);
1375 var testResult = predicate.call(t, kValue, k, o);
1376 if (Boolean(testResult))
1383 // %TypedArray%.prototype.forEach ( callbackfn, thisArg = undefined )
1384 Object.defineProperty($TypedArray$.prototype, 'forEach', {value: function(callbackfn) {
1385 if (this === undefined || this === null) throw TypeError();
1386 var t = Object(this);
1387 var len = ToUint32(t.length);
1388 if (!IsCallable(callbackfn)) throw TypeError();
1389 var thisp = arguments[1];
1390 for (var i = 0; i < len; i++)
1391 callbackfn.call(thisp, t._getter(i), i, t);
1394 // %TypedArray%.prototype.indexOf (searchElement, fromIndex = 0 )
1395 Object.defineProperty($TypedArray$.prototype, 'indexOf', {value: function(searchElement) {
1396 if (this === undefined || this === null) throw TypeError();
1397 var t = Object(this);
1398 var len = ToUint32(t.length);
1399 if (len === 0) return -1;
1401 if (arguments.length > 0) {
1402 n = Number(arguments[1]);
1405 } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
1406 n = (n > 0 || -1) * floor(abs(n));
1409 if (n >= len) return -1;
1410 var k = n >= 0 ? n : max(len - abs(n), 0);
1411 for (; k < len; k++) {
1412 if (t._getter(k) === searchElement) {
1419 // %TypedArray%.prototype.join ( separator )
1420 Object.defineProperty($TypedArray$.prototype, 'join', {value: function(separator) {
1421 if (this === undefined || this === null) throw TypeError();
1422 var t = Object(this);
1423 var len = ToUint32(t.length);
1424 var tmp = Array(len);
1425 for (var i = 0; i < len; ++i)
1426 tmp[i] = t._getter(i);
1427 return tmp.join(separator === undefined ? ',' : separator); // Hack for IE7
1430 // %TypedArray%.prototype.keys ( )
1431 // -- defined in es6.js to shim browsers w/ native TypedArrays
1433 // %TypedArray%.prototype.lastIndexOf ( searchElement, fromIndex = this.length-1 )
1434 Object.defineProperty($TypedArray$.prototype, 'lastIndexOf', {value: function(searchElement) {
1435 if (this === undefined || this === null) throw TypeError();
1436 var t = Object(this);
1437 var len = ToUint32(t.length);
1438 if (len === 0) return -1;
1440 if (arguments.length > 1) {
1441 n = Number(arguments[1]);
1444 } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
1445 n = (n > 0 || -1) * floor(abs(n));
1448 var k = n >= 0 ? min(n, len - 1) : len - abs(n);
1449 for (; k >= 0; k--) {
1450 if (t._getter(k) === searchElement)
1456 // get %TypedArray%.prototype.length
1457 // -- applied directly to the object in the constructor
1459 // %TypedArray%.prototype.map ( callbackfn, thisArg = undefined )
1460 Object.defineProperty($TypedArray$.prototype, 'map', {value: function(callbackfn) {
1461 if (this === undefined || this === null) throw TypeError();
1462 var t = Object(this);
1463 var len = ToUint32(t.length);
1464 if (!IsCallable(callbackfn)) throw TypeError();
1465 var res = []; res.length = len;
1466 var thisp = arguments[1];
1467 for (var i = 0; i < len; i++)
1468 res[i] = callbackfn.call(thisp, t._getter(i), i, t);
1469 return new this.constructor(res);
1472 // %TypedArray%.prototype.reduce ( callbackfn [, initialValue] )
1473 Object.defineProperty($TypedArray$.prototype, 'reduce', {value: function(callbackfn) {
1474 if (this === undefined || this === null) throw TypeError();
1475 var t = Object(this);
1476 var len = ToUint32(t.length);
1477 if (!IsCallable(callbackfn)) throw TypeError();
1478 // no value to return if no initial value and an empty array
1479 if (len === 0 && arguments.length === 1) throw TypeError();
1482 if (arguments.length >= 2) {
1483 accumulator = arguments[1];
1485 accumulator = t._getter(k++);
1488 accumulator = callbackfn.call(undefined, accumulator, t._getter(k), k, t);
1494 // %TypedArray%.prototype.reduceRight ( callbackfn [, initialValue] )
1495 Object.defineProperty($TypedArray$.prototype, 'reduceRight', {value: function(callbackfn) {
1496 if (this === undefined || this === null) throw TypeError();
1497 var t = Object(this);
1498 var len = ToUint32(t.length);
1499 if (!IsCallable(callbackfn)) throw TypeError();
1500 // no value to return if no initial value, empty array
1501 if (len === 0 && arguments.length === 1) throw TypeError();
1504 if (arguments.length >= 2) {
1505 accumulator = arguments[1];
1507 accumulator = t._getter(k--);
1510 accumulator = callbackfn.call(undefined, accumulator, t._getter(k), k, t);
1516 // %TypedArray%.prototype.reverse ( )
1517 Object.defineProperty($TypedArray$.prototype, 'reverse', {value: function() {
1518 if (this === undefined || this === null) throw TypeError();
1519 var t = Object(this);
1520 var len = ToUint32(t.length);
1521 var half = floor(len / 2);
1522 for (var i = 0, j = len - 1; i < half; ++i, --j) {
1523 var tmp = t._getter(i);
1524 t._setter(i, t._getter(j));
1530 // %TypedArray%.prototype.set(array, offset = 0 )
1531 // %TypedArray%.prototype.set(typedArray, offset = 0 )
1532 // WebIDL: void set(TypedArray array, optional unsigned long offset);
1533 // WebIDL: void set(sequence<type> array, optional unsigned long offset);
1534 Object.defineProperty($TypedArray$.prototype, 'set', {value: function(index, value) {
1535 if (arguments.length < 1) throw SyntaxError('Not enough arguments');
1536 var array, sequence, offset, len,
1538 byteOffset, byteLength, tmp;
1540 if (typeof arguments[0] === 'object' && arguments[0].constructor === this.constructor) {
1541 // void set(TypedArray array, optional unsigned long offset);
1542 array = arguments[0];
1543 offset = ToUint32(arguments[1]);
1545 if (offset + array.length > this.length) {
1546 throw RangeError('Offset plus length of array is out of range');
1549 byteOffset = this.byteOffset + offset * this.BYTES_PER_ELEMENT;
1550 byteLength = array.length * this.BYTES_PER_ELEMENT;
1552 if (array.buffer === this.buffer) {
1554 for (i = 0, s = array.byteOffset; i < byteLength; i += 1, s += 1) {
1555 tmp[i] = array.buffer._bytes[s];
1557 for (i = 0, d = byteOffset; i < byteLength; i += 1, d += 1) {
1558 this.buffer._bytes[d] = tmp[i];
1561 for (i = 0, s = array.byteOffset, d = byteOffset;
1562 i < byteLength; i += 1, s += 1, d += 1) {
1563 this.buffer._bytes[d] = array.buffer._bytes[s];
1566 } else if (typeof arguments[0] === 'object' && typeof arguments[0].length !== 'undefined') {
1567 // void set(sequence<type> array, optional unsigned long offset);
1568 sequence = arguments[0];
1569 len = ToUint32(sequence.length);
1570 offset = ToUint32(arguments[1]);
1572 if (offset + len > this.length) {
1573 throw RangeError('Offset plus length of array is out of range');
1576 for (i = 0; i < len; i += 1) {
1578 this._setter(offset + i, Number(s));
1581 throw TypeError('Unexpected argument type(s)');
1585 // %TypedArray%.prototype.slice ( start, end )
1586 Object.defineProperty($TypedArray$.prototype, 'slice', {value: function(start, end) {
1587 var o = ToObject(this);
1588 var lenVal = o.length;
1589 var len = ToUint32(lenVal);
1590 var relativeStart = ToInt32(start);
1591 var k = (relativeStart < 0) ? max(len + relativeStart, 0) : min(relativeStart, len);
1592 var relativeEnd = (end === undefined) ? len : ToInt32(end);
1593 var final = (relativeEnd < 0) ? max(len + relativeEnd, 0) : min(relativeEnd, len);
1594 var count = final - k;
1595 var c = o.constructor;
1596 var a = new c(count);
1599 var kValue = o._getter(k);
1600 a._setter(n, kValue);
1607 // %TypedArray%.prototype.some ( callbackfn, thisArg = undefined )
1608 Object.defineProperty($TypedArray$.prototype, 'some', {value: function(callbackfn) {
1609 if (this === undefined || this === null) throw TypeError();
1610 var t = Object(this);
1611 var len = ToUint32(t.length);
1612 if (!IsCallable(callbackfn)) throw TypeError();
1613 var thisp = arguments[1];
1614 for (var i = 0; i < len; i++) {
1615 if (callbackfn.call(thisp, t._getter(i), i, t)) {
1622 // %TypedArray%.prototype.sort ( comparefn )
1623 Object.defineProperty($TypedArray$.prototype, 'sort', {value: function(comparefn) {
1624 if (this === undefined || this === null) throw TypeError();
1625 var t = Object(this);
1626 var len = ToUint32(t.length);
1627 var tmp = Array(len);
1628 for (var i = 0; i < len; ++i)
1629 tmp[i] = t._getter(i);
1630 function sortCompare(x, y) {
1631 if (x !== x && y !== y) return +0;
1632 if (x !== x) return 1;
1633 if (y !== y) return -1;
1634 if (comparefn !== undefined) {
1635 return comparefn(x, y);
1637 if (x < y) return -1;
1638 if (x > y) return 1;
1641 tmp.sort(sortCompare);
1642 for (i = 0; i < len; ++i)
1643 t._setter(i, tmp[i]);
1647 // %TypedArray%.prototype.subarray(begin = 0, end = this.length )
1648 // WebIDL: TypedArray subarray(long begin, optional long end);
1649 Object.defineProperty($TypedArray$.prototype, 'subarray', {value: function(start, end) {
1650 function clamp(v, min, max) { return v < min ? min : v > max ? max : v; }
1652 start = ToInt32(start);
1655 if (arguments.length < 1) { start = 0; }
1656 if (arguments.length < 2) { end = this.length; }
1658 if (start < 0) { start = this.length + start; }
1659 if (end < 0) { end = this.length + end; }
1661 start = clamp(start, 0, this.length);
1662 end = clamp(end, 0, this.length);
1664 var len = end - start;
1669 return new this.constructor(
1670 this.buffer, this.byteOffset + start * this.BYTES_PER_ELEMENT, len);
1673 // %TypedArray%.prototype.toLocaleString ( )
1674 // %TypedArray%.prototype.toString ( )
1675 // %TypedArray%.prototype.values ( )
1676 // %TypedArray%.prototype [ @@iterator ] ( )
1677 // get %TypedArray%.prototype [ @@toStringTag ]
1678 // -- defined in es6.js to shim browsers w/ native TypedArrays
1680 function makeTypedArray(elementSize, pack, unpack) {
1681 // Each TypedArray type requires a distinct constructor instance with
1682 // identical logic, which this produces.
1683 var TypedArray = function() {
1684 Object.defineProperty(this, 'constructor', {value: TypedArray});
1685 $TypedArray$.apply(this, arguments);
1686 makeArrayAccessors(this);
1688 if ('__proto__' in TypedArray) {
1689 TypedArray.__proto__ = $TypedArray$;
1691 TypedArray.from = $TypedArray$.from;
1692 TypedArray.of = $TypedArray$.of;
1695 TypedArray.BYTES_PER_ELEMENT = elementSize;
1697 var TypedArrayPrototype = function() {};
1698 TypedArrayPrototype.prototype = $TypedArrayPrototype$;
1700 TypedArray.prototype = new TypedArrayPrototype();
1702 Object.defineProperty(TypedArray.prototype, 'BYTES_PER_ELEMENT', {value: elementSize});
1703 Object.defineProperty(TypedArray.prototype, '_pack', {value: pack});
1704 Object.defineProperty(TypedArray.prototype, '_unpack', {value: unpack});
1709 var Int8Array = makeTypedArray(1, packI8, unpackI8);
1710 var Uint8Array = makeTypedArray(1, packU8, unpackU8);
1711 var Uint8ClampedArray = makeTypedArray(1, packU8Clamped, unpackU8);
1712 var Int16Array = makeTypedArray(2, packI16, unpackI16);
1713 var Uint16Array = makeTypedArray(2, packU16, unpackU16);
1714 var Int32Array = makeTypedArray(4, packI32, unpackI32);
1715 var Uint32Array = makeTypedArray(4, packU32, unpackU32);
1716 var Float32Array = makeTypedArray(4, packF32, unpackF32);
1717 var Float64Array = makeTypedArray(8, packF64, unpackF64);
1719 global.Int8Array = global.Int8Array || Int8Array;
1720 global.Uint8Array = global.Uint8Array || Uint8Array;
1721 global.Uint8ClampedArray = global.Uint8ClampedArray || Uint8ClampedArray;
1722 global.Int16Array = global.Int16Array || Int16Array;
1723 global.Uint16Array = global.Uint16Array || Uint16Array;
1724 global.Int32Array = global.Int32Array || Int32Array;
1725 global.Uint32Array = global.Uint32Array || Uint32Array;
1726 global.Float32Array = global.Float32Array || Float32Array;
1727 global.Float64Array = global.Float64Array || Float64Array;
1731 // 6 The DataView View Type
1735 function r(array, index) {
1736 return IsCallable(array.get) ? array.get(index) : array[index];
1739 var IS_BIG_ENDIAN = (function() {
1740 var u16array = new Uint16Array([0x1234]),
1741 u8array = new Uint8Array(u16array.buffer);
1742 return r(u8array, 0) === 0x12;
1745 // DataView(buffer, byteOffset=0, byteLength=undefined)
1746 // WebIDL: Constructor(ArrayBuffer buffer,
1747 // optional unsigned long byteOffset,
1748 // optional unsigned long byteLength)
1749 function DataView(buffer, byteOffset, byteLength) {
1750 if (!(buffer instanceof ArrayBuffer || Class(buffer) === 'ArrayBuffer')) throw TypeError();
1752 byteOffset = ToUint32(byteOffset);
1753 if (byteOffset > buffer.byteLength)
1754 throw RangeError('byteOffset out of range');
1756 if (byteLength === undefined)
1757 byteLength = buffer.byteLength - byteOffset;
1759 byteLength = ToUint32(byteLength);
1761 if ((byteOffset + byteLength) > buffer.byteLength)
1762 throw RangeError('byteOffset and length reference an area beyond the end of the buffer');
1764 Object.defineProperty(this, 'buffer', {value: buffer});
1765 Object.defineProperty(this, 'byteLength', {value: byteLength});
1766 Object.defineProperty(this, 'byteOffset', {value: byteOffset});
1769 // get DataView.prototype.buffer
1770 // get DataView.prototype.byteLength
1771 // get DataView.prototype.byteOffset
1772 // -- applied directly to instances by the constructor
1774 function makeGetter(arrayType) {
1775 return function GetViewValue(byteOffset, littleEndian) {
1776 byteOffset = ToUint32(byteOffset);
1778 if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength)
1779 throw RangeError('Array index out of range');
1781 byteOffset += this.byteOffset;
1783 var uint8Array = new Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT),
1785 for (var i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1)
1786 bytes.push(r(uint8Array, i));
1788 if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN))
1791 return r(new arrayType(new Uint8Array(bytes).buffer), 0);
1795 Object.defineProperty(DataView.prototype, 'getUint8', {value: makeGetter(Uint8Array)});
1796 Object.defineProperty(DataView.prototype, 'getInt8', {value: makeGetter(Int8Array)});
1797 Object.defineProperty(DataView.prototype, 'getUint16', {value: makeGetter(Uint16Array)});
1798 Object.defineProperty(DataView.prototype, 'getInt16', {value: makeGetter(Int16Array)});
1799 Object.defineProperty(DataView.prototype, 'getUint32', {value: makeGetter(Uint32Array)});
1800 Object.defineProperty(DataView.prototype, 'getInt32', {value: makeGetter(Int32Array)});
1801 Object.defineProperty(DataView.prototype, 'getFloat32', {value: makeGetter(Float32Array)});
1802 Object.defineProperty(DataView.prototype, 'getFloat64', {value: makeGetter(Float64Array)});
1804 function makeSetter(arrayType) {
1805 return function SetViewValue(byteOffset, value, littleEndian) {
1806 byteOffset = ToUint32(byteOffset);
1807 if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength)
1808 throw RangeError('Array index out of range');
1811 var typeArray = new arrayType([value]),
1812 byteArray = new Uint8Array(typeArray.buffer),
1813 bytes = [], i, byteView;
1815 for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1)
1816 bytes.push(r(byteArray, i));
1818 // Flip if necessary
1819 if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN))
1823 byteView = new Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT);
1824 byteView.set(bytes);
1828 Object.defineProperty(DataView.prototype, 'setUint8', {value: makeSetter(Uint8Array)});
1829 Object.defineProperty(DataView.prototype, 'setInt8', {value: makeSetter(Int8Array)});
1830 Object.defineProperty(DataView.prototype, 'setUint16', {value: makeSetter(Uint16Array)});
1831 Object.defineProperty(DataView.prototype, 'setInt16', {value: makeSetter(Int16Array)});
1832 Object.defineProperty(DataView.prototype, 'setUint32', {value: makeSetter(Uint32Array)});
1833 Object.defineProperty(DataView.prototype, 'setInt32', {value: makeSetter(Int32Array)});
1834 Object.defineProperty(DataView.prototype, 'setFloat32', {value: makeSetter(Float32Array)});
1835 Object.defineProperty(DataView.prototype, 'setFloat64', {value: makeSetter(Float64Array)});
1837 global.DataView = global.DataView || DataView;
1842 if (!("defineProperty"in Object&&function(){try{var e={}
1843 return Object.defineProperty(e,"test",{value:42}),!0}catch(t){return!1}}()
1846 // Object.defineProperty
1847 (function (nativeDefineProperty) {
1849 var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
1850 var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
1851 var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
1853 // Polyfill.io - This does not use CreateMethodProperty because our CreateMethodProperty function uses Object.defineProperty.
1854 Object['defineProperty'] = function defineProperty(object, property, descriptor) {
1856 // Where native support exists, assume it
1857 if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
1858 return nativeDefineProperty(object, property, descriptor);
1861 if (object === null || !(object instanceof Object || typeof object === 'object')) {
1862 throw new TypeError('Object.defineProperty called on non-object');
1865 if (!(descriptor instanceof Object)) {
1866 throw new TypeError('Property description must be an object');
1869 var propertyString = String(property);
1870 var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
1871 var getterType = 'get' in descriptor && typeof descriptor.get;
1872 var setterType = 'set' in descriptor && typeof descriptor.set;
1874 // handle descriptor.get
1876 if (getterType !== 'function') {
1877 throw new TypeError('Getter must be a function');
1879 if (!supportsAccessors) {
1880 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
1882 if (hasValueOrWritable) {
1883 throw new TypeError(ERR_VALUE_ACCESSORS);
1885 Object.__defineGetter__.call(object, propertyString, descriptor.get);
1887 object[propertyString] = descriptor.value;
1890 // handle descriptor.set
1892 if (setterType !== 'function') {
1893 throw new TypeError('Setter must be a function');
1895 if (!supportsAccessors) {
1896 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
1898 if (hasValueOrWritable) {
1899 throw new TypeError(ERR_VALUE_ACCESSORS);
1901 Object.__defineSetter__.call(object, propertyString, descriptor.set);
1904 // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
1905 if ('value' in descriptor) {
1906 object[propertyString] = descriptor.value;
1911 }(Object.defineProperty));
1916 // _ESAbstract.CreateDataProperty
1917 // 7.3.4. CreateDataProperty ( O, P, V )
1919 // This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator.
1920 // 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.
1921 function CreateDataProperty(O, P, V) { // eslint-disable-line no-unused-vars
1922 // 1. Assert: Type(O) is Object.
1923 // 2. Assert: IsPropertyKey(P) is true.
1924 // 3. Let newDesc be the PropertyDescriptor{ [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.
1931 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
1933 Object.defineProperty(O, P, newDesc);
1940 // _ESAbstract.CreateDataPropertyOrThrow
1941 /* global CreateDataProperty */
1942 // 7.3.6. CreateDataPropertyOrThrow ( O, P, V )
1943 function CreateDataPropertyOrThrow(O, P, V) { // eslint-disable-line no-unused-vars
1944 // 1. Assert: Type(O) is Object.
1945 // 2. Assert: IsPropertyKey(P) is true.
1946 // 3. Let success be ? CreateDataProperty(O, P, V).
1947 var success = CreateDataProperty(O, P, V);
1948 // 4. If success is false, throw a TypeError exception.
1950 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) + '`');
1952 // 5. Return success.
1956 // _ESAbstract.CreateIterResultObject
1957 /* global Type, CreateDataProperty */
1958 // 7.4.7. CreateIterResultObject ( value, done )
1959 function CreateIterResultObject(value, done) { // eslint-disable-line no-unused-vars
1960 // 1. Assert: Type(done) is Boolean.
1961 if (Type(done) !== 'boolean') {
1964 // 2. Let obj be ObjectCreate(%ObjectPrototype%).
1966 // 3. Perform CreateDataProperty(obj, "value", value).
1967 CreateDataProperty(obj, "value", value);
1968 // 4. Perform CreateDataProperty(obj, "done", done).
1969 CreateDataProperty(obj, "done", done);
1974 // _ESAbstract.CreateMethodProperty
1975 // 7.3.5. CreateMethodProperty ( O, P, V )
1976 function CreateMethodProperty(O, P, V) { // eslint-disable-line no-unused-vars
1977 // 1. Assert: Type(O) is Object.
1978 // 2. Assert: IsPropertyKey(P) is true.
1979 // 3. Let newDesc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}.
1986 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
1987 Object.defineProperty(O, P, newDesc);
1989 if (!("isArray"in Array
1993 /* global CreateMethodProperty, IsArray */
1994 // 22.1.2.2. Array.isArray ( arg )
1995 CreateMethodProperty(Array, 'isArray', function isArray(arg) {
1996 // 1. Return ? IsArray(arg).
1997 return IsArray(arg);
2002 if (!("copyWithin"in Array.prototype&&function(){try{var t=function n(){}
2003 t.prototype[0]="foo"
2005 o[1]=1,o[2]=2,o.length=3
2006 var r=Array.prototype.copyWithin.call(o,1,0)
2007 return!(!r[0]||Object.prototype.hasOwnProperty.call(r,"0")||!Object.prototype.hasOwnProperty.call(r,"1")||"foo"!==r[0]||"foo"!==r[1]||1!==r[2]||3!==r.length)}catch(e){return!1}}()
2010 // Array.prototype.copyWithin
2011 /* global CreateMethodProperty, HasProperty, ToInteger */
2012 // 22.1.3.3 Array.prototype.copyWithin ( target, start [ , end ] )
2013 CreateMethodProperty(Array.prototype, 'copyWithin', function copyWithin(target, start /* [ , end ] */ ) {
2015 var end = arguments[2];
2017 // 22.1.3.3.1 Let O be ? ToObject(this value).
2018 if (this === null || this === undefined) {
2019 throw new TypeError('Cannot call method on ' + this);
2022 var o = Object(this);
2024 // 22.1.3.3.2 Let len be ? ToLength(? Get(O, "length")).
2025 var len = ToInteger(o.length);
2029 if (len === Infinity) {
2030 len = Math.pow(2, 53) - 1;
2032 len = Math.min(len, Math.pow(2, 53) - 1);
2034 len = Math.max(len, 0);
2036 // 22.1.3.3.3 Let relativeTarget be ? ToInteger(target).
2037 var relativeTarget = ToInteger(target);
2039 // 22.1.3.3.4 If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let to be min(relativeTarget, len).
2041 if (relativeTarget < 0) {
2042 to = Math.max(len + relativeTarget, 0);
2044 to = Math.min(relativeTarget, len);
2047 // 22.1.3.3.5 Let relativeStart be ? ToInteger(start).
2048 var relativeStart = ToInteger(start);
2050 // 22.1.3.3.6 If relativeStart < 0, let from be max((len + relativeStart), 0); else let from be min(relativeStart, len).
2052 if (relativeStart < 0) {
2053 from = Math.max(len + relativeStart, 0);
2055 from = Math.min(relativeStart, len);
2058 // 22.1.3.3.7 If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
2060 if (end === undefined) {
2063 relativeEnd = ToInteger(end);
2066 // 22.1.3.3.8 If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
2068 if (relativeEnd < 0) {
2069 final = Math.max(len + relativeEnd, 0);
2071 final = Math.min(relativeEnd, len);
2074 // 22.1.3.3.9 Let count be min(final-from, len-to).
2075 var count = Math.min(final - from, len - to);
2077 // 22.1.3.3.10 If from<to and to<from+count, then
2079 if (from < to && to < from + count) {
2080 // 22.1.3.3.10.a Let direction be -1.
2083 // 22.1.3.3.10.b Let from be from + count - 1.
2084 from = from + count - 1;
2086 // 22.1.3.3.10.c Let to be to + count - 1.
2087 to = to + count - 1;
2089 // 22.1.3.3.11 Else,
2090 // 22.1.3.3.11.a Let direction be 1.
2094 // 22.1.3.3.12 Repeat, while count > 0
2096 // 22.1.3.3.12.a Let fromKey be ! ToString(from).
2097 var fromKey = String(from);
2098 // 22.1.3.3.12.b Let toKey be ! ToString(to).
2099 var toKey = String(to);
2100 // 22.1.3.3.12.c Let fromPresent be ? HasProperty(O, fromKey).
2101 var fromPresent = HasProperty(o, fromKey);
2102 // 22.1.3.3.12.d If fromPresent is true, then
2104 // 22.1.3.3.12.d.i Let fromVal be ? Get(O, fromKey).
2105 var fromVal = o[fromKey];
2106 // 22.1.3.3.12.d.ii Perform ? Set(O, toKey, fromVal, true).
2109 // 22.1.3.3.12.e Else fromPresent is false,
2110 // 22.1.3.3.12.e.i Perform ? DeletePropertyOrThrow(O, toKey).
2113 // 22.1.3.3.12.f Let from be from + direction.
2114 from = from + direction;
2115 // 22.1.3.3.12.g Let to be to + direction.
2116 to = to + direction;
2117 // 22.1.3.3.12.h Let count be count - 1.
2120 // 22.1.3.3.13 Return O.
2126 if (!("fill"in Array.prototype
2129 // Array.prototype.fill
2130 /* global CreateMethodProperty, Get, ToInteger, ToLength, ToObject, ToString */
2131 // 22.1.3.6. Array.prototype.fill ( value [ , start [ , end ] ] )
2132 CreateMethodProperty(Array.prototype, 'fill', function fill(value /* [ , start [ , end ] ] */) {
2133 var start = arguments[1];
2134 var end = arguments[2];
2135 // 1. Let O be ? ToObject(this value).
2136 var O = ToObject(this);
2137 // 2. Let len be ? ToLength(? Get(O, "length")).
2138 var len = ToLength(Get(O, "length"));
2139 // 3. Let relativeStart be ? ToInteger(start).
2140 var relativeStart = ToInteger(start);
2141 // 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be min(relativeStart, len)
2142 var k = relativeStart < 0 ? Math.max((len + relativeStart), 0) : Math.min(relativeStart, len);
2143 // 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
2144 var relativeEnd = end === undefined ? len : ToInteger(end);
2145 // 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
2146 var final = relativeEnd < 0 ? Math.max((len + relativeEnd), 0) : Math.min(relativeEnd, len);
2147 // 7. Repeat, while k < final
2149 // a. Let Pk be ! ToString(k).
2150 var Pk = ToString(k);
2151 // b. Perform ? Set(O, Pk, value, true).
2153 // c. Increase k by 1.
2162 if (!("find"in Array.prototype
2165 // Array.prototype.find
2166 /* global Call, CreateMethodProperty, Get, IsCallable, ToBoolean, ToLength, ToObject, ToString */
2167 // 22.1.3.8 Array.prototype.find ( predicate [ , thisArg ] )
2168 CreateMethodProperty(Array.prototype, 'find', function find( predicate /* [ , thisArg ] */) {
2169 // 1. Let O be ? ToObject(this value).
2170 var O = ToObject(this);
2171 // 2. Let len be ? ToLength(? Get(O, "length")).
2172 var len = ToLength(Get(O, "length"));
2173 // 3. If IsCallable(predicate) is false, throw a TypeError exception.
2174 if (IsCallable(predicate) === false) {
2175 throw new TypeError(predicate + ' is not a function');
2177 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
2178 var T = arguments.length > 1 ? arguments[1] : undefined;
2181 // 6. Repeat, while k < len
2183 // a. Let Pk be ! ToString(k).
2184 var Pk = ToString(k);
2185 // b. Let kValue be ? Get(O, Pk).
2186 var kValue = Get(O, Pk);
2187 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
2188 var testResult = ToBoolean(Call(predicate, T, [kValue, k, O ]));
2189 // d. If testResult is true, return kValue.
2193 // e. Increase k by 1.
2196 // 7. Return undefined.
2202 if (!("findIndex"in Array.prototype
2205 // Array.prototype.findIndex
2206 /* global Call, CreateMethodProperty, Get, IsCallable, ToBoolean, ToLength, ToObject, ToString */
2207 // 22.1.3.9. Array.prototype.findIndex ( predicate [ , thisArg ] )
2208 CreateMethodProperty(Array.prototype, 'findIndex', function findIndex(predicate /* [ , thisArg ] */) {
2209 // 1. Let O be ? ToObject(this value).
2210 var O = ToObject(this);
2211 // 2. Let len be ? ToLength(? Get(O, "length")).
2212 var len = ToLength(Get(O, "length"));
2213 // 3. If IsCallable(predicate) is false, throw a TypeError exception.
2214 if (IsCallable(predicate) === false) {
2215 throw new TypeError(predicate + ' is not a function');
2217 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
2218 var T = arguments.length > 1 ? arguments[1] : undefined;
2221 // 6. Repeat, while k < len
2223 // a. Let Pk be ! ToString(k).
2224 var Pk = ToString(k);
2225 // b. Let kValue be ? Get(O, Pk).
2226 var kValue = Get(O, Pk);
2227 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
2228 var testResult = ToBoolean(Call(predicate, T, [kValue, k, O]));
2229 // d. If testResult is true, return k.
2233 // e. Increase k by 1.
2242 if (!("forEach"in Array.prototype
2245 // Array.prototype.forEach
2246 /* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
2247 // 22.1.3.10. Array.prototype.forEach ( callbackfn [ , thisArg ] )
2248 CreateMethodProperty(Array.prototype, 'forEach', function forEach(callbackfn /* [ , thisArg ] */) {
2249 // 1. Let O be ? ToObject(this value).
2250 var O = ToObject(this);
2251 // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
2252 // We will use arrayLike in place of O when we are iterating through the list.
2253 var arraylike = O instanceof String ? O.split('') : O;
2254 // 2. Let len be ? ToLength(? Get(O, "length")).
2255 var len = ToLength(Get(O, "length"));
2256 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
2257 if (IsCallable(callbackfn) === false) {
2258 throw new TypeError(callbackfn + ' is not a function');
2260 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
2261 var T = arguments.length > 1 ? arguments[1] : undefined;
2264 // 6. Repeat, while k < len
2266 // a. Let Pk be ! ToString(k).
2267 var Pk = ToString(k);
2268 // b. Let kPresent be ? HasProperty(O, Pk).
2269 var kPresent = HasProperty(arraylike, Pk);
2270 // c. If kPresent is true, then
2272 // i. Let kValue be ? Get(O, Pk).
2273 var kValue = Get(arraylike, Pk);
2274 // ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
2275 Call(callbackfn, T, [kValue, k, O]);
2277 // d. Increase k by 1.
2280 // 7. Return undefined.
2286 if (!("bind"in Function.prototype
2289 // Function.prototype.bind
2290 /* global CreateMethodProperty, IsCallable */
2291 // 19.2.3.2. Function.prototype.bind ( thisArg, ...args )
2292 // https://github.com/es-shims/es5-shim/blob/d6d7ff1b131c7ba14c798cafc598bb6780d37d3b/es5-shim.js#L182
2293 CreateMethodProperty(Function.prototype, 'bind', function bind(that) { // .length is 1
2294 // add necessary es5-shim utilities
2296 var $Object = Object;
2297 var ArrayPrototype = $Array.prototype;
2298 var Empty = function Empty() { };
2299 var array_slice = ArrayPrototype.slice;
2300 var array_concat = ArrayPrototype.concat;
2301 var array_push = ArrayPrototype.push;
2303 // /add necessary es5-shim utilities
2305 // 1. Let Target be the this value.
2307 // 2. If IsCallable(Target) is false, throw a TypeError exception.
2308 if (!IsCallable(target)) {
2309 throw new TypeError('Function.prototype.bind called on incompatible ' + target);
2311 // 3. Let A be a new (possibly empty) internal list of all of the
2312 // argument values provided after thisArg (arg1, arg2 etc), in order.
2313 // XXX slicedArgs will stand in for "A" if used
2314 var args = array_slice.call(arguments, 1); // for normal call
2315 // 4. Let F be a new native ECMAScript object.
2316 // 11. Set the [[Prototype]] internal property of F to the standard
2317 // built-in Function prototype object as specified in 15.3.3.1.
2318 // 12. Set the [[Call]] internal property of F as described in
2320 // 13. Set the [[Construct]] internal property of F as described in
2322 // 14. Set the [[HasInstance]] internal property of F as described in
2325 var binder = function () {
2327 if (this instanceof bound) {
2328 // 15.3.4.5.2 [[Construct]]
2329 // When the [[Construct]] internal method of a function object,
2330 // F that was created using the bind function is called with a
2331 // list of arguments ExtraArgs, the following steps are taken:
2332 // 1. Let target be the value of F's [[TargetFunction]]
2333 // internal property.
2334 // 2. If target has no [[Construct]] internal method, a
2335 // TypeError exception is thrown.
2336 // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
2338 // 4. Let args be a new list containing the same values as the
2339 // list boundArgs in the same order followed by the same
2340 // values as the list ExtraArgs in the same order.
2341 // 5. Return the result of calling the [[Construct]] internal
2342 // method of target providing args as the arguments.
2344 var result = target.apply(
2346 array_concat.call(args, array_slice.call(arguments))
2348 if ($Object(result) === result) {
2354 // 15.3.4.5.1 [[Call]]
2355 // When the [[Call]] internal method of a function object, F,
2356 // which was created using the bind function is called with a
2357 // this value and a list of arguments ExtraArgs, the following
2359 // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
2361 // 2. Let boundThis be the value of F's [[BoundThis]] internal
2363 // 3. Let target be the value of F's [[TargetFunction]] internal
2365 // 4. Let args be a new list containing the same values as the
2366 // list boundArgs in the same order followed by the same
2367 // values as the list ExtraArgs in the same order.
2368 // 5. Return the result of calling the [[Call]] internal method
2369 // of target providing boundThis as the this value and
2370 // providing args as the arguments.
2372 // equiv: target.call(this, ...boundArgs, ...args)
2373 return target.apply(
2375 array_concat.call(args, array_slice.call(arguments))
2382 // 15. If the [[Class]] internal property of Target is "Function", then
2383 // a. Let L be the length property of Target minus the length of A.
2384 // b. Set the length own property of F to either 0 or L, whichever is
2386 // 16. Else set the length own property of F to 0.
2388 var boundLength = max(0, target.length - args.length);
2390 // 17. Set the attributes of the length own property of F to the values
2391 // specified in 15.3.5.1.
2393 for (var i = 0; i < boundLength; i++) {
2394 array_push.call(boundArgs, '$' + i);
2397 // XXX Build a dynamic function with desired amount of arguments is the only
2398 // way to set the length property of a function.
2399 // In environments where Content Security Policies enabled (Chrome extensions,
2400 // for ex.) all use of eval or Function costructor throws an exception.
2401 // However in all of these environments Function.prototype.bind exists
2402 // and so this code will never be executed.
2403 bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
2405 if (target.prototype) {
2406 Empty.prototype = target.prototype;
2407 bound.prototype = new Empty();
2408 // Clean up dangling references.
2409 Empty.prototype = null;
2413 // 18. Set the [[Extensible]] internal property of F to true.
2416 // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
2417 // 20. Call the [[DefineOwnProperty]] internal method of F with
2418 // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
2419 // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
2421 // 21. Call the [[DefineOwnProperty]] internal method of F with
2422 // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
2423 // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
2427 // NOTE Function objects created using Function.prototype.bind do not
2428 // have a prototype property or the [[Code]], [[FormalParameters]], and
2429 // [[Scope]] internal properties.
2430 // XXX can't delete prototype in pure-js.
2438 if (!("acosh"in Math
2442 /* global CreateMethodProperty */
2443 // 20.2.2.3. Math.acosh ( x )
2444 CreateMethodProperty(Math, 'acosh', function acosh(x) {
2445 // If x is NaN, the result is NaN.
2449 // If x is less than 1, the result is NaN.
2453 // If x is 1, the result is +0.
2457 // If x is +∞, the result is +∞.
2458 if (x === Infinity) {
2461 return Math.log(x + Math.sqrt(x * x - 1));
2466 if (!("asinh"in Math
2470 /* global CreateMethodProperty */
2471 // 20.2.2.5. Math.asinh ( x )
2472 CreateMethodProperty(Math, 'asinh', function asinh(x) {
2473 // If x is NaN, the result is NaN.
2477 // If x is +0, the result is +0.
2478 if (x === 0 && 1/x === Infinity) {
2481 // If x is -0, the result is -0.
2482 if (x === 0 && 1/x === -Infinity) {
2485 // If x is +∞, the result is +∞.
2486 if (x === Infinity) {
2489 // If x is -∞, the result is -∞.
2490 if (x === -Infinity) {
2493 return Math.log(x + Math.sqrt(x * x + 1));
2498 if (!("atanh"in Math
2502 /* global CreateMethodProperty */
2503 // 20.2.2.7. Math.atanh ( x )
2504 CreateMethodProperty(Math, 'atanh', function atanh(x) {
2505 // If x is NaN, the result is NaN.
2509 // If x is less than -1, the result is NaN.
2513 // If x is greater than 1, the result is NaN.
2517 // If x is -1, the result is -∞.
2521 // If x is +1, the result is +∞.
2525 // If x is +0, the result is +0.
2526 if (x === 0 && 1/x === Infinity) {
2529 // If x is -0, the result is -0.
2530 if (x === 0 && 1/x === -Infinity) {
2533 return Math.log((1 + x) / (1 - x)) / 2;
2542 /* global CreateMethodProperty */
2543 // 20.2.2.9. Math.cbrt ( x )
2544 CreateMethodProperty(Math, 'cbrt', function cbrt(x) {
2545 // If x is NaN, the result is NaN.
2549 // If x is +0, the result is +0.
2550 if (x === 0 && 1/x === Infinity) {
2553 // If x is -0, the result is -0.
2554 if (x === 0 && 1/x === -Infinity) {
2557 // If x is +∞, the result is +∞.
2558 if (x === Infinity) {
2561 // If x is -∞, the result is -∞.
2562 if (x === -Infinity) {
2565 var y = Math.pow(Math.abs(x), 1 / 3);
2566 return x < 0 ? -y : y;
2571 if (!("clz32"in Math
2575 /* global CreateMethodProperty, ToUint32 */
2576 // 20.2.2.11. Math.clz32 ( x )
2577 CreateMethodProperty(Math, 'clz32', function clz32(x) {
2578 // 1. Let n be ToUint32(x).
2579 var n = ToUint32(x);
2580 // 2. Let p be the number of leading zero bits in the 32-bit binary representation of n.
2581 var p = n ? 32 - n.toString(2).length : 32;
2592 /* global CreateMethodProperty */
2593 // 20.2.2.1. 3Math.cosh ( x )
2594 CreateMethodProperty(Math, 'cosh', function cosh(x) {
2595 // If x is NaN, the result is NaN.
2599 // If x is +0, the result is 1.
2600 if (x === 0 && 1/x === Infinity) {
2603 // If x is -0, the result is 1.
2604 if (x === 0 && 1/x === -Infinity) {
2607 // If x is +∞, the result is +∞.
2608 if (x === Infinity) {
2611 // If x is -∞, the result is +∞.
2612 if (x === -Infinity) {
2617 var y = Math.exp(0.5 * x);
2620 var y = Math.exp(x);
2621 return (y + 1 / y) / 2;
2626 if (!("expm1"in Math
2630 /* global CreateMethodProperty */
2631 // 20.2.2.15. Math.expm1 ( x )
2632 CreateMethodProperty(Math, 'expm1', function expm1(x) {
2633 // If x is NaN, the result is NaN.
2637 // If x is +0, the result is +0.
2638 if (x === 0 && 1/x === Infinity) {
2641 // If x is -0, the result is -0.
2642 if (x === 0 && 1/x === -Infinity) {
2645 // If x is +∞, the result is +∞.
2646 if (x === Infinity) {
2649 // If x is -∞, the result is -1.
2650 if (x === -Infinity) {
2654 if (x > -1e-6 && x < 1e-6) {
2655 return x + x * x / 2;
2657 return Math.exp(x) - 1;
2663 if (!("fround"in Math
2667 /* global Float32Array, CreateMethodProperty */
2668 // 20.2.2.17 Math.fround ( x )
2669 CreateMethodProperty(Math, 'fround', function (x) {
2670 // 1. If x is NaN, return NaN.
2674 // 2. If x is one of +0, -0, +∞, -∞, return x.
2675 if (1 / x === +Infinity || 1 / x === -Infinity || x === +Infinity || x === -Infinity) {
2678 // 3. Let x32 be the result of converting x to a value in IEEE 754-2008 binary32 format using roundTiesToEven.
2679 // 4. Let x64 be the result of converting x32 to a value in IEEE 754-2008 binary64 format.
2680 // 5. Return the ECMAScript Number value corresponding to x64.
2681 return (new Float32Array([x]))[0];
2686 if (!("hypot"in Math
2690 /* global CreateMethodProperty */
2691 // 20.2.2.18. Math.hypot ( value1, value2, ...values )
2692 CreateMethodProperty(Math, 'hypot', function hypot(value1, value2) { // eslint-disable-line no-unused-vars
2693 // If no arguments are passed, the result is +0.
2694 if (arguments.length === 0) {
2699 for (var i = 0; i < arguments.length; ++i) {
2700 // If any argument is +∞, the result is +∞.
2701 if (arguments[i] === Infinity) {
2705 // If any argument is -∞, the result is +∞.
2706 if (arguments[i] === -Infinity) {
2710 // If no argument is +∞ or -∞, and any argument is NaN, the result is NaN.
2711 // If all arguments are either +0 or -0, the result is +0.
2712 // Polyfill.io - The two conditions above are handled in the math.
2714 var arg = Math.abs(Number(arguments[i]));
2716 y = y * Math.pow(max / arg, 2);
2719 if (arg !== 0 || max !== 0) {
2720 y = y + Math.pow(arg / max, 2);
2724 return max * Math.sqrt(y);
2733 /* global CreateMethodProperty, ToUint32 */
2734 // 20.2.2.19. Math.imul ( x, y )
2735 CreateMethodProperty(Math, 'imul', function imul(x, y) {
2736 // 1. Let a be ToUint32(x).
2737 var a = ToUint32(x);
2738 // 2. Let b be ToUint32(y).
2739 var b = ToUint32(y);
2740 var UINT16 = 0xffff;
2741 var aHigh = a >>> 16 & UINT16;
2742 var aLow = UINT16 & a;
2743 var bHigh = b >>> 16 & UINT16;
2744 var bLow = UINT16 & b;
2745 // the shift by 0 fixes the sign on the high part
2746 // the final |0 converts the unsigned value into a signed value
2747 return aLow * bLow + (aHigh * bLow + aLow * bHigh << 16 >>> 0) | 0;
2751 if (!("log10"in Math
2755 /* global CreateMethodProperty */
2756 // 20.2.2.22. Math.log10 ( x )
2757 CreateMethodProperty(Math, 'log10', function log10(x) {
2758 return Math.log(x) / Math.LN10;
2763 if (!("log1p"in Math
2767 /* global CreateMethodProperty */
2768 // 20.2.2.21. Math.log1p ( x )
2769 CreateMethodProperty(Math, 'log1p', function log1p(x) {
2771 if (-1 < x && x < 1) {
2772 // Polyfill.io - For numbers in the range −1 < x < 1
2773 // Because we are using log, the precision of the result will be identical to log(1).
2774 // To fix this we avoid using log and use the Taylor Series expansion of log.
2775 // This series converges when |x| < 1. As we can not sum to infinity,
2776 // we instead sum the first 300 parts of the series to give a close approximation.
2777 // |x|<1, log(1+x) = x - x^2/2 + x^3/3 - ... + (-1)^(n-1)*x^n/n + ...
2779 for (var i = 2; i <= 300; i++) {
2780 y += Math.pow((-1), (i - 1)) * Math.pow(x, i) / i;
2785 return Math.log(1 + x);
2793 /* global CreateMethodProperty */
2794 // 20.2.2.23. Math.log2 ( x )
2795 CreateMethodProperty(Math, 'log2', function log2(x) {
2796 return Math.log(x) / Math.LN2;
2805 /* global CreateMethodProperty */
2806 // 20.2.2.29. Math.sign ( x )
2807 CreateMethodProperty(Math, 'sign', function sign(x) {
2809 // If x is NaN, the result is NaN.
2813 // If x is -0, the result is -0.
2814 if (1 / x === -Infinity) {
2817 // If x is +0, the result is +0.
2818 if (1 / x === Infinity) {
2821 // If x is negative and not -0, the result is -1.
2825 // If x is positive and not +0, the result is +1.
2837 /* global CreateMethodProperty */
2838 // 20.2.2.31. Math.sinh ( x )
2839 CreateMethodProperty(Math, 'sinh', function sinh(x) {
2840 var s = (x < 0) ? -1 : 1;
2841 var absx = Math.abs(x);
2843 if (absx < Math.pow(2, -28)) {
2846 var t = Math.exp(absx) - 1;
2848 return (s * (2 * t - t * t / (t + 1)))/2;
2850 return (s * (t + t / (t + 1)))/2;
2852 if (absx < 709.7822265625) {
2853 return (s * Math.exp(absx))/2;
2855 var w = Math.exp(0.5 * absx);
2866 /* global CreateMethodProperty */
2867 // 20.2.2.34. Math.tanh ( x )
2868 CreateMethodProperty(Math, 'tanh', function tanh(x) {
2871 return x === Infinity ? 1 : x === -Infinity ? -1 : (y = Math.exp(2 * x), (y - 1) / (y + 1));
2876 if (!("trunc"in Math
2880 /* global CreateMethodProperty */
2881 CreateMethodProperty(Math, 'trunc', function trunc(x) {
2882 return x < 0 ? Math.ceil(x) : Math.floor(x);
2887 if (!("isFinite"in Number
2891 /* global CreateMethodProperty, Type */
2894 // 20.1.2.2. Number.isFinite ( number )
2895 CreateMethodProperty(Number, 'isFinite', function isFinite(number) {
2896 // 1. If Type(number) is not Number, return false.
2897 if (Type(number) !== 'number') {
2900 // 2. If number is NaN, +∞, or -∞, return false.
2901 // 3. Otherwise, return true.
2902 // Polyfill.io - We use isFinite as it implements steps 2 and 3.
2903 return that.isFinite(number);
2909 if (!("isInteger"in Number
2913 /* global CreateMethodProperty, ToInteger, Type */
2914 // 20.1.2.3. Number.isInteger ( number )
2915 CreateMethodProperty(Number, 'isInteger', function isInteger(number) {
2916 // 1. If Type(number) is not Number, return false.
2917 if (Type(number) !== 'number') {
2920 // 2. If number is NaN, +∞, or -∞, return false.
2921 if (isNaN(number) || number === Infinity || number === -Infinity) {
2924 // 3. Let integer be ToInteger(number).
2925 var integer = ToInteger(number);
2926 // 4. If integer is not equal to number, return false.
2927 if (integer !== number) {
2930 // 5. Otherwise, return true.
2936 if (!("isNaN"in Number
2940 /* global CreateMethodProperty, Type */
2943 // 20.1.2.4. Number.isNaN ( number )
2944 CreateMethodProperty(Number, 'isNaN', function isNaN(number) {
2945 // 1. If Type(number) is not Number, return false.
2946 if (Type(number) !== 'number') {
2949 // 2. If number is NaN, return true.
2950 if (that.isNaN(number)) {
2953 // 3. Otherwise, return false.
2960 if (!("isSafeInteger"in Number
2963 // Number.isSafeInteger
2964 /* global CreateMethodProperty, Type, ToInteger */
2965 // 20.1.2.5. Number.isSafeInteger ( number )
2966 CreateMethodProperty(Number, 'isSafeInteger', function isSafeInteger(number) {
2967 // 1. If Type(number) is not Number, return false.
2968 if (Type(number) !== 'number') {
2971 // 2. If number is NaN, +∞, or -∞, return false.
2972 if (isNaN(number) || number === Infinity || number === -Infinity) {
2975 // 3. Let integer be ToInteger(number).
2976 var integer = ToInteger(number);
2977 // 4. If integer is not equal to number, return false.
2978 if (integer !== number) {
2981 // 5. If abs(integer) ≤ 2^53-1, return true.
2982 if (Math.abs(integer) <= (Math.pow(2, 53) - 1)) {
2985 // 6. Otherwise, return false.
2991 if (!("parseFloat"in Number
2994 // Number.parseFloat
2995 /* global CreateMethodProperty */
2996 // 20.1.2.12. Number.parseFloat ( string )
2997 // 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.
2998 CreateMethodProperty(Number, 'parseFloat', parseFloat);
3002 if (!("parseInt"in Number
3006 /* global CreateMethodProperty */
3007 // 20.1.2.13. Number.parseInt ( string, radix )
3008 // 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.
3009 CreateMethodProperty(Number, 'parseInt', parseInt);
3013 if (!("name"in Function.prototype&&"x"===function n(){}.name
3016 // Function.prototype.name
3020 accessorName = 'name',
3021 fnNameMatchRegex = /^\s*function\s+([^\(\s]*)\s*/,
3022 $Function = Function,
3023 FunctionName = 'Function',
3024 FunctionProto = $Function.prototype,
3025 FunctionProtoCtor = FunctionProto.constructor,
3027 getFunctionName = function(fn) {
3030 if (fn === $Function || fn === FunctionProtoCtor) {
3031 name = FunctionName;
3033 else if (fn !== FunctionProto) {
3034 match = ('' + fn).match(fnNameMatchRegex);
3035 name = match && match[1];
3041 Object.defineProperty(FunctionProto, accessorName, {
3042 get: function Function$name() {
3045 fnName = getFunctionName(fn);
3047 // Since named function definitions have immutable names, also memoize the
3048 // output by defining the `name` property directly on this Function
3049 // instance so the accessor function will not need to be invoked again.
3050 if (fn !== FunctionProto) {
3051 Object.defineProperty(fn, accessorName, {
3066 if (!("EPSILON"in Number
3070 // 20.1.2.1. Number.EPSILON
3071 // 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.
3072 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
3073 Object.defineProperty(Number, 'EPSILON', {
3075 configurable: false,
3077 value: Math.pow(2, -52)
3082 if (!("MAX_SAFE_INTEGER"in Number
3085 // Number.MAX_SAFE_INTEGER
3086 // 20.1.2.6. Number.MAX_SAFE_INTEGER
3087 // The value of Number.MAX_SAFE_INTEGER is 9007199254740991 (2^53-1).
3088 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
3089 Object.defineProperty(Number, 'MAX_SAFE_INTEGER', {
3091 configurable: false,
3093 value: Math.pow(2, 53) - 1
3098 if (!("MIN_SAFE_INTEGER"in Number
3101 // Number.MIN_SAFE_INTEGER
3102 // 20.1.2.8. Number.MIN_SAFE_INTEGER
3103 // The value of Number.MIN_SAFE_INTEGER is -9007199254740991 (-(253-1)).
3104 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
3105 Object.defineProperty(Number, 'MIN_SAFE_INTEGER', {
3107 configurable: false,
3109 value: -(Math.pow(2, 53) - 1)
3114 if (!("freeze"in Object
3118 /* global CreateMethodProperty */
3119 // 19.1.2.6. Object.freeze ( O )
3120 CreateMethodProperty(Object, 'freeze', function freeze(O) {
3121 // This feature cannot be implemented fully as a polyfill.
3122 // We choose to silently fail which allows "securable" code
3123 // to "gracefully" degrade to working but insecure code.
3129 if (!("getOwnPropertyDescriptor"in Object&&"function"==typeof Object.getOwnPropertyDescriptor&&function(){try{var t={}
3130 return t.test=0,0===Object.getOwnPropertyDescriptor(t,"test").value}catch(e){return!1}}()
3133 // Object.getOwnPropertyDescriptor
3134 /* global CreateMethodProperty */
3136 var call = Function.prototype.call;
3137 var prototypeOfObject = Object.prototype;
3138 var owns = call.bind(prototypeOfObject.hasOwnProperty);
3142 var supportsAccessors;
3143 if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
3144 lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
3145 lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
3147 function doesGetOwnPropertyDescriptorWork(object) {
3149 object.sentinel = 0;
3150 return Object.getOwnPropertyDescriptor(
3154 } catch (exception) {
3158 // check whether getOwnPropertyDescriptor works if it's given. Otherwise,
3160 if (Object.defineProperty) {
3161 var getOwnPropertyDescriptorWorksOnObject =
3162 doesGetOwnPropertyDescriptorWork({});
3163 var getOwnPropertyDescriptorWorksOnDom = typeof document == "undefined" ||
3164 doesGetOwnPropertyDescriptorWork(document.createElement("div"));
3165 if (!getOwnPropertyDescriptorWorksOnDom ||
3166 !getOwnPropertyDescriptorWorksOnObject
3168 var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
3172 if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
3173 var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
3175 CreateMethodProperty(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(object, property) {
3176 if ((typeof object != "object" && typeof object != "function") || object === null) {
3177 throw new TypeError(ERR_NON_OBJECT + object);
3180 // make a valiant attempt to use the real getOwnPropertyDescriptor
3181 // for I8's DOM elements.
3182 if (getOwnPropertyDescriptorFallback) {
3184 return getOwnPropertyDescriptorFallback.call(Object, object, property);
3185 } catch (exception) {
3186 // try the shim if the real one doesn't work
3190 // If object does not owns property return undefined immediately.
3191 if (!owns(object, property)) {
3195 // If object has a property then it's for sure both `enumerable` and
3197 var descriptor = { enumerable: true, configurable: true };
3199 // If JS engine supports accessor properties then property may be a
3200 // getter or setter.
3201 if (supportsAccessors) {
3202 // Unfortunately `__lookupGetter__` will return a getter even
3203 // if object has own non getter property along with a same named
3204 // inherited getter. To avoid misbehavior we temporary remove
3205 // `__proto__` so that `__lookupGetter__` will return getter only
3206 // if it's owned by an object.
3207 var prototype = object.__proto__;
3208 object.__proto__ = prototypeOfObject;
3210 var getter = lookupGetter(object, property);
3211 var setter = lookupSetter(object, property);
3213 // Once we have getter and setter we can put values back.
3214 object.__proto__ = prototype;
3216 if (getter || setter) {
3218 descriptor.get = getter;
3221 descriptor.set = setter;
3223 // If it was accessor property we're done and return here
3224 // in order to avoid adding `value` to the descriptor.
3229 // If we got this far we know that object has an own property that is
3230 // not an accessor so we set it as a value and return descriptor.
3231 descriptor.value = object[property];
3232 descriptor.writable = true;
3240 if (!("getOwnPropertyNames"in Object
3243 // Object.getOwnPropertyNames
3244 /* global CreateMethodProperty */
3246 var toString = ({}).toString;
3247 var split = ''.split;
3249 CreateMethodProperty(Object, 'getOwnPropertyNames', function getOwnPropertyNames(object) {
3253 // Non-enumerable properties cannot be discovered but can be checked for by name.
3254 // Define those used internally by JS to allow an incomplete solution
3255 var commonProps = ['length', "name", "arguments", "caller", "prototype", "observe", "unobserve"];
3257 if (typeof object === 'undefined' || object === null) {
3258 throw new TypeError('Cannot convert undefined or null to object');
3261 // Polyfill.io fallback for non-array-like strings which exist in some ES3 user-agents (IE 8)
3262 object = toString.call(object) == '[object String]' ? split.call(object, '') : Object(object);
3264 // Enumerable properties only
3265 for (key in object) {
3266 if (Object.prototype.hasOwnProperty.call(object, key)) {
3271 // Check for and add the common non-enumerable properties
3272 for (var i=0, s=commonProps.length; i<s; i++) {
3273 if (commonProps[i] in object) buffer.push(commonProps[i]);
3281 if (!("getPrototypeOf"in Object
3284 // Object.getPrototypeOf
3285 /* global CreateMethodProperty */
3286 // Based on: https://github.com/es-shims/es5-shim/blob/master/es5-sham.js
3288 // https://github.com/es-shims/es5-shim/issues#issue/2
3289 // http://ejohn.org/blog/objectgetprototypeof/
3290 // recommended by fschaefer on github
3292 // sure, and webreflection says ^_^
3293 // ... this will nerever possibly return null
3294 // ... Opera Mini breaks here with infinite loops
3295 CreateMethodProperty(Object, 'getPrototypeOf', function getPrototypeOf(object) {
3296 if (object !== Object(object)) {
3297 throw new TypeError('Object.getPrototypeOf called on non-object');
3299 var proto = object.__proto__;
3300 if (proto || proto === null) {
3302 } else if (typeof object.constructor == 'function' && object instanceof object.constructor) {
3303 return object.constructor.prototype;
3304 } else if (object instanceof Object) {
3305 return Object.prototype;
3307 // Correctly return null for Objects created with `Object.create(null)`
3308 // (shammed or native) or `{ __proto__: null}`. Also returns null for
3309 // cross-realm objects on browsers that lack `__proto__` support (like
3310 // IE <11), but that's the best we can do.
3321 /* global CreateMethodProperty, SameValue */
3322 // 19.1.2.12. Object.is ( value1, value2 )
3323 CreateMethodProperty(Object, 'is', function is(value1, value2) {
3324 // 1. Return SameValue(value1, value2).
3325 return SameValue(value1, value2);
3330 if (!("keys"in Object&&function(){return 2===Object.keys(arguments).length}(1,2)&&function(){try{return Object.keys(""),!0}catch(t){return!1}}()
3334 /* global CreateMethodProperty */
3335 CreateMethodProperty(Object, "keys", (function() {
3338 // modified from https://github.com/es-shims/object-keys
3340 var has = Object.prototype.hasOwnProperty;
3341 var toStr = Object.prototype.toString;
3342 var isEnumerable = Object.prototype.propertyIsEnumerable;
3343 var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
3344 var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
3351 'propertyIsEnumerable',
3354 var equalsConstructorPrototype = function (o) {
3355 var ctor = o.constructor;
3356 return ctor && ctor.prototype === o;
3358 var excludedKeys = {
3362 $frameElement: true,
3376 $webkitIndexedDB: true,
3377 $webkitStorageInfo: true,
3380 var hasAutomationEqualityBug = (function () {
3382 if (typeof window === 'undefined') { return false; }
3383 for (var k in window) {
3385 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
3387 equalsConstructorPrototype(window[k]);
3398 var equalsConstructorPrototypeIfNotBuggy = function (o) {
3400 if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
3401 return equalsConstructorPrototype(o);
3404 return equalsConstructorPrototype(o);
3410 function isArgumentsObject(value) {
3411 var str = toStr.call(value);
3412 var isArgs = str === '[object Arguments]';
3414 isArgs = str !== '[object Array]' &&
3416 typeof value === 'object' &&
3417 typeof value.length === 'number' &&
3418 value.length >= 0 &&
3419 toStr.call(value.callee) === '[object Function]';
3424 return function keys(object) {
3425 var isFunction = toStr.call(object) === '[object Function]';
3426 var isArguments = isArgumentsObject(object);
3427 var isString = toStr.call(object) === '[object String]';
3430 if (object === undefined || object === null) {
3431 throw new TypeError('Cannot convert undefined or null to object');
3434 var skipProto = hasProtoEnumBug && isFunction;
3435 if (isString && object.length > 0 && !has.call(object, 0)) {
3436 for (var i = 0; i < object.length; ++i) {
3437 theKeys.push(String(i));
3441 if (isArguments && object.length > 0) {
3442 for (var j = 0; j < object.length; ++j) {
3443 theKeys.push(String(j));
3446 for (var name in object) {
3447 if (!(skipProto && name === 'prototype') && has.call(object, name)) {
3448 theKeys.push(String(name));
3453 if (hasDontEnumBug) {
3454 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
3456 for (var k = 0; k < dontEnums.length; ++k) {
3457 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
3458 theKeys.push(dontEnums[k]);
3468 if (!("assign"in Object
3472 /* global CreateMethodProperty, Get, ToObject */
3473 // 19.1.2.1 Object.assign ( target, ...sources )
3474 CreateMethodProperty(Object, 'assign', function assign(target, source) { // eslint-disable-line no-unused-vars
3475 // 1. Let to be ? ToObject(target).
3476 var to = ToObject(target);
3478 // 2. If only one argument was passed, return to.
3479 if (arguments.length === 1) {
3483 // 3. Let sources be the List of argument values starting with the second argument
3484 var sources = Array.prototype.slice.call(arguments, 1);
3486 // 4. For each element nextSource of sources, in ascending index order, do
3491 for (index1 = 0; index1 < sources.length; index1++) {
3492 var nextSource = sources[index1];
3493 // a. If nextSource is undefined or null, let keys be a new empty List.
3494 if (nextSource === undefined || nextSource === null) {
3498 // i. Let from be ! ToObject(nextSource).
3499 from = ToObject(nextSource);
3500 // ii. Let keys be ? from.[[OwnPropertyKeys]]().
3502 This step in our polyfill is not complying with the specification.
3503 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
3504 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
3506 keys = Object.keys(from);
3509 // c. For each element nextKey of keys in List order, do
3510 for (index2 = 0; index2 < keys.length; index2++) {
3511 var nextKey = keys[index2];
3514 // i. Let desc be ? from.[[GetOwnProperty]](nextKey).
3515 var desc = Object.getOwnPropertyDescriptor(from, nextKey);
3516 // ii. If desc is not undefined and desc.[[Enumerable]] is true, then
3517 enumerable = desc !== undefined && desc.enumerable === true;
3519 // Polyfill.io - We use Object.prototype.propertyIsEnumerable as a fallback
3520 // because `Object.getOwnPropertyDescriptor(window.location, 'hash')` causes Internet Explorer 11 to crash.
3521 enumerable = Object.prototype.propertyIsEnumerable.call(from, nextKey);
3524 // 1. Let propValue be ? Get(from, nextKey).
3525 var propValue = Get(from, nextKey);
3526 // 2. Perform ? Set(to, nextKey, propValue, true).
3527 to[nextKey] = propValue;
3537 if (!("defineProperties"in Object
3540 // Object.defineProperties
3541 /* global CreateMethodProperty, Get, ToObject, Type */
3542 // 19.1.2.3. Object.defineProperties ( O, Properties )
3543 CreateMethodProperty(Object, 'defineProperties', function defineProperties(O, Properties) {
3544 // 1. If Type(O) is not Object, throw a TypeError exception.
3545 if (Type(O) !== 'object') {
3546 throw new TypeError('Object.defineProperties called on non-object');
3548 // 2. Let props be ? ToObject(Properties).
3549 var props = ToObject(Properties);
3550 // 3. Let keys be ? props.[[OwnPropertyKeys]]().
3552 Polyfill.io - This step in our polyfill is not complying with the specification.
3553 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
3554 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
3556 var keys = Object.keys(props);
3557 // 4. Let descriptors be a new empty List.
3558 var descriptors = [];
3559 // 5. For each element nextKey of keys in List order, do
3560 for (var i = 0; i < keys.length; i++) {
3561 var nextKey = keys[i];
3562 // a. Let propDesc be ? props.[[GetOwnProperty]](nextKey).
3563 var propDesc = Object.getOwnPropertyDescriptor(props, nextKey);
3564 // b. If propDesc is not undefined and propDesc.[[Enumerable]] is true, then
3565 if (propDesc !== undefined && propDesc.enumerable) {
3566 // i. Let descObj be ? Get(props, nextKey).
3567 var descObj = Get(props, nextKey);
3568 // ii. Let desc be ? ToPropertyDescriptor(descObj).
3569 // Polyfill.io - We skip this step because Object.defineProperty deals with it.
3570 // TODO: Implement this step?
3572 // iii. Append the pair (a two element List) consisting of nextKey and desc to the end of descriptors.
3573 descriptors.push([nextKey, desc]);
3576 // 6. For each pair from descriptors in list order, do
3577 for (var i = 0; i < descriptors.length; i++){
3578 // a. Let P be the first element of pair.
3579 var P = descriptors[i][0];
3580 // b. Let desc be the second element of pair.
3581 var desc = descriptors[i][1];
3582 // c. Perform ? DefinePropertyOrThrow(O, P, desc).
3583 Object.defineProperty(O, P, desc);
3591 if (!("create"in Object
3595 /* global CreateMethodProperty, Type */
3596 CreateMethodProperty(Object, 'create', function create(O, properties) {
3597 // 1. If Type(O) is neither Object nor Null, throw a TypeError exception.
3598 if (Type(O) !== 'object' && Type(O) !== 'null') {
3599 throw new TypeError('Object prototype may only be an Object or null');
3601 // 2. Let obj be ObjectCreate(O).
3602 var obj = new Function('e', 'function Object() {}Object.prototype=e;return new Object')(O);
3604 obj.constructor.prototype = O;
3606 // 3. If Properties is not undefined, then
3607 if (1 in arguments) {
3608 // a. Return ? ObjectDefineProperties(obj, Properties).
3609 return Object.defineProperties(obj, properties);
3618 // _ESAbstract.GetIterator
3619 /* global GetMethod, Symbol, Call, Type, GetV */
3620 // 7.4.1. GetIterator ( obj [ , method ] )
3621 // The abstract operation GetIterator with argument obj and optional argument method performs the following steps:
3622 function GetIterator(obj /*, method */) { // eslint-disable-line no-unused-vars
3623 // 1. If method is not present, then
3624 // a. Set method to ? GetMethod(obj, @@iterator).
3625 var method = arguments.length > 1 ? arguments[1] : GetMethod(obj, Symbol.iterator);
3626 // 2. Let iterator be ? Call(method, obj).
3627 var iterator = Call(method, obj);
3628 // 3. If Type(iterator) is not Object, throw a TypeError exception.
3629 if (Type(iterator) !== 'object') {
3630 throw new TypeError('bad iterator');
3632 // 4. Let nextMethod be ? GetV(iterator, "next").
3633 var nextMethod = GetV(iterator, "next");
3634 // 5. Let iteratorRecord be Record {[[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false}.
3635 var iteratorRecord = Object.create(null);
3636 iteratorRecord['[[Iterator]]'] = iterator;
3637 iteratorRecord['[[NextMethod]]'] = nextMethod;
3638 iteratorRecord['[[Done]]'] = false;
3639 // 6. Return iteratorRecord.
3640 return iteratorRecord;
3643 // _ESAbstract.OrdinaryCreateFromConstructor
3644 /* global GetPrototypeFromConstructor */
3645 // 9.1.13. OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
3646 function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
3647 var internalSlotsList = arguments[2] || {};
3648 // 1. Assert: intrinsicDefaultProto is a String value that is this specification's name of an intrinsic object.
3649 // The corresponding object must be an intrinsic that is intended to be used as the[[Prototype]] value of an object.
3651 // 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
3652 var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto);
3654 // 3. Return ObjectCreate(proto, internalSlotsList).
3655 // 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.
3656 var obj = Object.create(proto);
3657 for (var name in internalSlotsList) {
3658 if (Object.prototype.hasOwnProperty.call(internalSlotsList, name)) {
3659 Object.defineProperty(obj, name, {
3663 value: internalSlotsList[name]
3670 // _ESAbstract.Construct
3671 /* global IsConstructor, OrdinaryCreateFromConstructor, Call */
3672 // 7.3.13. Construct ( F [ , argumentsList [ , newTarget ]] )
3673 function Construct(F /* [ , argumentsList [ , newTarget ]] */) { // eslint-disable-line no-unused-vars
3674 // 1. If newTarget is not present, set newTarget to F.
3675 var newTarget = arguments.length > 2 ? arguments[2] : F;
3677 // 2. If argumentsList is not present, set argumentsList to a new empty List.
3678 var argumentsList = arguments.length > 1 ? arguments[1] : [];
3680 // 3. Assert: IsConstructor(F) is true.
3681 if (!IsConstructor(F)) {
3682 throw new TypeError('F must be a constructor.');
3685 // 4. Assert: IsConstructor(newTarget) is true.
3686 if (!IsConstructor(newTarget)) {
3687 throw new TypeError('newTarget must be a constructor.');
3690 // 5. Return ? F.[[Construct]](argumentsList, newTarget).
3691 // Polyfill.io - If newTarget is the same as F, it is equivalent to new F(...argumentsList).
3692 if (newTarget === F) {
3693 return new (Function.prototype.bind.apply(F, [null].concat(argumentsList)))();
3695 // Polyfill.io - This is mimicking section 9.2.2 step 5.a.
3696 var obj = OrdinaryCreateFromConstructor(newTarget, Object.prototype);
3697 return Call(F, obj, argumentsList);
3701 // _ESAbstract.ArraySpeciesCreate
3702 /* global IsArray, ArrayCreate, Get, Type, IsConstructor, Construct */
3703 // 9.4.2.3. ArraySpeciesCreate ( originalArray, length )
3704 function ArraySpeciesCreate(originalArray, length) { // eslint-disable-line no-unused-vars
3705 // 1. Assert: length is an integer Number ≥ 0.
3706 // 2. If length is -0, set length to +0.
3707 if (1/length === -Infinity) {
3711 // 3. Let isArray be ? IsArray(originalArray).
3712 var isArray = IsArray(originalArray);
3714 // 4. If isArray is false, return ? ArrayCreate(length).
3715 if (isArray === false) {
3716 return ArrayCreate(length);
3719 // 5. Let C be ? Get(originalArray, "constructor").
3720 var C = Get(originalArray, 'constructor');
3722 // Polyfill.io - We skip this section as not sure how to make a cross-realm normal Array, a same-realm Array.
3723 // 6. If IsConstructor(C) is true, then
3724 // if (IsConstructor(C)) {
3725 // a. Let thisRealm be the current Realm Record.
3726 // b. Let realmC be ? GetFunctionRealm(C).
3727 // c. If thisRealm and realmC are not the same Realm Record, then
3728 // i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined.
3730 // 7. If Type(C) is Object, then
3731 if (Type(C) === 'object') {
3732 // a. Set C to ? Get(C, @@species).
3733 C = 'Symbol' in this && 'species' in this.Symbol ? Get(C, this.Symbol.species) : undefined;
3734 // b. If C is null, set C to undefined.
3739 // 8. If C is undefined, return ? ArrayCreate(length).
3740 if (C === undefined) {
3741 return ArrayCreate(length);
3743 // 9. If IsConstructor(C) is false, throw a TypeError exception.
3744 if (!IsConstructor(C)) {
3745 throw new TypeError('C must be a constructor');
3747 // 10. Return ? Construct(C, « length »).
3748 return Construct(C, [length]);
3750 if (!("filter"in Array.prototype
3753 // Array.prototype.filter
3754 /* global CreateMethodProperty, ToObject, ToLength, Get, IsCallable, ArraySpeciesCreate, ToString, HasProperty, ToBoolean, Call, CreateDataPropertyOrThrow */
3755 // 22.1.3.7. Array.prototype.filter ( callbackfn [ , thisArg ] )
3756 CreateMethodProperty(Array.prototype, 'filter', function filter(callbackfn /* [ , thisArg ] */) {
3757 // 1. Let O be ? ToObject(this value).
3758 var O = ToObject(this);
3759 // 2. Let len be ? ToLength(? Get(O, "length")).
3760 var len = ToLength(Get(O, "length"));
3761 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
3762 if (IsCallable(callbackfn) === false) {
3763 throw new TypeError(callbackfn + ' is not a function');
3765 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
3766 var T = arguments.length > 1 ? arguments[1] : undefined;
3767 // 5. Let A be ? ArraySpeciesCreate(O, 0).
3768 var A = ArraySpeciesCreate(O, 0);
3773 // 8. Repeat, while k < len
3775 // a. Let Pk be ! ToString(k).
3776 var Pk = ToString(k);
3777 // b. Let kPresent be ? HasProperty(O, Pk).
3778 var kPresent = HasProperty(O, Pk);
3779 // c. If kPresent is true, then
3781 // i. Let kValue be ? Get(O, Pk).
3782 var kValue = Get(O, Pk);
3783 // ii. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
3784 var selected = ToBoolean(Call(callbackfn, T, [kValue, k, O]));
3785 // iii. If selected is true, then
3787 // 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue)
3788 CreateDataPropertyOrThrow(A, ToString(to), kValue);
3789 // 2. Increase to by 1.
3794 // d. Increase k by 1.
3803 if (!("map"in Array.prototype
3806 // Array.prototype.map
3807 /* global ArraySpeciesCreate, Call, CreateDataPropertyOrThrow, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
3808 /* global CreateMethodProperty, ToObject, ToLength, Get, ArraySpeciesCreate, ToString, HasProperty, Call, CreateDataPropertyOrThrow */
3809 // 22.1.3.16. Array.prototype.map ( callbackfn [ , thisArg ] )
3810 CreateMethodProperty(Array.prototype, 'map', function map(callbackfn /* [ , thisArg ] */) {
3811 // 1. Let O be ? ToObject(this value).
3812 var O = ToObject(this);
3813 // 2. Let len be ? ToLength(? Get(O, "length")).
3814 var len = ToLength(Get(O, "length"));
3815 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
3816 if (IsCallable(callbackfn) === false) {
3817 throw new TypeError(callbackfn + ' is not a function');
3819 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
3820 var T = arguments.length > 1 ? arguments[1] : undefined;
3821 // 5. Let A be ? ArraySpeciesCreate(O, len).
3822 var A = ArraySpeciesCreate(O, len);
3825 // 7. Repeat, while k < len
3827 // a. Let Pk be ! ToString(k).
3828 var Pk = ToString(k);
3829 // b. Let kPresent be ? HasProperty(O, Pk).
3830 var kPresent = HasProperty(O, Pk);
3831 // c. If kPresent is true, then
3833 // i. Let kValue be ? Get(O, Pk).
3834 var kValue = Get(O, Pk);
3835 // ii. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
3836 var mappedValue = Call(callbackfn, T, [kValue, k, O]);
3837 // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
3838 CreateDataPropertyOrThrow(A, Pk, mappedValue);
3840 // d. Increase k by 1.
3853 /* global ArrayCreate, Construct, CreateDataPropertyOrThrow, CreateMethodProperty, IsConstructor, ToString */
3854 // 22.1.2.3. Array.of ( ...items )
3855 CreateMethodProperty(Array, 'of', function of() {
3856 // 1. Let len be the actual number of arguments passed to this function.
3857 var len = arguments.length;
3858 // 2. Let items be the List of arguments passed to this function.
3859 var items = arguments;
3860 // 3. Let C be the this value.
3862 // 4. If IsConstructor(C) is true, then
3863 if (IsConstructor(C)) {
3864 // a. Let A be ? Construct(C, « len »).
3865 var A = Construct(C, [len]);
3868 // a. Let A be ? ArrayCreate(len).
3869 var A = ArrayCreate(len);
3873 // 7. Repeat, while k < len
3875 // a. Let kValue be items[k].
3876 var kValue = items[k];
3877 // b. Let Pk be ! ToString(k).
3878 var Pk = ToString(k);
3879 // c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue).
3880 CreateDataPropertyOrThrow(A, Pk, kValue);
3881 // d. Increase k by 1.
3885 // 8. Perform ? Set(A, "length", len, true)
3893 if (!("seal"in Object&&function(){try{return Object.seal("1"),!0}catch(t){return!1}}
3897 /* global CreateMethodProperty, Type */
3898 // 19.1.2.19 Object.seal ( O )
3899 (function(originalObjectSeal) {
3900 CreateMethodProperty(Object, 'seal', function seal(O) {
3901 // 1. If Type(O) is not Object, return O.
3902 if (Type(O) === 'object') {
3905 // 2. Let status be ? SetIntegrityLevel(O, "sealed").
3906 // 3. If status is false, throw a TypeError exception.
3908 return originalObjectSeal ? originalObjectSeal(O) : O;
3916 // Object.setPrototypeOf
3917 /* global CreateMethodProperty */
3918 // ES6-shim 0.16.0 (c) 2013-2014 Paul Miller (http://paulmillr.com)
3919 // ES6-shim may be freely distributed under the MIT license.
3920 // For more details and documentation:
3921 // https://github.com/paulmillr/es6-shim/
3923 // NOTE: This versions needs object ownership
3924 // because every promoted object needs to be reassigned
3925 // otherwise uncompatible browsers cannot work as expected
3927 // NOTE: This might need es5-shim or polyfills upfront
3928 // because it's based on ES5 API.
3929 // (probably just an IE <= 8 problem)
3931 // NOTE: nodejs is fine in version 0.8, 0.10, and future versions.
3933 if (Object.setPrototypeOf) { return; }
3935 /*jshint proto: true */
3936 // @author Andrea Giammarchi - @WebReflection
3938 var getOwnPropertyNames = Object.getOwnPropertyNames;
3939 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
3940 var create = Object.create;
3941 var defineProperty = Object.defineProperty;
3942 var getPrototypeOf = Object.getPrototypeOf;
3943 var objProto = Object.prototype;
3945 var copyDescriptors = function (target, source) {
3946 // define into target descriptors from source
3947 getOwnPropertyNames(source).forEach(function (key) {
3951 getOwnPropertyDescriptor(source, key)
3956 // used as fallback when no promotion is possible
3957 var createAndCopy = function setPrototypeOf(origin, proto) {
3958 return copyDescriptors(create(proto), origin);
3962 // this might fail for various reasons
3963 // ignore if Chrome cought it at runtime
3964 set = getOwnPropertyDescriptor(objProto, '__proto__').set;
3966 // setter not poisoned, it can promote
3968 sPOf = function setPrototypeOf(origin, proto) {
3969 set.call(origin, proto);
3973 // do one or more feature detections
3974 set = { __proto__: null };
3975 // if proto does not work, needs to fallback
3976 // some Opera, Rhino, ducktape
3977 if (set instanceof Object) {
3978 sPOf = createAndCopy;
3980 // verify if null objects are buggy
3981 /* eslint-disable no-proto */
3982 set.__proto__ = objProto;
3983 /* eslint-enable no-proto */
3984 // if null objects are buggy
3985 // nodejs 0.8 to 0.10
3986 if (set instanceof Object) {
3987 sPOf = function setPrototypeOf(origin, proto) {
3988 // use such bug to promote
3989 /* eslint-disable no-proto */
3990 origin.__proto__ = proto;
3991 /* eslint-enable no-proto */
3995 // try to use proto or fallback
3996 // Safari, old Firefox, many others
3997 sPOf = function setPrototypeOf(origin, proto) {
3998 // if proto is not null
3999 if (getPrototypeOf(origin)) {
4000 // use __proto__ to promote
4001 /* eslint-disable no-proto */
4002 origin.__proto__ = proto;
4003 /* eslint-enable no-proto */
4006 // otherwise unable to promote: fallback
4007 return createAndCopy(origin, proto);
4013 CreateMethodProperty(Object, 'setPrototypeOf', sPOf);
4015 if (!("Promise"in this
4019 !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:/*!***********************!*\
4020 !*** ./src/global.js ***!
4021 \***********************/
4022 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:/*!***********************************!*\
4023 !*** (webpack)/buildin/global.js ***!
4024 \***********************************/
4025 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:/*!*********************!*\
4026 !*** ./src/yaku.js ***!
4027 \*********************/
4028 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))}});
4031 if (!("flags"in RegExp.prototype
4034 // RegExp.prototype.flags
4035 /* global Get, ToBoolean, Type */
4036 Object.defineProperty(RegExp.prototype, 'flags', {
4040 // 21.2.5.3.1 Let R be the this value.
4043 // 21.2.5.3.2 If Type(R) is not Object, throw a TypeError exception.
4044 if (Type(R) !== 'object') {
4045 throw new TypeError('Method called on incompatible type: must be an object.');
4047 // 21.2.5.3.3 Let result be the empty String.
4050 // 21.2.5.3.4 Let global be ToBoolean(? Get(R, "global")).
4051 var global = ToBoolean(Get(R, 'global'));
4053 // 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.
4058 // 21.2.5.3.6 Let ignoreCase be ToBoolean(? Get(R, "ignoreCase")).
4059 var ignoreCase = ToBoolean(Get(R, 'ignoreCase'));
4061 // 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.
4066 // 21.2.5.3.8 Let multiline be ToBoolean(? Get(R, "multiline")).
4067 var multiline = ToBoolean(Get(R, 'multiline'));
4069 // 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.
4074 // 21.2.5.3.10 Let unicode be ToBoolean(? Get(R, "unicode")).
4075 var unicode = ToBoolean(Get(R, 'unicode'));
4077 // 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.
4082 // 21.2.5.3.12 Let sticky be ToBoolean(? Get(R, "sticky")).
4083 var sticky = ToBoolean(Get(R, 'sticky'));
4085 // 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.
4090 // 21.2.5.3.14 Return result.
4097 if (!("fromCodePoint"in String&&1===String.fromCodePoint.length
4100 // String.fromCodePoint
4101 /* global CreateMethodProperty, IsArray, SameValue, ToInteger, ToNumber, UTF16Encoding */
4103 // 21.1.2.2. String.fromCodePoint ( ...codePoints )
4104 CreateMethodProperty(String, 'fromCodePoint', function fromCodePoint(_) { // eslint-disable-line no-unused-vars
4105 // Polyfill.io - List to store the characters whilst iterating over the code points.
4107 // 1. Let codePoints be a List containing the arguments passed to this function.
4108 var codePoints = arguments;
4109 // 2. Let length be the number of elements in codePoints.
4110 var length = arguments.length;
4111 // 3. Let elements be a new empty List.
4113 // 4. Let nextIndex be 0.
4115 // 5. Repeat, while nextIndex < length
4116 while (nextIndex < length) {
4117 // Polyfill.io - We reset the elements List as we store the partial results in the result List.
4119 // a. Let next be codePoints[nextIndex].
4120 var next = codePoints[nextIndex];
4121 // b. Let nextCP be ? ToNumber(next).
4122 var nextCP = ToNumber(next);
4123 // c. If SameValue(nextCP, ToInteger(nextCP)) is false, throw a RangeError exception.
4124 if (SameValue(nextCP, ToInteger(nextCP)) === false) {
4125 throw new RangeError('Invalid code point ' + Object.prototype.toString.call(nextCP));
4127 // d. If nextCP < 0 or nextCP > 0x10FFFF, throw a RangeError exception.
4128 if (nextCP < 0 || nextCP > 0x10FFFF) {
4129 throw new RangeError('Invalid code point ' + Object.prototype.toString.call(nextCP));
4131 // e. Append the elements of the UTF16Encoding of nextCP to the end of elements.
4132 // Polyfill.io - UTF16Encoding can return a single codepoint or a list of multiple codepoints.
4133 var cp = UTF16Encoding(nextCP);
4135 elements = elements.concat(cp);
4139 // f. Let nextIndex be nextIndex + 1.
4140 nextIndex = nextIndex + 1;
4142 // Polyfill.io - Retrieving the characters whilst iterating enables the function to work in a memory efficient and performant way.
4143 result.push(String.fromCharCode.apply(null, elements));
4145 // 6. Return the String value whose elements are, in order, the elements in the List elements. If length is 0, the empty string is returned.
4146 return length === 0 ? '' : result.join('');
4151 if (!("codePointAt"in String.prototype
4154 // String.prototype.codePointAt
4155 /* global CreateMethodProperty, RequireObjectCoercible, ToInteger, ToString, UTF16Decode */
4156 // 21.1.3.3. String.prototype.codePointAt ( pos )
4157 CreateMethodProperty(String.prototype, 'codePointAt', function codePointAt(pos) {
4158 // 1. Let O be ? RequireObjectCoercible(this value).
4159 var O = RequireObjectCoercible(this);
4160 // 2. Let S be ? ToString(O).
4161 var S = ToString(O);
4162 // 3. Let position be ? ToInteger(pos).
4163 var position = ToInteger(pos);
4164 // 4. Let size be the length of S.
4165 var size = S.length;
4166 // 5. If position < 0 or position ≥ size, return undefined.
4167 if (position < 0 || position >= size) {
4170 // 6. Let first be the numeric value of the code unit at index position within the String S.
4171 var first = String.prototype.charCodeAt.call(S, position);
4172 // 7. If first < 0xD800 or first > 0xDBFF or position+1 = size, return first.
4173 if (first < 0xD800 || first > 0xDBFF || position + 1 === size) {
4176 // 8. Let second be the numeric value of the code unit at index position+1 within the String S.
4177 var second = String.prototype.charCodeAt.call(S, position + 1);
4178 // 9. If second < 0xDC00 or second > 0xDFFF, return first.
4179 if (second < 0xDC00 || second > 0xDFFF) {
4182 // 10. Return UTF16Decode(first, second).
4183 // 21.1.3.3.10 Return UTF16Decode(first, second).
4184 return UTF16Decode(first, second);
4189 if (!("endsWith"in String.prototype
4192 // String.prototype.endsWith
4193 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
4194 // 21.1.3.6. String.prototype.endsWith ( searchString [ , endPosition ] )
4195 CreateMethodProperty(String.prototype, 'endsWith', function endsWith(searchString /* [ , endPosition ] */) {
4197 var endPosition = arguments.length > 1 ? arguments[1] : undefined;
4198 // 1. Let O be ? RequireObjectCoercible(this value).
4199 var O = RequireObjectCoercible(this);
4200 // 2. Let S be ? ToString(O).
4201 var S = ToString(O);
4202 // 3. Let isRegExp be ? IsRegExp(searchString).
4203 var isRegExp = IsRegExp(searchString);
4204 // 4. If isRegExp is true, throw a TypeError exception.
4206 throw new TypeError('First argument to String.prototype.endsWith must not be a regular expression');
4208 // 5. Let searchStr be ? ToString(searchString).
4209 var searchStr = ToString(searchString);
4210 // 6. Let len be the length of S.
4212 // 7. If endPosition is undefined, let pos be len, else let pos be ? ToInteger(endPosition).
4213 var pos = endPosition === undefined ? len : ToInteger(endPosition);
4214 // 8. Let end be min(max(pos, 0), len).
4215 var end = Math.min(Math.max(pos, 0), len);
4216 // 9. Let searchLength be the length of searchStr.
4217 var searchLength = searchStr.length;
4218 // 10. Let start be end - searchLength.
4219 var start = end - searchLength;
4220 // 11. If start is less than 0, return false.
4224 // 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.
4225 if (S.substr(start, searchLength) === searchStr) {
4228 // 13. Otherwise, return false.
4234 if (!("includes"in String.prototype
4237 // String.prototype.includes
4238 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
4239 // 21.1.3.7. String.prototype.includes ( searchString [ , position ] )
4240 CreateMethodProperty(String.prototype, 'includes', function includes(searchString /* [ , position ] */) {
4242 var position = arguments.length > 1 ? arguments[1] : undefined;
4243 // 1. Let O be ? RequireObjectCoercible(this value).
4244 var O = RequireObjectCoercible(this);
4245 // 2. Let S be ? ToString(O).
4246 var S = ToString(O);
4247 // 3. Let isRegExp be ? IsRegExp(searchString).
4248 var isRegExp = IsRegExp(searchString);
4249 // 4. If isRegExp is true, throw a TypeError exception.
4251 throw new TypeError('First argument to String.prototype.includes must not be a regular expression');
4253 // 5. Let searchStr be ? ToString(searchString).
4254 var searchStr = ToString(searchString);
4255 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
4256 var pos = ToInteger(position);
4257 // 7. Let len be the length of S.
4259 // 8. Let start be min(max(pos, 0), len).
4260 var start = Math.min(Math.max(pos, 0), len);
4261 // 9. Let searchLen be the length of searchStr.
4262 // var searchLength = searchStr.length;
4263 // 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.
4264 return String.prototype.indexOf.call(S, searchStr, start) !== -1;
4269 if (!("repeat"in String.prototype
4272 // String.prototype.repeat
4273 /* global CreateMethodProperty, RequireObjectCoercible, ToInteger, ToString */
4274 // 21.1.3.15String.prototype.repeat ( count )
4275 CreateMethodProperty(String.prototype, 'repeat', function repeat(count) {
4277 // 1. Let O be ? RequireObjectCoercible(this value).
4278 var O = RequireObjectCoercible(this);
4279 // 2. Let S be ? ToString(O).
4280 var S = ToString(O);
4281 // 3. Let n be ? ToInteger(count).
4282 var n = ToInteger(count);
4283 // 4. If n < 0, throw a RangeError exception.
4285 throw new RangeError('Invalid count value');
4287 // 5. If n is +∞, throw a RangeError exception.
4288 if (n === Infinity) {
4289 throw new RangeError('Invalid count value');
4291 // 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.
4292 var T = n === 0 ? '' : new Array(n + 1).join(S);
4299 if (!("startsWith"in String.prototype
4302 // String.prototype.startsWith
4303 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
4304 // 21.1.3.20. String.prototype.startsWith ( searchString [ , position ] )
4305 CreateMethodProperty(String.prototype, 'startsWith', function startsWith(searchString /* [ , position ] */) {
4307 var position = arguments.length > 1 ? arguments[1] : undefined;
4308 // 1. Let O be ? RequireObjectCoercible(this value).
4309 var O = RequireObjectCoercible(this);
4310 // 2. Let S be ? ToString(O).
4311 var S = ToString(O);
4312 // 3. Let isRegExp be ? IsRegExp(searchString).
4313 var isRegExp = IsRegExp(searchString);
4314 // 4. If isRegExp is true, throw a TypeError exception.
4316 throw new TypeError('First argument to String.prototype.startsWith must not be a regular expression');
4318 // 5. Let searchStr be ? ToString(searchString).
4319 var searchStr = ToString(searchString);
4320 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
4321 var pos = ToInteger(position);
4322 // 7. Let len be the length of S.
4324 // 8. Let start be min(max(pos, 0), len).
4325 var start = Math.min(Math.max(pos, 0), len);
4326 // 9. Let searchLength be the length of searchStr.
4327 var searchLength = searchStr.length;
4328 // 10. If searchLength+start is greater than len, return false.
4329 if (searchLength + start > len) {
4332 // 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.
4333 if (S.substr(start).indexOf(searchString) === 0) {
4336 // 12. Otherwise, return false.
4342 if (!("Symbol"in this&&0===this.Symbol.length
4346 // A modification of https://github.com/WebReflection/get-own-property-symbols
4347 // (C) Andrea Giammarchi - MIT Licensed
4349 (function (Object, GOPS, global) {
4353 var random = '' + Math.random();
4354 var prefix = '__\x01symbol:';
4355 var prefixLength = prefix.length;
4356 var internalSymbol = '__\x01symbol@@' + random;
4357 var DP = 'defineProperty';
4358 var DPies = 'defineProperties';
4359 var GOPN = 'getOwnPropertyNames';
4360 var GOPD = 'getOwnPropertyDescriptor';
4361 var PIE = 'propertyIsEnumerable';
4362 var ObjectProto = Object.prototype;
4363 var hOP = ObjectProto.hasOwnProperty;
4364 var pIE = ObjectProto[PIE];
4365 var toString = ObjectProto.toString;
4366 var concat = Array.prototype.concat;
4367 var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : [];
4368 var nGOPN = Object[GOPN];
4369 var gOPN = function getOwnPropertyNames (obj) {
4370 if (toString.call(obj) === '[object Window]') {
4374 // IE bug where layout engine calls userland gOPN for cross-domain `window` objects
4375 return concat.call([], cachedWindowNames);
4380 var gOPD = Object[GOPD];
4381 var create = Object.create;
4382 var keys = Object.keys;
4383 var freeze = Object.freeze || Object;
4384 var defineProperty = Object[DP];
4385 var $defineProperties = Object[DPies];
4386 var descriptor = gOPD(Object, GOPN);
4387 var addInternalIfNeeded = function (o, uid, enumerable) {
4388 if (!hOP.call(o, internalSymbol)) {
4390 defineProperty(o, internalSymbol, {
4392 configurable: false,
4397 o[internalSymbol] = {};
4400 o[internalSymbol]['@@' + uid] = enumerable;
4402 var createWithSymbols = function (proto, descriptors) {
4403 var self = create(proto);
4404 gOPN(descriptors).forEach(function (key) {
4405 if (propertyIsEnumerable.call(descriptors, key)) {
4406 $defineProperty(self, key, descriptors[key]);
4411 var copyAsNonEnumerable = function (descriptor) {
4412 var newDescriptor = create(descriptor);
4413 newDescriptor.enumerable = false;
4414 return newDescriptor;
4416 var get = function get(){};
4417 var onlyNonSymbols = function (name) {
4418 return name != internalSymbol &&
4419 !hOP.call(source, name);
4421 var onlySymbols = function (name) {
4422 return name != internalSymbol &&
4423 hOP.call(source, name);
4425 var propertyIsEnumerable = function propertyIsEnumerable(key) {
4427 return onlySymbols(uid) ? (
4428 hOP.call(this, uid) &&
4429 this[internalSymbol]['@@' + uid]
4430 ) : pIE.call(this, key);
4432 var setAndGetSymbol = function (uid) {
4437 set: function (value) {
4438 setDescriptor(this, uid, {
4444 addInternalIfNeeded(this, uid, true);
4448 defineProperty(ObjectProto, uid, descriptor);
4450 ObjectProto[uid] = descriptor.value;
4452 return freeze(source[uid] = defineProperty(
4458 var Symbol = function Symbol() {
4459 var description = arguments[0];
4460 if (this instanceof Symbol) {
4461 throw new TypeError('Symbol is not a constructor');
4463 return setAndGetSymbol(
4464 prefix.concat(description || '', random, ++id)
4467 var source = create(null);
4468 var sourceConstructor = {value: Symbol};
4469 var sourceMap = function (uid) {
4472 var $defineProperty = function defineProp(o, key, descriptor) {
4474 if (onlySymbols(uid)) {
4475 setDescriptor(o, uid, descriptor.enumerable ?
4476 copyAsNonEnumerable(descriptor) : descriptor);
4477 addInternalIfNeeded(o, uid, !!descriptor.enumerable);
4479 defineProperty(o, key, descriptor);
4484 var onlyInternalSymbols = function (obj) {
4485 return function (name) {
4486 return hOP.call(obj, internalSymbol) && hOP.call(obj[internalSymbol], '@@' + name);
4489 var $getOwnPropertySymbols = function getOwnPropertySymbols(o) {
4490 return gOPN(o).filter(o === ObjectProto ? onlyInternalSymbols(o) : onlySymbols).map(sourceMap);
4494 descriptor.value = $defineProperty;
4495 defineProperty(Object, DP, descriptor);
4497 descriptor.value = $getOwnPropertySymbols;
4498 defineProperty(Object, GOPS, descriptor);
4500 descriptor.value = function getOwnPropertyNames(o) {
4501 return gOPN(o).filter(onlyNonSymbols);
4503 defineProperty(Object, GOPN, descriptor);
4505 descriptor.value = function defineProperties(o, descriptors) {
4506 var symbols = $getOwnPropertySymbols(descriptors);
4507 if (symbols.length) {
4508 keys(descriptors).concat(symbols).forEach(function (uid) {
4509 if (propertyIsEnumerable.call(descriptors, uid)) {
4510 $defineProperty(o, uid, descriptors[uid]);
4514 $defineProperties(o, descriptors);
4518 defineProperty(Object, DPies, descriptor);
4520 descriptor.value = propertyIsEnumerable;
4521 defineProperty(ObjectProto, PIE, descriptor);
4523 descriptor.value = Symbol;
4524 defineProperty(global, 'Symbol', descriptor);
4526 // defining `Symbol.for(key)`
4527 descriptor.value = function (key) {
4528 var uid = prefix.concat(prefix, key, random);
4529 return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid);
4531 defineProperty(Symbol, 'for', descriptor);
4533 // defining `Symbol.keyFor(symbol)`
4534 descriptor.value = function (symbol) {
4535 if (onlyNonSymbols(symbol))
4536 throw new TypeError(symbol + ' is not a symbol');
4537 return hOP.call(source, symbol) ?
4538 symbol.slice(prefixLength * 2, -random.length) :
4542 defineProperty(Symbol, 'keyFor', descriptor);
4544 descriptor.value = function getOwnPropertyDescriptor(o, key) {
4545 var descriptor = gOPD(o, key);
4546 if (descriptor && onlySymbols(key)) {
4547 descriptor.enumerable = propertyIsEnumerable.call(o, key);
4551 defineProperty(Object, GOPD, descriptor);
4553 descriptor.value = function (proto, descriptors) {
4554 return arguments.length === 1 || typeof descriptors === "undefined" ?
4556 createWithSymbols(proto, descriptors);
4558 defineProperty(Object, 'create', descriptor);
4560 descriptor.value = function () {
4561 var str = toString.call(this);
4562 return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
4564 defineProperty(ObjectProto, 'toString', descriptor);
4567 setDescriptor = function (o, key, descriptor) {
4568 var protoDescriptor = gOPD(ObjectProto, key);
4569 delete ObjectProto[key];
4570 defineProperty(o, key, descriptor);
4571 if (o !== ObjectProto) {
4572 defineProperty(ObjectProto, key, protoDescriptor);
4576 }(Object, 'getOwnPropertySymbols', this));
4580 if (!("Symbol"in this&&"hasInstance"in this.Symbol
4583 // Symbol.hasInstance
4585 Object.defineProperty(Symbol, 'hasInstance', { value: Symbol('hasInstance') });
4589 if (!("Symbol"in this&&"isConcatSpreadable"in this.Symbol
4592 // Symbol.isConcatSpreadable
4594 Object.defineProperty(Symbol, 'isConcatSpreadable', { value: Symbol('isConcatSpreadable') });
4598 if (!("Symbol"in this&&"iterator"in this.Symbol
4603 Object.defineProperty(Symbol, 'iterator', { value: Symbol('iterator') });
4607 if (!("Symbol"in this&&"match"in this.Symbol
4612 Object.defineProperty(Symbol, 'match', { value: Symbol('match') });
4616 if (!("Symbol"in this&&"replace"in this.Symbol
4621 Object.defineProperty(Symbol, 'replace', { value: Symbol('replace') });
4625 if (!("Symbol"in this&&"search"in this.Symbol
4630 Object.defineProperty(Symbol, 'search', { value: Symbol('search') });
4634 if (!("Symbol"in this&&"species"in this.Symbol
4639 Object.defineProperty(Symbol, 'species', { value: Symbol('species') });
4643 if (!("Map"in this&&function(){try{var t=new Map([[1,1],[2,2]])
4644 return 0===Map.length&&2===t.size&&"Symbol"in this&&"iterator"in Symbol&&"function"==typeof t[Symbol.iterator]}catch(n){return!1}}()
4648 /* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
4649 (function (global) {
4650 var supportsGetters = (function () {
4653 Object.defineProperty(a, 't', {
4667 // 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.
4668 var undefMarker = Symbol('undef');
4669 // 23.1.1.1 Map ( [ iterable ] )
4670 var Map = function Map(/* iterable */) {
4671 // 1. If NewTarget is undefined, throw a TypeError exception.
4672 if (!(this instanceof Map)) {
4673 throw new TypeError('Constructor Map requires "new"');
4675 // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%MapPrototype%", « [[MapData]] »).
4676 var map = OrdinaryCreateFromConstructor(this, Map.prototype, {
4683 // 3. Set map.[[MapData]] to a new empty List.
4684 // Polyfill.io - This step was done as part of step two.
4686 // 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.
4687 if (!supportsGetters) {
4688 Object.defineProperty(map, 'size', {
4696 // 4. If iterable is not present, let iterable be undefined.
4697 var iterable = arguments.length > 0 ? arguments[0] : undefined;
4699 // 5. If iterable is either undefined or null, return map.
4700 if (iterable === null || iterable === undefined) {
4704 // 6. Let adder be ? Get(map, "set").
4705 var adder = map.set;
4707 // 7. If IsCallable(adder) is false, throw a TypeError exception.
4708 if (!IsCallable(adder)) {
4709 throw new TypeError("Map.prototype.set is not a function");
4712 // 8. Let iteratorRecord be ? GetIterator(iterable).
4714 var iteratorRecord = GetIterator(iterable);
4717 // a. Let next be ? IteratorStep(iteratorRecord).
4718 var next = IteratorStep(iteratorRecord);
4719 // b. If next is false, return map.
4720 if (next === false) {
4723 // c. Let nextItem be ? IteratorValue(next).
4724 var nextItem = IteratorValue(next);
4725 // d. If Type(nextItem) is not Object, then
4726 if (Type(nextItem) !== 'object') {
4727 // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
4729 throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
4731 // ii. Return ? IteratorClose(iteratorRecord, error).
4732 return IteratorClose(iteratorRecord, error);
4736 // Polyfill.io - The try catch accounts for steps: f, h, and j.
4738 // e. Let k be Get(nextItem, "0").
4739 var k = nextItem[0];
4740 // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
4741 // g. Let v be Get(nextItem, "1").
4742 var v = nextItem[1];
4743 // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
4744 // i. Let status be Call(adder, map, « k.[[Value]], v.[[Value]] »).
4745 adder.call(map, k, v);
4747 // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
4748 return IteratorClose(iteratorRecord, e);
4752 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
4753 if (Array.isArray(iterable) ||
4754 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
4755 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
4756 (!!iterable.callee)) {
4758 var length = iterable.length;
4759 for (index = 0; index < length; index++) {
4760 adder.call(map, iterable[index][0], iterable[index][1]);
4767 // 23.1.2.1. Map.prototype
4768 // The initial value of Map.prototype is the intrinsic object %MapPrototype%.
4769 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
4770 Object.defineProperty(Map, 'prototype', {
4771 configurable: false,
4777 // 23.1.2.2 get Map [ @@species ]
4778 if (supportsGetters) {
4779 Object.defineProperty(Map, Symbol.species, {
4783 // 1. Return the this value.
4789 CreateMethodProperty(Map, Symbol.species, Map);
4792 // 23.1.3.1 Map.prototype.clear ( )
4793 CreateMethodProperty(Map.prototype, 'clear', function clear() {
4794 // 1. Let M be the this value.
4796 // 2. If Type(M) is not Object, throw a TypeError exception.
4797 if (Type(M) !== 'object') {
4798 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
4800 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
4801 if (M._es6Map !== true) {
4802 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
4804 // 4. Let entries be the List that is M.[[MapData]].
4805 var entries = M._keys;
4806 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
4807 for (var i = 0; i < entries.length; i++) {
4808 // 5.a. Set p.[[Key]] to empty.
4809 M._keys[i] = undefMarker;
4810 // 5.b. Set p.[[Value]] to empty.
4811 M._values[i] = undefMarker;
4814 if (!supportsGetters) {
4815 this.size = this._size;
4817 // 6. Return undefined.
4822 // 23.1.3.2. Map.prototype.constructor
4823 CreateMethodProperty(Map.prototype, 'constructor', Map);
4825 // 23.1.3.3. Map.prototype.delete ( key )
4826 CreateMethodProperty(Map.prototype, 'delete', function (key) {
4827 // 1. Let M be the this value.
4829 // 2. If Type(M) is not Object, throw a TypeError exception.
4830 if (Type(M) !== 'object') {
4831 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
4833 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
4834 if (M._es6Map !== true) {
4835 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
4837 // 4. Let entries be the List that is M.[[MapData]].
4838 var entries = M._keys;
4839 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
4840 for (var i = 0; i < entries.length; i++) {
4841 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
4842 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
4843 // i. Set p.[[Key]] to empty.
4844 this._keys[i] = undefMarker;
4845 // ii. Set p.[[Value]] to empty.
4846 this._values[i] = undefMarker;
4847 this._size = --this._size;
4848 if (!supportsGetters) {
4849 this.size = this._size;
4851 // iii. Return true.
4860 // 23.1.3.4. Map.prototype.entries ( )
4861 CreateMethodProperty(Map.prototype, 'entries', function entries () {
4862 // 1. Let M be the this value.
4864 // 2. Return ? CreateMapIterator(M, "key+value").
4865 return CreateMapIterator(M, 'key+value');
4869 // 23.1.3.5. Map.prototype.forEach ( callbackfn [ , thisArg ] )
4870 CreateMethodProperty(Map.prototype, 'forEach', function (callbackFn) {
4871 // 1. Let M be the this value.
4873 // 2. If Type(M) is not Object, throw a TypeError exception.
4874 if (Type(M) !== 'object') {
4875 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
4877 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
4878 if (M._es6Map !== true) {
4879 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
4881 // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
4882 if (!IsCallable(callbackFn)) {
4883 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
4885 // 5. If thisArg is present, let T be thisArg; else let T be undefined.
4887 var T = arguments[1];
4889 // 6. Let entries be the List that is M.[[MapData]].
4890 var entries = M._keys;
4891 // 7. For each Record {[[Key]], [[Value]]} e that is an element of entries, in original key insertion order, do
4892 for (var i = 0; i < entries.length; i++) {
4893 // a. If e.[[Key]] is not empty, then
4894 if (M._keys[i] !== undefMarker && M._values[i] !== undefMarker ) {
4895 // i. Perform ? Call(callbackfn, T, « e.[[Value]], e.[[Key]], M »).
4896 callbackFn.call(T, M._values[i], M._keys[i], M);
4899 // 8. Return undefined.
4904 // 23.1.3.6. Map.prototype.get ( key )
4905 CreateMethodProperty(Map.prototype, 'get', function get(key) {
4906 // 1. Let M be the this value.
4908 // 2. If Type(M) is not Object, throw a TypeError exception.
4909 if (Type(M) !== 'object') {
4910 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
4912 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
4913 if (M._es6Map !== true) {
4914 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
4916 // 4. Let entries be the List that is M.[[MapData]].
4917 var entries = M._keys;
4918 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
4919 for (var i = 0; i < entries.length; i++) {
4920 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return p.[[Value]].
4921 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
4922 return M._values[i];
4925 // 6. Return undefined.
4929 // 23.1.3.7. Map.prototype.has ( key )
4930 CreateMethodProperty(Map.prototype, 'has', function has (key) {
4931 // 1. Let M be the this value.
4933 // 2. If Type(M) is not Object, throw a TypeError exception.
4934 if (typeof M !== 'object') {
4935 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
4937 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
4938 if (M._es6Map !== true) {
4939 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
4941 // 4. Let entries be the List that is M.[[MapData]].
4942 var entries = M._keys;
4943 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
4944 for (var i = 0; i < entries.length; i++) {
4945 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return true.
4946 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
4954 // 23.1.3.8. Map.prototype.keys ( )
4955 CreateMethodProperty(Map.prototype, 'keys', function keys () {
4956 // 1. Let M be the this value.
4958 // 2. Return ? CreateMapIterator(M, "key").
4959 return CreateMapIterator(M, "key");
4962 // 23.1.3.9. Map.prototype.set ( key, value )
4963 CreateMethodProperty(Map.prototype, 'set', function set(key, value) {
4964 // 1. Let M be the this value.
4966 // 2. If Type(M) is not Object, throw a TypeError exception.
4967 if (Type(M) !== 'object') {
4968 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
4970 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
4971 if (M._es6Map !== true) {
4972 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
4974 // 4. Let entries be the List that is M.[[MapData]].
4975 var entries = M._keys;
4976 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
4977 for (var i = 0; i < entries.length; i++) {
4978 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
4979 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
4980 // i. Set p.[[Value]] to value.
4981 M._values[i] = value;
4986 // 6. If key is -0, let key be +0.
4990 // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
4993 p['[[Value]]'] = value;
4994 // 8. Append p as the last element of entries.
4995 M._keys.push(p['[[Key]]']);
4996 M._values.push(p['[[Value]]']);
4998 if (!supportsGetters) {
5005 // 23.1.3.10. get Map.prototype.size
5006 if (supportsGetters) {
5007 Object.defineProperty(Map.prototype, 'size', {
5011 // 1. Let M be the this value.
5013 // 2. If Type(M) is not Object, throw a TypeError exception.
5014 if (Type(M) !== 'object') {
5015 throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
5017 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
5018 if (M._es6Map !== true) {
5019 throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
5021 // 4. Let entries be the List that is M.[[MapData]].
5022 var entries = M._keys;
5023 // 5. Let count be 0.
5025 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
5026 for (var i = 0; i < entries.length; i++) {
5027 // a. If p.[[Key]] is not empty, set count to count+1.
5028 if (M._keys[i] !== undefMarker) {
5039 // 23.1.3.11. Map.prototype.values ( )
5040 CreateMethodProperty(Map.prototype, 'values', function values () {
5041 // 1. Let M be the this value.
5043 // 2. Return ? CreateMapIterator(M, "value").
5044 return CreateMapIterator(M, 'value');
5048 // 23.1.3.12. Map.prototype [ @@iterator ] ( )
5049 // The initial value of the @@iterator property is the same function object as the initial value of the entries property.
5050 CreateMethodProperty(Map.prototype, Symbol.iterator, Map.prototype.entries);
5052 // 23.1.3.13. Map.prototype [ @@toStringTag ]
5053 // The initial value of the @@toStringTag property is the String value "Map".
5054 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
5056 // 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.
5057 if (!('name' in Map)) {
5059 Object.defineProperty(Map, 'name', {
5067 // 23.1.5.1. CreateMapIterator ( map, kind )
5068 function CreateMapIterator(map, kind) {
5069 // 1. If Type(map) is not Object, throw a TypeError exception.
5070 if (Type(map) !== 'object') {
5071 throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
5073 // 2. If map does not have a [[MapData]] internal slot, throw a TypeError exception.
5074 if (map._es6Map !== true) {
5075 throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
5077 // 3. Let iterator be ObjectCreate(%MapIteratorPrototype%, « [[Map]], [[MapNextIndex]], [[MapIterationKind]] »).
5078 var iterator = Object.create(MapIteratorPrototype);
5079 // 4. Set iterator.[[Map]] to map.
5080 Object.defineProperty(iterator, '[[Map]]', {
5086 // 5. Set iterator.[[MapNextIndex]] to 0.
5087 Object.defineProperty(iterator, '[[MapNextIndex]]', {
5093 // 6. Set iterator.[[MapIterationKind]] to kind.
5094 Object.defineProperty(iterator, '[[MapIterationKind]]', {
5100 // 7. Return iterator.
5104 // 23.1.5.2. The %MapIteratorPrototype% Object
5105 var MapIteratorPrototype = {};
5106 // Polyfill.io - We use this as a quick way to check if an object is a Map Iterator instance.
5107 Object.defineProperty(MapIteratorPrototype, 'isMapIterator', {
5108 configurable: false,
5114 // 23.1.5.2.1. %MapIteratorPrototype%.next ( )
5115 CreateMethodProperty(MapIteratorPrototype, 'next', function next() {
5116 // 1. Let O be the this value.
5118 // 2. If Type(O) is not Object, throw a TypeError exception.
5119 if (Type(O) !== 'object') {
5120 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
5122 // 3. If O does not have all of the internal slots of a Map Iterator Instance (23.1.5.3), throw a TypeError exception.
5123 if (!O.isMapIterator) {
5124 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
5126 // 4. Let m be O.[[Map]].
5127 var m = O['[[Map]]'];
5128 // 5. Let index be O.[[MapNextIndex]].
5129 var index = O['[[MapNextIndex]]'];
5130 // 6. Let itemKind be O.[[MapIterationKind]].
5131 var itemKind = O['[[MapIterationKind]]'];
5132 // 7. If m is undefined, return CreateIterResultObject(undefined, true).
5133 if (m === undefined) {
5134 return CreateIterResultObject(undefined, true);
5136 // 8. Assert: m has a [[MapData]] internal slot.
5138 throw new Error(Object.prototype.toString.call(m) + ' has a [[MapData]] internal slot.');
5140 // 9. Let entries be the List that is m.[[MapData]].
5141 var entries = m._keys;
5142 // 10. Let numEntries be the number of elements of entries.
5143 var numEntries = entries.length;
5144 // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
5145 // 12. Repeat, while index is less than numEntries,
5146 while (index < numEntries) {
5147 // a. Let e be the Record {[[Key]], [[Value]]} that is the value of entries[index].
5148 var e = Object.create(null);
5149 e['[[Key]]'] = m._keys[index];
5150 e['[[Value]]'] = m._values[index];
5151 // b. Set index to index+1.
5153 // c. Set O.[[MapNextIndex]] to index.
5154 O['[[MapNextIndex]]'] = index;
5155 // d. If e.[[Key]] is not empty, then
5156 if (e['[[Key]]'] !== undefMarker) {
5157 // i. If itemKind is "key", let result be e.[[Key]].
5158 if (itemKind === 'key') {
5159 var result = e['[[Key]]'];
5160 // ii. Else if itemKind is "value", let result be e.[[Value]].
5161 } else if (itemKind === 'value') {
5162 result = e['[[Value]]'];
5165 // 1. Assert: itemKind is "key+value".
5166 if (itemKind !== 'key+value') {
5169 // 2. Let result be CreateArrayFromList(« e.[[Key]], e.[[Value]] »).
5175 // iv. Return CreateIterResultObject(result, false).
5176 return CreateIterResultObject(result, false);
5179 // 13. Set O.[[Map]] to undefined.
5180 O['[[Map]]'] = undefined;
5181 // 14. Return CreateIterResultObject(undefined, true).
5182 return CreateIterResultObject(undefined, true);
5186 // 23.1.5.2.2 %MapIteratorPrototype% [ @@toStringTag ]
5187 // The initial value of the @@toStringTag property is the String value "Map Iterator".
5188 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
5190 CreateMethodProperty(MapIteratorPrototype, Symbol.iterator, function iterator() {
5195 // Export the object
5197 CreateMethodProperty(global, 'Map', Map);
5199 // IE8 throws an error here if we set enumerable to false.
5200 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
5201 global['Map'] = Map;
5207 if (!("Set"in this&&function(){try{var t=new Set([1,2])
5208 return 0===Set.length&&2===t.size&&"Symbol"in this&&"iterator"in Symbol&&"function"==typeof t[Symbol.iterator]}catch(e){return!1}}()
5212 /* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Symbol */
5213 (function (global) {
5214 var supportsGetters = (function () {
5217 Object.defineProperty(a, 't', {
5231 // 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.
5232 var undefMarker = Symbol('undef');
5233 // 23.2.1.1. Set ( [ iterable ] )
5234 var Set = function Set(/* iterable */) {
5235 // 1. If NewTarget is undefined, throw a TypeError exception.
5236 if (!(this instanceof Set)) {
5237 throw new TypeError('Constructor Set requires "new"');
5239 // 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%SetPrototype%", « [[SetData]] »).
5240 var set = OrdinaryCreateFromConstructor(this, Set.prototype, {
5246 // 3. Set set.[[SetData]] to a new empty List.
5247 // Polyfill.io - This step was done as part of step two.
5249 // 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.
5250 if (!supportsGetters) {
5251 Object.defineProperty(set, 'size', {
5259 // 4. If iterable is not present, let iterable be undefined.
5260 var iterable = arguments.length > 0 ? arguments[0] : undefined;
5262 // 5. If iterable is either undefined or null, return set.
5263 if (iterable === null || iterable === undefined) {
5267 // 6. Let adder be ? Get(set, "add").
5268 var adder = set.add;
5269 // 7. If IsCallable(adder) is false, throw a TypeError exception.
5270 if (!IsCallable(adder)) {
5271 throw new TypeError("Set.prototype.add is not a function");
5275 // 8. Let iteratorRecord be ? GetIterator(iterable).
5276 var iteratorRecord = GetIterator(iterable);
5279 // a. Let next be ? IteratorStep(iteratorRecord).
5280 var next = IteratorStep(iteratorRecord);
5281 // b. If next is false, return set.
5282 if (next === false) {
5285 // c. Let nextValue be ? IteratorValue(next).
5286 var nextValue = IteratorValue(next);
5287 // d. Let status be Call(adder, set, « nextValue.[[Value]] »).
5289 adder.call(set, nextValue);
5291 // e. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
5292 return IteratorClose(iteratorRecord, e);
5296 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
5297 if (Array.isArray(iterable) ||
5298 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
5299 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
5300 (!!iterable.callee)) {
5302 var length = iterable.length;
5303 for (index = 0; index < length; index++) {
5304 adder.call(set, iterable[index]);
5313 // 23.2.2.1. Set.prototype
5314 // The initial value of Set.prototype is the intrinsic %SetPrototype% object.
5315 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
5316 Object.defineProperty(Set, 'prototype', {
5317 configurable: false,
5323 // 23.2.2.2 get Set [ @@species ]
5324 if (supportsGetters) {
5325 Object.defineProperty(Set, Symbol.species, {
5329 // 1. Return the this value.
5335 CreateMethodProperty(Set, Symbol.species, Set);
5338 // 23.2.3.1. Set.prototype.add ( value )
5339 CreateMethodProperty(Set.prototype, 'add', function add(value) {
5340 // 1. Let S be the this value.
5342 // 2. If Type(S) is not Object, throw a TypeError exception.
5343 if (typeof S !== 'object') {
5344 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
5346 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
5347 if (S._es6Set !== true) {
5348 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
5350 // 4. Let entries be the List that is S.[[SetData]].
5351 var entries = S._values;
5352 // 5. For each e that is an element of entries, do
5353 for (var i = 0; i < entries.length; i++) {
5355 // a. If e is not empty and SameValueZero(e, value) is true, then
5356 if (e !== undefMarker && SameValueZero(e, value)) {
5361 // 6. If value is -0, let value be +0.
5362 if (1/value === -Infinity) {
5365 // 7. Append value as the last element of entries.
5366 S._values.push(value);
5368 this._size = ++this._size;
5369 if (!supportsGetters) {
5370 this.size = this._size;
5376 // 23.2.3.2. Set.prototype.clear ( )
5377 CreateMethodProperty(Set.prototype, 'clear', function clear() {
5378 // 1. Let S be the this value.
5380 // 2. If Type(S) is not Object, throw a TypeError exception.
5381 if (typeof S !== 'object') {
5382 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
5384 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
5385 if (S._es6Set !== true) {
5386 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
5388 // 4. Let entries be the List that is S.[[SetData]].
5389 var entries = S._values;
5390 // 5. For each e that is an element of entries, do
5391 for (var i = 0; i < entries.length; i++) {
5392 // a. Replace the element of entries whose value is e with an element whose value is empty.
5393 entries[i] = undefMarker;
5396 if (!supportsGetters) {
5397 this.size = this._size;
5399 // 6. Return undefined.
5403 // 23.2.3.3. Set.prototype.constructor
5404 CreateMethodProperty(Set.prototype, 'constructor', Set);
5406 // 23.2.3.4. Set.prototype.delete ( value )
5407 CreateMethodProperty(Set.prototype, 'delete', function (value) {
5408 // 1. Let S be the this value.
5410 // 2. If Type(S) is not Object, throw a TypeError exception.
5411 if (typeof S !== 'object') {
5412 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
5414 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
5415 if (S._es6Set !== true) {
5416 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
5418 // 4. Let entries be the List that is S.[[SetData]].
5419 var entries = S._values;
5420 // 5. For each e that is an element of entries, do
5421 for (var i = 0; i < entries.length; i++) {
5423 // a. If e is not empty and SameValueZero(e, value) is true, then
5424 if (e !== undefMarker && SameValueZero(e, value)) {
5425 // i. Replace the element of entries whose value is e with an element whose value is empty.
5426 entries[i] = undefMarker;
5428 this._size = --this._size;
5429 if (!supportsGetters) {
5430 this.size = this._size;
5441 // 23.2.3.5. Set.prototype.entries ( )
5442 CreateMethodProperty(Set.prototype, 'entries', function entries() {
5443 // 1. Let S be the this value.
5445 // 2. Return ? CreateSetIterator(S, "key+value").
5446 return CreateSetIterator(S, 'key+value');
5450 // 23.2.3.6. Set.prototype.forEach ( callbackfn [ , thisArg ] )
5451 CreateMethodProperty(Set.prototype, 'forEach', function forEach(callbackFn /*[ , thisArg ]*/) {
5452 // 1. Let S be the this value.
5454 // 2. If Type(S) is not Object, throw a TypeError exception.
5455 if (typeof S !== 'object') {
5456 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
5458 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
5459 if (S._es6Set !== true) {
5460 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
5462 // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
5463 if (!IsCallable(callbackFn)) {
5464 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
5466 // 5. If thisArg is present, let T be thisArg; else let T be undefined.
5468 var T = arguments[1];
5470 // 6. Let entries be the List that is S.[[SetData]].
5471 var entries = S._values;
5472 // 7. For each e that is an element of entries, in original insertion order, do
5473 for (var i = 0; i < entries.length; i++) {
5475 // a. If e is not empty, then
5476 if (e !== undefMarker) {
5477 // i. Perform ? Call(callbackfn, T, « e, e, S »).
5478 callbackFn.call(T, e, e, S);
5481 // 8. Return undefined.
5486 // 23.2.3.7. Set.prototype.has ( value )
5487 CreateMethodProperty(Set.prototype, 'has', function has(value) {
5488 // 1. Let S be the this value.
5490 // 2. If Type(S) is not Object, throw a TypeError exception.
5491 if (typeof S !== 'object') {
5492 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
5494 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
5495 if (S._es6Set !== true) {
5496 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
5498 // 4. Let entries be the List that is S.[[SetData]].
5499 var entries = S._values;
5500 // 5. For each e that is an element of entries, do
5501 for (var i = 0; i < entries.length; i++) {
5503 // a. If e is not empty and SameValueZero(e, value) is true, return true.
5504 if (e !== undefMarker && SameValueZero(e, value)) {
5513 // Polyfill.io - We need to define Set.prototype.values before Set.prototype.keys because keys is a reference to values.
5514 // 23.2.3.10. Set.prototype.values()
5515 var values = function values() {
5516 // 1. Let S be the this value.
5518 // 2. Return ? CreateSetIterator(S, "value").
5519 return CreateSetIterator(S, "value");
5521 CreateMethodProperty(Set.prototype, 'values', values);
5523 // 23.2.3.8 Set.prototype.keys ( )
5524 // The initial value of the keys property is the same function object as the initial value of the values property.
5525 CreateMethodProperty(Set.prototype, 'keys', values);
5527 // 23.2.3.9. get Set.prototype.size
5528 if (supportsGetters) {
5529 Object.defineProperty(Set.prototype, 'size', {
5533 // 1. Let S be the this value.
5535 // 2. If Type(S) is not Object, throw a TypeError exception.
5536 if (typeof S !== 'object') {
5537 throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
5539 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
5540 if (S._es6Set !== true) {
5541 throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
5543 // 4. Let entries be the List that is S.[[SetData]].
5544 var entries = S._values;
5545 // 5. Let count be 0.
5547 // 6. For each e that is an element of entries, do
5548 for (var i = 0; i < entries.length; i++) {
5550 // a. If e is not empty, set count to count+1.
5551 if (e !== undefMarker) {
5562 // 23.2.3.11. Set.prototype [ @@iterator ] ( )
5563 // The initial value of the @@iterator property is the same function object as the initial value of the values property.
5564 CreateMethodProperty(Set.prototype, Symbol.iterator, values);
5566 // 23.2.3.12. Set.prototype [ @@toStringTag ]
5567 // The initial value of the @@toStringTag property is the String value "Set".
5568 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
5570 // 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.
5571 if (!('name' in Set)) {
5573 Object.defineProperty(Set, 'name', {
5581 // 23.2.5.1. CreateSetIterator ( set, kind )
5582 function CreateSetIterator(set, kind) {
5583 // 1. If Type(set) is not Object, throw a TypeError exception.
5584 if (typeof set !== 'object') {
5585 throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
5587 // 2. If set does not have a [[SetData]] internal slot, throw a TypeError exception.
5588 if (set._es6Set !== true) {
5589 throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
5591 // 3. Let iterator be ObjectCreate(%SetIteratorPrototype%, « [[IteratedSet]], [[SetNextIndex]], [[SetIterationKind]] »).
5592 var iterator = Object.create(SetIteratorPrototype);
5593 // 4. Set iterator.[[IteratedSet]] to set.
5594 Object.defineProperty(iterator, '[[IteratedSet]]', {
5600 // 5. Set iterator.[[SetNextIndex]] to 0.
5601 Object.defineProperty(iterator, '[[SetNextIndex]]', {
5607 // 6. Set iterator.[[SetIterationKind]] to kind.
5608 Object.defineProperty(iterator, '[[SetIterationKind]]', {
5614 // 7. Return iterator.
5618 // 23.2.5.2. The %SetIteratorPrototype% Object
5619 var SetIteratorPrototype = {};
5620 //Polyfill.io - We add this property to help us identify what is a set iterator.
5621 Object.defineProperty(SetIteratorPrototype, 'isSetIterator', {
5622 configurable: false,
5628 // 23.2.5.2.1. %SetIteratorPrototype%.next ( )
5629 CreateMethodProperty(SetIteratorPrototype, 'next', function next() {
5630 // 1. Let O be the this value.
5632 // 2. If Type(O) is not Object, throw a TypeError exception.
5633 if (typeof O !== 'object') {
5634 throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
5636 // 3. If O does not have all of the internal slots of a Set Iterator Instance (23.2.5.3), throw a TypeError exception.
5637 if (!O.isSetIterator) {
5638 throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
5640 // 4. Let s be O.[[IteratedSet]].
5641 var s = O['[[IteratedSet]]'];
5642 // 5. Let index be O.[[SetNextIndex]].
5643 var index = O['[[SetNextIndex]]'];
5644 // 6. Let itemKind be O.[[SetIterationKind]].
5645 var itemKind = O['[[SetIterationKind]]'];
5646 // 7. If s is undefined, return CreateIterResultObject(undefined, true).
5647 if (s === undefined) {
5648 return CreateIterResultObject(undefined, true);
5650 // 8. Assert: s has a [[SetData]] internal slot.
5652 throw new Error(Object.prototype.toString.call(s) + ' does not have [[SetData]] internal slot.');
5654 // 9. Let entries be the List that is s.[[SetData]].
5655 var entries = s._values;
5656 // 10. Let numEntries be the number of elements of entries.
5657 var numEntries = entries.length;
5658 // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
5659 // 12. Repeat, while index is less than numEntries,
5660 while (index < numEntries) {
5661 // a. Let e be entries[index].
5662 var e = entries[index];
5663 // b. Set index to index+1.
5665 // c. Set O.[[SetNextIndex]] to index.
5666 O['[[SetNextIndex]]'] = index;
5667 // d. If e is not empty, then
5668 if (e !== undefMarker) {
5669 // i. If itemKind is "key+value", then
5670 if (itemKind === 'key+value') {
5671 // 1. Return CreateIterResultObject(CreateArrayFromList(« e, e »), false).
5672 return CreateIterResultObject([e, e], false);
5674 // ii. Return CreateIterResultObject(e, false).
5675 return CreateIterResultObject(e, false);
5678 // 13. Set O.[[IteratedSet]] to undefined.
5679 O['[[IteratedSet]]'] = undefined;
5680 // 14. Return CreateIterResultObject(undefined, true).
5681 return CreateIterResultObject(undefined, true);
5684 // 23.2.5.2.2. %SetIteratorPrototype% [ @@toStringTag ]
5685 // The initial value of the @@toStringTag property is the String value "Set Iterator".
5686 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
5688 CreateMethodProperty(SetIteratorPrototype, Symbol.iterator, function iterator() {
5693 // Export the object
5695 CreateMethodProperty(global, 'Set', Set);
5697 // IE8 throws an error here if we set enumerable to false.
5698 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
5699 global['Set'] = Set;
5706 if (!("from"in Array&&function(){try{return Array.from({length:-Infinity}),!0}catch(r){return!1}}()
5711 IsCallable, GetMethod, Symbol, IsConstructor, Construct, ArrayCreate, GetIterator, IteratorClose,
5712 ToString, IteratorStep, IteratorValue, Call, CreateDataPropertyOrThrow, ToObject, ToLength, Get, CreateMethodProperty
5715 var toString = Object.prototype.toString;
5716 var stringMatch = String.prototype.match;
5717 // A cross-realm friendly way to detect if a value is a String object or literal.
5718 function isString(value) {
5719 if (typeof value === 'string') { return true; }
5720 if (typeof value !== 'object') { return false; }
5721 return toString.call(value) === '[object String]';
5724 // 22.1.2.1. Array.from ( items [ , mapfn [ , thisArg ] ] )
5725 CreateMethodProperty(Array, 'from', function from(items /* [ , mapfn [ , thisArg ] ] */) { // eslint-disable-line no-undef
5726 // 1. Let C be the this value.
5728 // 2. If mapfn is undefined, let mapping be false.
5729 var mapfn = arguments.length > 1 ? arguments[1] : undefined;
5730 if (mapfn === undefined) {
5731 var mapping = false;
5734 // a. If IsCallable(mapfn) is false, throw a TypeError exception.
5735 if (IsCallable(mapfn) === false) {
5736 throw new TypeError(Object.prototype.toString.call(mapfn) + ' is not a function.');
5738 // b. If thisArg is present, let T be thisArg; else let T be undefined.
5739 var thisArg = arguments.length > 2 ? arguments[2] : undefined;
5740 if (thisArg !== undefined) {
5745 // c. Let mapping be true.
5749 // 4. Let usingIterator be ? GetMethod(items, @@iterator).
5750 var usingIterator = GetMethod(items, Symbol.iterator);
5751 // 5. If usingIterator is not undefined, then
5752 if (usingIterator !== undefined) {
5753 // a. If IsConstructor(C) is true, then
5754 if (IsConstructor(C)) {
5755 // i. Let A be ? Construct(C).
5756 var A = Construct(C);
5759 // i. Let A be ! ArrayCreate(0).
5762 // c. Let iteratorRecord be ? GetIterator(items, usingIterator).
5763 var iteratorRecord = GetIterator(items, usingIterator);
5768 // i. If k ≥ 2^53-1, then
5769 if (k >= (Math.pow(2, 53) - 1)) {
5770 // 1. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
5771 var error = new TypeError('Iteration count can not be greater than or equal 9007199254740991.');
5772 // 2. Return ? IteratorClose(iteratorRecord, error).
5773 return IteratorClose(iteratorRecord, error);
5775 // ii. Let Pk be ! ToString(k).
5776 var Pk = ToString(k);
5777 // iii. Let next be ? IteratorStep(iteratorRecord).
5778 var next = IteratorStep(iteratorRecord);
5779 // iv. If next is false, then
5780 if (next === false) {
5781 // 1. Perform ? Set(A, "length", k, true).
5786 // v. Let nextValue be ? IteratorValue(next).
5787 var nextValue = IteratorValue(next);
5788 // vi. If mapping is true, then
5791 // Polyfill.io - The try catch accounts for step 2.
5792 // 1. Let mappedValue be Call(mapfn, T, « nextValue, k »).
5793 var mappedValue = Call(mapfn, T, [nextValue, k]);
5794 // 2. If mappedValue is an abrupt completion, return ? IteratorClose(iteratorRecord, mappedValue).
5795 // 3. Let mappedValue be mappedValue.[[Value]].
5797 return IteratorClose(iteratorRecord, e);
5800 // vii. Else, let mappedValue be nextValue.
5802 mappedValue = nextValue;
5805 // Polyfill.io - The try catch accounts for step ix.
5806 // viii. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, mappedValue).
5807 CreateDataPropertyOrThrow(A, Pk, mappedValue);
5808 // ix. If defineStatus is an abrupt completion, return ? IteratorClose(iteratorRecord, defineStatus).
5810 return IteratorClose(iteratorRecord, e);
5812 // x. Increase k by 1.
5816 // 6. NOTE: items is not an Iterable so assume it is an array-like object.
5817 // 7. Let arrayLike be ! ToObject(items).
5818 // Polyfill.io - For Strings we need to split astral symbols into surrogate pairs.
5819 if (isString(items)) {
5820 var arrayLike = stringMatch.call(items, /[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g) || [];
5822 arrayLike = ToObject(items);
5824 // 8. Let len be ? ToLength(? Get(arrayLike, "length")).
5825 var len = ToLength(Get(arrayLike, "length"));
5826 // 9. If IsConstructor(C) is true, then
5827 if (IsConstructor(C)) {
5828 // a. Let A be ? Construct(C, « len »).
5829 A = Construct(C, [len]);
5832 // a. Let A be ? ArrayCreate(len).
5833 A = ArrayCreate(len);
5837 // 12. Repeat, while k < len
5839 // a. Let Pk be ! ToString(k).
5841 // b. Let kValue be ? Get(arrayLike, Pk).
5842 var kValue = Get(arrayLike, Pk);
5843 // c. If mapping is true, then
5844 if (mapping === true) {
5845 // i. Let mappedValue be ? Call(mapfn, T, « kValue, k »).
5846 mappedValue = Call(mapfn, T, [kValue, k]);
5847 // d. Else, let mappedValue be kValue.
5849 mappedValue = kValue;
5851 // e. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
5852 CreateDataPropertyOrThrow(A, Pk, mappedValue);
5853 // f. Increase k by 1.
5856 // 13. Perform ? Set(A, "length", len, true).
5865 if (!("Symbol"in this&&"split"in this.Symbol
5870 Object.defineProperty(Symbol, 'split', { value: Symbol('split') });
5874 if (!("Symbol"in this&&"toPrimitive"in this.Symbol
5877 // Symbol.toPrimitive
5879 Object.defineProperty(Symbol, 'toPrimitive', { value: Symbol('toPrimitive') });
5883 if (!("Symbol"in this&&"toStringTag"in this.Symbol
5886 // Symbol.toStringTag
5888 Object.defineProperty(Symbol, 'toStringTag', {
5889 value: Symbol('toStringTag')
5897 // A modification of https://github.com/medikoo/es6-iterator
5898 // Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
5900 var Iterator = (function () { // eslint-disable-line no-unused-vars
5901 var clear = function () {
5905 var callable = function (fn) {
5906 if (typeof fn !== 'function') throw new TypeError(fn + " is not a function");
5910 var Iterator = function (list, context) {
5911 if (!(this instanceof Iterator)) {
5912 return new Iterator(list, context);
5914 Object.defineProperties(this, {
5928 if (!context) return;
5929 callable(context.on);
5930 context.on('_add', this._onAdd.bind(this));
5931 context.on('_delete', this._onDelete.bind(this));
5932 context.on('_clear', this._onClear.bind(this));
5935 Object.defineProperties(Iterator.prototype, Object.assign({
5943 value: function () {
5945 if (!this.__list__) return;
5946 if (this.__redo__) {
5947 i = this.__redo__.shift();
5948 if (i !== undefined) return i;
5950 if (this.__nextIndex__ < this.__list__.length) return this.__nextIndex__++;
5958 value: function () {
5959 return this._createResult(this._next());
5966 value: function (i) {
5967 if (i === undefined) return {
5973 value: this._resolve(i)
5981 value: function (i) {
5982 return this.__list__[i];
5989 value: function () {
5990 this.__list__ = null;
5991 delete this.__redo__;
5992 if (!this.__context__) return;
5993 this.__context__.off('_add', this._onAdd.bind(this));
5994 this.__context__.off('_delete', this._onDelete.bind(this));
5995 this.__context__.off('_clear', this._onClear.bind(this));
5996 this.__context__ = null;
6003 value: function () {
6004 return '[object Iterator]';
6012 value: function (index) {
6013 if (index >= this.__nextIndex__) return;
6014 ++this.__nextIndex__;
6015 if (!this.__redo__) {
6016 Object.defineProperty(this, '__redo__', {
6024 this.__redo__.forEach(function (redo, i) {
6025 if (redo >= index) this.__redo__[i] = ++redo;
6027 this.__redo__.push(index);
6034 value: function (index) {
6036 if (index >= this.__nextIndex__) return;
6037 --this.__nextIndex__;
6038 if (!this.__redo__) return;
6039 i = this.__redo__.indexOf(index);
6040 if (i !== -1) this.__redo__.splice(i, 1);
6041 this.__redo__.forEach(function (redo, i) {
6042 if (redo > index) this.__redo__[i] = --redo;
6050 value: function () {
6051 if (this.__redo__) clear.call(this.__redo__);
6052 this.__nextIndex__ = 0;
6060 Object.defineProperty(Iterator.prototype, Symbol.iterator, {
6061 value: function () {
6068 Object.defineProperty(Iterator.prototype, Symbol.toStringTag, {
6070 configurable: false,
6079 /* global Iterator */
6080 // A modification of https://github.com/medikoo/es6-iterator
6081 // Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
6083 var ArrayIterator = (function() { // eslint-disable-line no-unused-vars
6085 var ArrayIterator = function(arr, kind) {
6086 if (!(this instanceof ArrayIterator)) return new ArrayIterator(arr, kind);
6087 Iterator.call(this, arr);
6088 if (!kind) kind = 'value';
6089 else if (String.prototype.includes.call(kind, 'key+value')) kind = 'key+value';
6090 else if (String.prototype.includes.call(kind, 'key')) kind = 'key';
6091 else kind = 'value';
6092 Object.defineProperty(this, '__kind__', {
6094 configurable: false,
6099 if (Object.setPrototypeOf) Object.setPrototypeOf(ArrayIterator, Iterator.prototype);
6101 ArrayIterator.prototype = Object.create(Iterator.prototype, {
6103 value: ArrayIterator,
6109 value: function(i) {
6110 if (this.__kind__ === 'value') return this.__list__[i];
6111 if (this.__kind__ === 'key+value') return [i, this.__list__[i]];
6120 return '[object Array Iterator]';
6128 return ArrayIterator;
6130 if (!("Symbol"in this&&"iterator"in this.Symbol&&!!Array.prototype.entries
6133 // Array.prototype.entries
6134 /* global CreateMethodProperty, ToObject */
6135 // 22.1.3.4. Array.prototype.entries ( )
6136 CreateMethodProperty(Array.prototype, 'entries', function entries() {
6137 // 1. Let O be ? ToObject(this value).
6138 var O = ToObject(this);
6139 // 2. Return CreateArrayIterator(O, "key+value").
6140 // TODO: Add CreateArrayIterator
6141 return new ArrayIterator(O, 'key+value');
6146 if (!("Symbol"in this&&"iterator"in this.Symbol&&!!Array.prototype.keys
6149 // Array.prototype.keys
6150 /* global CreateMethodProperty, ToObject */
6151 // 22.1.3.14. Array.prototype.keys ( )
6152 CreateMethodProperty(Array.prototype, 'keys', function keys() {
6153 // 1. Let O be ? ToObject(this value).
6154 var O = ToObject(this);
6155 // 2. Return CreateArrayIterator(O, "key").
6156 // TODO: Add CreateArrayIterator.
6157 return new ArrayIterator(O, 'key');
6162 if (!("values"in Array.prototype
6165 // Array.prototype.values
6166 /* global CreateMethodProperty, Symbol, ToObject */
6167 // 22.1.3.30/ Array.prototype.values ( )
6168 // Polyfill.io - Firefox, Chrome and Opera have Array.prototype[Symbol.iterator], which is the exact same function as Array.prototype.values.
6169 if ('Symbol' in this && 'iterator' in Symbol && typeof Array.prototype[Symbol.iterator] === 'function') {
6170 CreateMethodProperty(Array.prototype, 'values', Array.prototype[Symbol.iterator]);
6172 CreateMethodProperty(Array.prototype, 'values', function values () {
6173 // 1. Let O be ? ToObject(this value).
6174 var O = ToObject(this);
6175 // 2. Return CreateArrayIterator(O, "value").
6176 // TODO: Add CreateArrayIterator
6177 return new ArrayIterator(O, 'value');
6183 if (!("Symbol"in this&&"iterator"in this.Symbol&&!!Array.prototype[Symbol.iterator]
6186 // Array.prototype.@@iterator
6187 /* global Symbol, CreateMethodProperty */
6188 // 22.1.3.31. Array.prototype [ @@iterator ] ( )
6189 // The initial value of the @@iterator property is the same function object as the initial value of the Array.prototype.values property.
6190 CreateMethodProperty(Array.prototype, Symbol.iterator, Array.prototype.values);
6196 // A modification of https://github.com/medikoo/es6-iterator
6197 // Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
6199 /* global Iterator */
6201 var StringIterator = (function() { // eslint-disable-line no-unused-vars
6203 var StringIterator = function (str) {
6204 if (!(this instanceof StringIterator)) return new StringIterator(str);
6206 Iterator.call(this, str);
6207 Object.defineProperty(this, '__length__', {
6209 configurable: false,
6214 if (Object.setPrototypeOf) Object.setPrototypeOf(StringIterator, Iterator);
6216 StringIterator.prototype = Object.create(Iterator.prototype, {
6218 value: StringIterator,
6225 if (!this.__list__) return;
6226 if (this.__nextIndex__ < this.__length__) return this.__nextIndex__++;
6234 value: function (i) {
6235 var char = this.__list__[i], code;
6236 if (this.__nextIndex__ === this.__length__) return char;
6237 code = char.charCodeAt(0);
6238 if ((code >= 0xD800) && (code <= 0xDBFF)) return char + this.__list__[this.__nextIndex__++];
6247 return '[object String Iterator]';
6255 return StringIterator;
6257 if (!("Symbol"in this&&"iterator"in this.Symbol&&!!String.prototype[Symbol.iterator]
6260 // String.prototype.@@iterator
6261 /* global CreateMethodProperty, RequireObjectCoercible, ToString, StringIterator, Symbol */
6262 // 21.1.3.29. String.prototype [ @@iterator ] ( )
6263 CreateMethodProperty(String.prototype, Symbol.iterator, function () {
6264 // 1. Let O be ? RequireObjectCoercible(this value).
6265 var O = RequireObjectCoercible(this);
6266 // 2. Let S be ? ToString(O).
6267 var S = ToString(O);
6268 // 3. Return CreateStringIterator(S).
6269 // TODO: Add CreateStringIterator.
6270 return new StringIterator(S);
6275 if (!("Symbol"in this&&"unscopables"in this.Symbol
6278 // Symbol.unscopables
6280 Object.defineProperty(Symbol, 'unscopables', { value: Symbol('unscopables') });
6284 if (!((function(e){try{if("WeakMap"in e&&0===WeakMap.length){var t={},a=new WeakMap([[t,"test"]])
6285 return"test"===a.get(t)&&!1===a["delete"](0)}return!1}catch(n){return!1}})(this)
6289 /* globals Symbol, OrdinaryCreateFromConstructor, IsCallable, GetIterator, IteratorStep, IteratorValue, IteratorClose, Get, Call, CreateMethodProperty, Type, SameValue */
6290 (function (global) {
6291 // 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.
6292 var undefMarker = Symbol('undef');
6293 // 23.3.1.1 WeakMap ( [ iterable ] )
6294 var WeakMap = function WeakMap(/* iterable */) {
6295 // 1. If NewTarget is undefined, throw a TypeError exception.
6296 if (!(this instanceof WeakMap)) {
6297 throw new TypeError('Constructor WeakMap requires "new"');
6299 // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakMapPrototype%", « [[WeakMapData]] »).
6300 var map = OrdinaryCreateFromConstructor(this, WeakMap.prototype, {
6306 // 3. Set map.[[WeakMapData]] to a new empty List.
6307 // Polyfill.io - This step was done as part of step two.
6309 // 4. If iterable is not present, let iterable be undefined.
6310 var iterable = arguments.length > 0 ? arguments[0] : undefined;
6312 // 5. If iterable is either undefined or null, return map.
6313 if (iterable === null || iterable === undefined) {
6317 // 6. Let adder be ? Get(map, "set").
6318 var adder = Get(map, "set");
6320 // 7. If IsCallable(adder) is false, throw a TypeError exception.
6321 if (!IsCallable(adder)) {
6322 throw new TypeError("WeakMap.prototype.set is not a function");
6325 // 8. Let iteratorRecord be ? GetIterator(iterable).
6327 var iteratorRecord = GetIterator(iterable);
6330 // a. Let next be ? IteratorStep(iteratorRecord).
6331 var next = IteratorStep(iteratorRecord);
6332 // b. If next is false, return map.
6333 if (next === false) {
6336 // c. Let nextItem be ? IteratorValue(next).
6337 var nextItem = IteratorValue(next);
6338 // d. If Type(nextItem) is not Object, then
6339 if (Type(nextItem) !== 'object') {
6340 // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
6342 throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
6344 // ii. Return ? IteratorClose(iteratorRecord, error).
6345 return IteratorClose(iteratorRecord, error);
6349 // Polyfill.io - The try catch accounts for steps: f, h, and j.
6351 // e. Let k be Get(nextItem, "0").
6352 var k = Get(nextItem, "0");
6353 // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
6354 // g. Let v be Get(nextItem, "1").
6355 var v = Get(nextItem, "1");
6356 // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
6357 // i. Let status be Call(adder, map, « k.[[Value]], v.[[Value]] »).
6358 Call(adder, map, [k, v]);
6360 // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
6361 return IteratorClose(iteratorRecord, e);
6365 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
6366 if (Array.isArray(iterable) ||
6367 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
6368 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
6369 (!!iterable.callee)) {
6371 var length = iterable.length;
6372 for (index = 0; index < length; index++) {
6373 var k = iterable[index][0];
6374 var v = iterable[index][1];
6375 Call(adder, map, [k, v]);
6382 // 23.3.2.1 WeakMap.prototype
6383 // The initial value of WeakMap.prototype is the intrinsic object %WeakMapPrototype%.
6384 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
6385 Object.defineProperty(WeakMap, 'prototype', {
6386 configurable: false,
6392 // 23.3.3.1 WeakMap.prototype.constructor
6393 CreateMethodProperty(WeakMap.prototype, 'constructor', WeakMap);
6395 // 23.3.3.2 WeakMap.prototype.delete ( key )
6396 CreateMethodProperty(WeakMap.prototype, 'delete', function (key) {
6397 // 1. Let M be the this value.
6399 // 2. If Type(M) is not Object, throw a TypeError exception.
6400 if (Type(M) !== 'object') {
6401 throw new TypeError('Method WeakMap.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
6403 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
6404 if (M._es6WeakMap !== true) {
6405 throw new TypeError('Method WeakMap.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
6407 // 4. Let entries be the List that is M.[[WeakMapData]].
6408 var entries = M._keys;
6409 // 5. If Type(key) is not Object, return false.
6410 if (Type(key) !== 'object') {
6413 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
6414 for (var i = 0; i < entries.length; i++) {
6415 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, then
6416 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
6417 // i. Set p.[[Key]] to empty.
6418 this._keys[i] = undefMarker;
6419 // ii. Set p.[[Value]] to empty.
6420 this._values[i] = undefMarker;
6421 this._size = --this._size;
6422 // iii. Return true.
6430 // 23.3.3.3 WeakMap.prototype.get ( key )
6431 CreateMethodProperty(WeakMap.prototype, 'get', function get(key) {
6432 // 1. Let M be the this value.
6434 // 2. If Type(M) is not Object, throw a TypeError exception.
6435 if (Type(M) !== 'object') {
6436 throw new TypeError('Method WeakMap.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
6438 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
6439 if (M._es6WeakMap !== true) {
6440 throw new TypeError('Method WeakMap.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
6442 // 4. Let entries be the List that is M.[[WeakMapData]].
6443 var entries = M._keys;
6444 // 5. If Type(key) is not Object, return undefined.
6445 if (Type(key) !== 'object') {
6448 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
6449 for (var i = 0; i < entries.length; i++) {
6450 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
6451 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
6452 return M._values[i];
6455 // 7. Return undefined.
6459 // 23.3.3.4 WeakMap.prototype.has ( key )
6460 CreateMethodProperty(WeakMap.prototype, 'has', function has(key) {
6461 // 1. Let M be the this value.
6463 // 2. If Type(M) is not Object, throw a TypeError exception.
6464 if (typeof M !== 'object') {
6465 throw new TypeError('Method WeakMap.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
6467 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
6468 if (M._es6WeakMap !== true) {
6469 throw new TypeError('Method WeakMap.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
6471 // 4. Let entries be the List that is M.[[WeakMapData]].
6472 var entries = M._keys;
6473 // 5. If Type(key) is not Object, return false.
6474 if (Type(key) !== 'object') {
6477 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
6478 for (var i = 0; i < entries.length; i++) {
6479 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return true.
6480 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
6488 // 23.3.3.5 WeakMap.prototype.set ( key, value )
6489 CreateMethodProperty(WeakMap.prototype, 'set', function set(key, value) {
6490 // 1. Let M be the this value.
6492 // 2. If Type(M) is not Object, throw a TypeError exception.
6493 if (Type(M) !== 'object') {
6494 throw new TypeError('Method WeakMap.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
6496 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
6497 if (M._es6WeakMap !== true) {
6498 throw new TypeError('Method WeakMap.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
6500 // 4. Let entries be the List that is M.[[WeakMapData]].
6501 var entries = M._keys;
6502 // 5. If Type(key) is not Object, throw a TypeError exception.
6503 if (Type(key) !== 'object') {
6504 throw new TypeError("Invalid value used as weak map key");
6506 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
6507 for (var i = 0; i < entries.length; i++) {
6508 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, then
6509 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
6510 // i. Set p.[[Value]] to value.
6511 M._values[i] = value;
6516 // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
6521 // 8. Append p as the last element of entries.
6522 M._keys.push(p['[[Key]]']);
6523 M._values.push(p['[[Value]]']);
6528 // 23.3.3.6 WeakMap.prototype [ @@toStringTag ]
6529 // The initial value of the @@toStringTag property is the String value "WeakMap".
6530 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
6532 // 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.
6533 if (!('name' in WeakMap)) {
6535 Object.defineProperty(WeakMap, 'name', {
6543 // Export the object
6545 CreateMethodProperty(global, 'WeakMap', WeakMap);
6547 // IE8 throws an error here if we set enumerable to false.
6548 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
6549 global['WeakMap'] = WeakMap;
6555 if (!((function(e){try{if("WeakSet"in e&&0===WeakSet.length){var t={},n=new WeakSet([t])
6556 return n.has(t)&&!1===n["delete"](0)}return!1}catch(r){return!1}})(this)
6560 /* global Call, CreateMethodProperty, Get, GetIterator, IsArray, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
6561 (function (global) {
6562 // 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.
6563 var undefMarker = Symbol('undef');
6564 // 23.4.1.1. WeakSet ( [ iterable ] )
6565 var WeakSet = function WeakSet() {
6566 // 1. If NewTarget is undefined, throw a TypeError exception.
6567 if (!(this instanceof WeakSet)) {
6568 throw new TypeError('Constructor WeakSet requires "new"');
6570 // 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakSetPrototype%", « [[WeakSetData]] »).
6571 var set = OrdinaryCreateFromConstructor(this, WeakSet.prototype, {
6577 // 3. Set set.[[WeakSetData]] to a new empty List.
6578 // Polyfill.io - This step was done as part of step two.
6580 // 4. If iterable is not present, let iterable be undefined.
6581 var iterable = arguments.length > 0 ? arguments[0] : undefined;
6582 // 5. If iterable is either undefined or null, return set.
6583 if (iterable === null || iterable === undefined) {
6586 // 6. Let adder be ? Get(set, "add").
6587 var adder = Get(set, 'add');
6588 // 7. If IsCallable(adder) is false, throw a TypeError exception.
6589 if (!IsCallable(adder)) {
6590 throw new TypeError("WeakSet.prototype.add is not a function");
6593 // 8. Let iteratorRecord be ? GetIterator(iterable).
6594 var iteratorRecord = GetIterator(iterable);
6597 // a. Let next be ? IteratorStep(iteratorRecord).
6598 var next = IteratorStep(iteratorRecord);
6599 // b. If next is false, return set.
6600 if (next === false) {
6603 // c. Let nextValue be ? IteratorValue(next).
6604 var nextValue = IteratorValue(next);
6605 // d. Let status be Call(adder, set, « nextValue »).
6607 Call(adder, set, [nextValue]);
6609 // e. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
6610 return IteratorClose(iteratorRecord, e);
6614 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
6615 if (IsArray(iterable) ||
6616 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
6617 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
6618 (!!iterable.callee)) {
6620 var length = iterable.length;
6621 for (index = 0; index < length; index++) {
6622 Call(adder, set, [iterable[index]]);
6629 // 23.4.2.1. WeakSet.prototype
6630 // The initial value of WeakSet.prototype is the intrinsic %WeakSetPrototype% object.
6631 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
6632 Object.defineProperty(WeakSet, 'prototype', {
6633 configurable: false,
6639 // 23.4.3.1. WeakSet.prototype.add ( value )
6640 CreateMethodProperty(WeakSet.prototype, 'add', function add(value) {
6641 // 1. Let S be the this value.
6643 // 2. If Type(S) is not Object, throw a TypeError exception.
6644 if (Type(S) !== 'object') {
6645 throw new TypeError('Method WeakSet.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
6647 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
6648 if (S._es6WeakSet !== true) {
6649 throw new TypeError('Method WeakSet.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
6651 // 4. If Type(value) is not Object, throw a TypeError exception.
6652 if (Type(value) !== 'object') {
6653 throw new TypeError('Invalid value used in weak set');
6655 // 5. Let entries be the List that is S.[[WeakSetData]].
6656 var entries = S._values;
6657 // 6. For each e that is an element of entries, do
6658 for (var i = 0; i < entries.length; i++) {
6660 // a. If e is not empty and SameValue(e, value) is true, then
6661 if (e !== undefMarker && SameValueZero(e, value)) {
6666 // 7. Append value as the last element of entries.
6667 S._values.push(value);
6672 // 23.4.3.2. WeakSet.prototype.constructor
6673 CreateMethodProperty(WeakSet.prototype, 'constructor', WeakSet);
6675 // 23.4.3.3. WeakSet.prototype.delete ( value )
6676 CreateMethodProperty(WeakSet.prototype, 'delete', function (value) {
6677 // 1. Let S be the this value.
6679 // 2. If Type(S) is not Object, throw a TypeError exception.
6680 if (Type(S) !== 'object') {
6681 throw new TypeError('Method WeakSet.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
6683 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
6684 if (S._es6WeakSet !== true) {
6685 throw new TypeError('Method WeakSet.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
6687 // 4. If Type(value) is not Object, return false.
6688 if (Type(value) !== 'object') {
6691 // 5. Let entries be the List that is S.[[WeakSetData]].
6692 var entries = S._values;
6693 // 6. For each e that is an element of entries, do
6694 for (var i = 0; i < entries.length; i++) {
6696 // a. If e is not empty and SameValue(e, value) is true, then
6697 if (e !== undefMarker && SameValueZero(e, value)) {
6698 // i. Replace the element of entries whose value is e with an element whose value is empty.
6699 entries[i] = undefMarker;
6708 // 23.4.3.4. WeakSet.prototype.has ( value )
6709 CreateMethodProperty(WeakSet.prototype, 'has', function has(value) {
6710 // 1. Let S be the this value.
6712 // 2. If Type(S) is not Object, throw a TypeError exception.
6713 if (Type(S) !== 'object') {
6714 throw new TypeError('Method WeakSet.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(S));
6716 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
6717 if (S._es6WeakSet !== true) {
6718 throw new TypeError('Method WeakSet.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(S));
6720 // 4. Let entries be the List that is S.[[WeakSetData]].
6721 var entries = S._values;
6722 // 5. If Type(value) is not Object, return false.
6723 if (Type(value) !== 'object') {
6726 // 6. For each e that is an element of entries, do
6727 for (var i = 0; i < entries.length; i++) {
6729 // a. If e is not empty and SameValue(e, value) is true, return true.
6730 if (e !== undefMarker && SameValueZero(e, value)) {
6738 // 23.4.3.5. WeakSet.prototype [ @@toStringTag ]
6739 // The initial value of the @@toStringTag property is the String value "WeakSet".
6740 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
6742 // 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.
6743 if (!('name' in WeakSet)) {
6745 Object.defineProperty(WeakSet, 'name', {
6753 // Export the object
6755 CreateMethodProperty(global, 'WeakSet', WeakSet);
6757 // IE8 throws an error here if we set enumerable to false.
6758 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
6759 global['WeakSet'] = WeakSet;
6767 .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});