· 6 years ago · Aug 19, 2019, 02:22 PM
1/* Polyfill service v3.38.0
2 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
3 *
4 * Features requested: es2015,es2016
5 *
6 * - _ESAbstract.ArrayCreate, License: CC0 (required by "Array.from", "es2015", "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", "es2015", "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", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "String.prototype.padStart", "_ESAbstract.OrdinaryToPrimitive")
8 * - _ESAbstract.Get, License: CC0 (required by "Array.from", "es2015", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Object.assign", "RegExp.prototype.flags", "WeakMap", "WeakSet", "Array.prototype.includes", "es2016", "_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", "String.prototype.padEnd", "String.prototype.padStart")
9 * - _ESAbstract.HasProperty, License: CC0 (required by "Array.prototype.copyWithin", "es2015", "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 "WeakMap", "es2015", "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", "es2015", "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", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "String.prototype.padStart")
12 * - _ESAbstract.RequireObjectCoercible, License: CC0 (required by "String.prototype.@@iterator", "es2015", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "String.prototype.padEnd", "es2016", "String.prototype.padStart")
13 * - _ESAbstract.SameValueNonNumber, License: CC0 (required by "_ESAbstract.SameValueZero", "Map", "es2015", "Array.from", "Set", "WeakSet", "Array.prototype.includes", "es2016", "_ESAbstract.SameValue", "Object.is", "WeakMap")
14 * - _ESAbstract.ToBoolean, License: CC0 (required by "Array.prototype.find", "es2015", "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", "es2015", "Array.prototype.fill", "Number.isInteger", "Number.isSafeInteger", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "Array.prototype.includes", "es2016", "_ESAbstract.ToLength", "Array.from", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.padEnd", "String.prototype.padStart")
16 * - _ESAbstract.ToLength, License: CC0 (required by "Array.from", "es2015", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "String.prototype.padStart", "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.ToObject, License: CC0 (required by "Array.from", "es2015", "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.includes", "es2016", "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")
18 * - _ESAbstract.GetV, License: CC0 (required by "_ESAbstract.GetMethod", "Array.from", "es2015", "Map", "Set", "_ESAbstract.GetIterator", "WeakMap", "WeakSet")
19 * - _ESAbstract.GetMethod, License: CC0 (required by "Array.from", "es2015", "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", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "String.prototype.padStart")
20 * - _ESAbstract.ToUint32, License: CC0 (required by "Math.clz32", "es2015", "Math.imul")
21 * - _ESAbstract.Type, License: CC0 (required by "Map", "es2015", "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", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "String.prototype.padStart", "_ESAbstract.IteratorValue", "_ESAbstract.CreateIterResultObject", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "_ESAbstract.IteratorNext", "_ESAbstract.SameValueZero", "Object.create", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.SameValue", "Object.is", "_ESAbstract.IsRegExp", "_ESAbstract.ToPrimitive", "_ESAbstract.GetPrototypeFromConstructor", "Object.defineProperties", "_Iterator", "_StringIterator", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.OrdinaryToPrimitive")
22 * - _ESAbstract.GetPrototypeFromConstructor, License: CC0 (required by "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "es2015", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
23 * - _ESAbstract.IsConstructor, License: CC0 (required by "Array.from", "es2015", "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")
24 * - _ESAbstract.IsRegExp, License: CC0 (required by "String.prototype.endsWith", "es2015", "String.prototype.includes", "String.prototype.startsWith")
25 * - _ESAbstract.IteratorClose, License: CC0 (required by "Array.from", "es2015", "Map", "Set", "WeakMap", "WeakSet")
26 * - _ESAbstract.IteratorComplete, License: CC0 (required by "Map", "es2015", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet")
27 * - _ESAbstract.IteratorNext, License: CC0 (required by "Map", "es2015", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet")
28 * - _ESAbstract.IteratorStep, License: CC0 (required by "Array.from", "es2015", "Map", "Set", "WeakMap", "WeakSet")
29 * - _ESAbstract.IteratorValue, License: CC0 (required by "Array.from", "es2015", "Map", "Set", "WeakMap", "WeakSet")
30 * - _ESAbstract.OrdinaryToPrimitive, License: CC0 (required by "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.from", "es2015", "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.includes", "es2016", "String.prototype.padEnd", "String.prototype.padStart")
31 * - _ESAbstract.SameValue, License: CC0 (required by "Object.is", "es2015", "WeakMap")
32 * - _ESAbstract.SameValueZero, License: CC0 (required by "Map", "es2015", "Array.from", "Set", "WeakSet", "Array.prototype.includes", "es2016")
33 * - _ESAbstract.ToPrimitive, License: CC0 (required by "_ESAbstract.ToString", "Array.from", "es2015", "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.includes", "es2016", "String.prototype.padEnd", "String.prototype.padStart")
34 * - _ESAbstract.ToString, License: CC0 (required by "Array.from", "es2015", "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.includes", "es2016", "String.prototype.padEnd", "String.prototype.padStart", "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")
35 * - _ESAbstract.UTF16Decode, License: CC0 (required by "String.prototype.codePointAt", "es2015")
36 * - _TypedArray, License: MIT (required by "Math.fround", "es2015")
37 * - Object.defineProperty, License: CC0 (required by "Function.prototype.name", "es2015", "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.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "String.prototype.padStart", "_ArrayIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_StringIterator", "_ESAbstract.CreateDataProperty", "_ESAbstract.CreateDataPropertyOrThrow", "_ESAbstract.CreateIterResultObject", "_Iterator", "Object.defineProperties", "Object.create", "_ESAbstract.GetIterator")
38 * - _ESAbstract.CreateDataProperty, License: CC0 (required by "_ESAbstract.CreateDataPropertyOrThrow", "Array.from", "es2015", "Array.of", "_ESAbstract.CreateIterResultObject", "Map", "Set")
39 * - _ESAbstract.CreateDataPropertyOrThrow, License: CC0 (required by "Array.from", "es2015", "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")
40 * - _ESAbstract.CreateIterResultObject, License: CC0 (required by "Map", "es2015", "Array.from", "Set")
41 * - _ESAbstract.CreateMethodProperty, License: CC0 (required by "Array.from", "es2015", "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.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "WeakMap", "WeakSet", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "String.prototype.padStart", "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")
42 * - Array.isArray, License: CC0 (required by "Map", "es2015", "Array.from", "Set", "WeakMap")
43 * - Array.prototype.copyWithin, License: MIT (required by "es2015")
44 * - Array.prototype.fill, License: CC0 (required by "es2015")
45 * - Array.prototype.find, License: CC0 (required by "es2015")
46 * - Array.prototype.findIndex, License: CC0 (required by "es2015")
47 * - Array.prototype.forEach, License: CC0 (required by "Object.setPrototypeOf", "es2015", "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")
48 * - Array.prototype.includes, License: MIT (required by "es2016")
49 * - Function.prototype.bind, License: MIT (required by "_ESAbstract.Construct", "Array.from", "es2015", "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")
50 * - Math.acosh, License: CC0 (required by "es2015")
51 * - Math.asinh, License: CC0 (required by "es2015")
52 * - Math.atanh, License: CC0 (required by "es2015")
53 * - Math.cbrt, License: CC0 (required by "es2015")
54 * - Math.clz32, License: CC0 (required by "es2015")
55 * - Math.cosh, License: CC0 (required by "es2015")
56 * - Math.expm1, License: CC0 (required by "es2015")
57 * - Math.fround, License: CC0 (required by "es2015")
58 * - Math.hypot, License: CC0 (required by "es2015")
59 * - Math.imul, License: CC0 (required by "es2015")
60 * - Math.log10, License: CC0 (required by "es2015")
61 * - Math.log1p, License: CC0 (required by "es2015")
62 * - Math.log2, License: CC0 (required by "es2015")
63 * - Math.sign, License: CC0 (required by "es2015")
64 * - Math.sinh, License: CC0 (required by "es2015")
65 * - Math.tanh, License: CC0 (required by "es2015")
66 * - Math.trunc, License: CC0 (required by "es2015")
67 * - Number.isFinite, License: MIT (required by "es2015")
68 * - Number.isInteger, License: MIT (required by "es2015")
69 * - Number.isNaN, License: MIT (required by "es2015")
70 * - Number.isSafeInteger, License: MIT (required by "es2015")
71 * - Number.parseFloat, License: MIT (required by "es2015")
72 * - Number.parseInt, License: MIT (required by "es2015")
73 * - Function.prototype.name, License: MIT (required by "es2015")
74 * - Number.Epsilon, License: MIT (required by "es2015")
75 * - Number.MAX_SAFE_INTEGER, License: MIT (required by "es2015")
76 * - Number.MIN_SAFE_INTEGER, License: MIT (required by "es2015")
77 * - Object.freeze, License: CC0 (required by "Symbol", "es2015", "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")
78 * - Object.getOwnPropertyDescriptor, License: CC0 (required by "Object.assign", "es2015", "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")
79 * - Object.getOwnPropertyNames, License: CC0 (required by "Object.setPrototypeOf", "es2015", "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")
80 * - Object.getPrototypeOf, License: CC0 (required by "Object.setPrototypeOf", "es2015", "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
81 * - Object.is, License: CC0 (required by "es2015")
82 * - Object.keys, License: MIT (required by "Object.assign", "es2015", "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")
83 * - Object.assign, License: CC0 (required by "es2015", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
84 * - Object.defineProperties, License: CC0 (required by "Object.create", "Map", "es2015", "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")
85 * - Object.create, License: CC0 (required by "Map", "es2015", "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")
86 * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "Map", "es2015", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
87 * - _ESAbstract.Construct, License: CC0 (required by "Array.from", "es2015", "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")
88 * - _ESAbstract.ArraySpeciesCreate, License: CC0 (required by "Array.prototype.filter", "Symbol", "es2015", "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")
89 * - Array.prototype.filter, License: CC0 (required by "Symbol", "es2015", "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")
90 * - Array.prototype.map, License: CC0 (required by "Symbol", "es2015", "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")
91 * - Array.of, License: CC0 (required by "es2015")
92 * - Object.seal, License: MIT (required by "es2015")
93 * - Object.setPrototypeOf, License: MIT (required by "es2015", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
94 * - Promise, License: MIT (required by "es2015")
95 * - RegExp.prototype.flags, License: MIT (required by "es2015")
96 * - String.prototype.codePointAt, License: MIT (required by "es2015")
97 * - String.prototype.endsWith, License: CC0 (required by "es2015")
98 * - String.prototype.includes, License: CC0 (required by "es2015", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
99 * - String.prototype.padEnd, License: CC0 (required by "es2016")
100 * - String.prototype.padStart, License: CC0 (required by "es2016")
101 * - String.prototype.repeat, License: CC0 (required by "es2015")
102 * - String.prototype.startsWith, License: CC0 (required by "es2015")
103 * - Symbol, License: MIT (required by "es2015", "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")
104 * - Symbol.hasInstance, License: MIT (required by "es2015")
105 * - Symbol.isConcatSpreadable, License: MIT (required by "es2015")
106 * - Symbol.iterator, License: MIT (required by "es2015", "Array.from", "Array.prototype.@@iterator", "Map", "Set", "String.prototype.@@iterator", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
107 * - _ESAbstract.GetIterator, License: CC0 (required by "Array.from", "es2015", "Map", "Set", "WeakMap", "WeakSet")
108 * - Symbol.match, License: MIT (required by "es2015")
109 * - Symbol.replace, License: MIT (required by "es2015")
110 * - Symbol.search, License: MIT (required by "es2015")
111 * - Symbol.species, License: MIT (required by "es2015", "Map", "Array.from", "Set")
112 * - Map, License: CC0 (required by "es2015", "Array.from")
113 * - Set, License: CC0 (required by "es2015", "Array.from")
114 * - Array.from, License: CC0 (required by "es2015")
115 * - Symbol.split, License: MIT (required by "es2015")
116 * - Symbol.toPrimitive, License: MIT (required by "es2015")
117 * - Symbol.toStringTag, License: MIT (required by "es2015", "_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", "es2015", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
119 * - _ArrayIterator, License: MIT (required by "Array.prototype.entries", "es2015", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
120 * - Array.prototype.entries, License: CC0 (required by "es2015")
121 * - Array.prototype.keys, License: CC0 (required by "es2015")
122 * - Array.prototype.values, License: MIT (required by "es2015", "Array.prototype.@@iterator")
123 * - Array.prototype.@@iterator, License: CC0 (required by "es2015")
124 * - _StringIterator, License: MIT (required by "String.prototype.@@iterator", "es2015")
125 * - String.prototype.@@iterator, License: CC0 (required by "es2015")
126 * - Symbol.unscopables, License: MIT (required by "es2015")
127 * - WeakMap, License: MIT (required by "es2015")
128 * - WeakSet, License: MIT (required by "es2015") */
129
130(function(undefined) {
131
132 // _ESAbstract.ArrayCreate
133 // 9.4.2.2. ArrayCreate ( length [ , proto ] )
134 function ArrayCreate(length /* [, proto] */
135 ) {
136 // eslint-disable-line no-unused-vars
137 // 1. Assert: length is an integer Number ≥ 0.
138 // 2. If length is -0, set length to +0.
139 if (1 / length === - Infinity) {
140 length = 0;
141 }
142 // 3. If length>2^32-1, throw a RangeError exception.
143 if (length > (Math.pow(2, 32) - 1)) {
144 throw new RangeError('Invalid array length');
145 }
146 // 4. If proto is not present, set proto to the intrinsic object %ArrayPrototype%.
147 // 5. Let A be a newly created Array exotic object.
148 var A = [];
149 // 6. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.
150 // 7. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1.
151 // 8. Set A.[[Prototype]] to proto.
152 // 9. Set A.[[Extensible]] to true.
153 // 10. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
154 A.length = length;
155 // 11. Return A.
156 return A;
157 }
158
159 // _ESAbstract.Call
160 /* global IsCallable */
161 // 7.3.12. Call ( F, V [ , argumentsList ] )
162 function Call(F, V /* [, argumentsList] */
163 ) {
164 // eslint-disable-line no-unused-vars
165 // 1. If argumentsList is not present, set argumentsList to a new empty List.
166 var argumentsList = arguments.length > 2 ? arguments[2] : [];
167 // 2. If IsCallable(F) is false, throw a TypeError exception.
168 if (IsCallable(F) === false) {
169 throw new TypeError(Object.prototype.toString.call(F) + 'is not a function.');
170 }
171 // 3. Return ? F.[[Call]](V, argumentsList).
172 return F.apply(V, argumentsList);
173 }
174
175 // _ESAbstract.Get
176 // 7.3.1. Get ( O, P )
177 function Get(O, P) {
178 // eslint-disable-line no-unused-vars
179 // 1. Assert: Type(O) is Object.
180 // 2. Assert: IsPropertyKey(P) is true.
181 // 3. Return ? O.[[Get]](P, O).
182 return O[P];
183 }
184
185 // _ESAbstract.HasProperty
186 // 7.3.10. HasProperty ( O, P )
187 function HasProperty(O, P) {
188 // eslint-disable-line no-unused-vars
189 // Assert: Type(O) is Object.
190 // Assert: IsPropertyKey(P) is true.
191 // Return ? O.[[HasProperty]](P).
192 return P in O;
193 }
194
195 // _ESAbstract.IsArray
196 // 7.2.2. IsArray ( argument )
197 function IsArray(argument) {
198 // eslint-disable-line no-unused-vars
199 // 1. If Type(argument) is not Object, return false.
200 // 2. If argument is an Array exotic object, return true.
201 // 3. If argument is a Proxy exotic object, then
202 // a. If argument.[[ProxyHandler]] is null, throw a TypeError exception.
203 // b. Let target be argument.[[ProxyTarget]].
204 // c. Return ? IsArray(target).
205 // 4. Return false.
206
207 // Polyfill.io - We can skip all the above steps and check the string returned from Object.prototype.toString().
208 return Object.prototype.toString.call(argument) === '[object Array]';
209 }
210
211 // _ESAbstract.IsCallable
212 // 7.2.3. IsCallable ( argument )
213 function IsCallable(argument) {
214 // eslint-disable-line no-unused-vars
215 // 1. If Type(argument) is not Object, return false.
216 // 2. If argument has a [[Call]] internal method, return true.
217 // 3. Return false.
218
219 // 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.
220 return typeof argument === 'function';
221 }
222
223 // _ESAbstract.RequireObjectCoercible
224 // 7.2.1. RequireObjectCoercible ( argument )
225 // The abstract operation ToObject converts argument to a value of type Object according to Table 12:
226 // Table 12: ToObject Conversions
227 /*
228 |----------------------------------------------------------------------------------------------------------------------------------------------------|
229 | Argument Type | Result |
230 |----------------------------------------------------------------------------------------------------------------------------------------------------|
231 | Undefined | Throw a TypeError exception. |
232 | Null | Throw a TypeError exception. |
233 | Boolean | Return argument. |
234 | Number | Return argument. |
235 | String | Return argument. |
236 | Symbol | Return argument. |
237 | Object | Return argument. |
238 |----------------------------------------------------------------------------------------------------------------------------------------------------|
239 */
240 function RequireObjectCoercible(argument) {
241 // eslint-disable-line no-unused-vars
242 if (argument === null || argument === undefined) {
243 throw TypeError();
244 }
245 return argument;
246 }
247
248 // _ESAbstract.SameValueNonNumber
249 // 7.2.12. SameValueNonNumber ( x, y )
250 function SameValueNonNumber(x, y) {
251 // eslint-disable-line no-unused-vars
252 // 1. Assert: Type(x) is not Number.
253 // 2. Assert: Type(x) is the same as Type(y).
254 // 3. If Type(x) is Undefined, return true.
255 // 4. If Type(x) is Null, return true.
256 // 5. If Type(x) is String, then
257 // 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.
258 // 6. If Type(x) is Boolean, then
259 // a. If x and y are both true or both false, return true; otherwise, return false.
260 // 7. If Type(x) is Symbol, then
261 // a. If x and y are both the same Symbol value, return true; otherwise, return false.
262 // 8. If x and y are the same Object value, return true. Otherwise, return false.
263
264 // Polyfill.io - We can skip all above steps because the === operator does it all for us.
265 return x === y;
266 }
267
268 // _ESAbstract.ToBoolean
269 // 7.1.2. ToBoolean ( argument )
270 // The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 9:
271 /*
272 --------------------------------------------------------------------------------------------------------------
273 | Argument Type | Result |
274 --------------------------------------------------------------------------------------------------------------
275 | Undefined | Return false. |
276 | Null | Return false. |
277 | Boolean | Return argument. |
278 | Number | If argument is +0, -0, or NaN, return false; otherwise return true. |
279 | String | If argument is the empty String (its length is zero), return false; otherwise return true. |
280 | Symbol | Return true. |
281 | Object | Return true. |
282 --------------------------------------------------------------------------------------------------------------
283 */
284 function ToBoolean(argument) {
285 // eslint-disable-line no-unused-vars
286 return Boolean(argument);
287 }
288
289 // _ESAbstract.ToInteger
290 // 7.1.4. ToInteger ( argument )
291 function ToInteger(argument) {
292 // eslint-disable-line no-unused-vars
293 // 1. Let number be ? ToNumber(argument).
294 var number = Number(argument);
295 // 2. If number is NaN, return +0.
296 if (isNaN(number)) {
297 return 0;
298 }
299 // 3. If number is +0, -0, +∞, or -∞, return number.
300 if (1 / number === Infinity || 1 / number === - Infinity || number === Infinity || number === - Infinity) {
301 return number;
302 }
303 // 4. Return the number value that is the same sign as number and whose magnitude is floor(abs(number)).
304 return ((number < 0) ? - 1 : 1) * Math.floor(Math.abs(number));
305 }
306
307 // _ESAbstract.ToLength
308 /* global ToInteger */
309 // 7.1.15. ToLength ( argument )
310 function ToLength(argument) {
311 // eslint-disable-line no-unused-vars
312 // 1. Let len be ? ToInteger(argument).
313 var len = ToInteger(argument);
314 // 2. If len ≤ +0, return +0.
315 if (len <= 0) {
316 return 0;
317 }
318 // 3. Return min(len, 253-1).
319 return Math.min(len, Math.pow(2, 53) - 1);
320 }
321
322 // _ESAbstract.ToObject
323 // 7.1.13 ToObject ( argument )
324 // The abstract operation ToObject converts argument to a value of type Object according to Table 12:
325 // Table 12: ToObject Conversions
326 /*
327 |----------------------------------------------------------------------------------------------------------------------------------------------------|
328 | Argument Type | Result |
329 |----------------------------------------------------------------------------------------------------------------------------------------------------|
330 | Undefined | Throw a TypeError exception. |
331 | Null | Throw a TypeError exception. |
332 | Boolean | Return a new Boolean object whose [[BooleanData]] internal slot is set to argument. See 19.3 for a description of Boolean objects. |
333 | Number | Return a new Number object whose [[NumberData]] internal slot is set to argument. See 20.1 for a description of Number objects. |
334 | String | Return a new String object whose [[StringData]] internal slot is set to argument. See 21.1 for a description of String objects. |
335 | Symbol | Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 19.4 for a description of Symbol objects. |
336 | Object | Return argument. |
337 |----------------------------------------------------------------------------------------------------------------------------------------------------|
338 */
339 function ToObject(argument) {
340 // eslint-disable-line no-unused-vars
341 if (argument === null || argument === undefined) {
342 throw TypeError();
343 }
344 return Object(argument);
345 }
346
347 // _ESAbstract.GetV
348 /* global ToObject */
349 // 7.3.2 GetV (V, P)
350 function GetV(v, p) {
351 // eslint-disable-line no-unused-vars
352 // 1. Assert: IsPropertyKey(P) is true.
353 // 2. Let O be ? ToObject(V).
354 var o = ToObject(v);
355 // 3. Return ? O.[[Get]](P, V).
356 return o[p];
357 }
358
359 // _ESAbstract.GetMethod
360 /* global GetV, IsCallable */
361 // 7.3.9. GetMethod ( V, P )
362 function GetMethod(V, P) {
363 // eslint-disable-line no-unused-vars
364 // 1. Assert: IsPropertyKey(P) is true.
365 // 2. Let func be ? GetV(V, P).
366 var func = GetV(V, P);
367 // 3. If func is either undefined or null, return undefined.
368 if (func === null || func === undefined) {
369 return undefined;
370 }
371 // 4. If IsCallable(func) is false, throw a TypeError exception.
372 if (IsCallable(func) === false) {
373 throw new TypeError('Method not callable: ' + P);
374 }
375 // 5. Return func.
376 return func;
377 }
378
379 // _ESAbstract.ToUint32
380 // 7.1.6. ToUint32 ( argument )
381 function ToUint32(argument) {
382 // eslint-disable-line no-unused-vars
383 // 1. Let number be ? ToNumber(argument).
384 var number = Number(argument);
385 // 2. If number is NaN, +0, -0, +∞, or -∞, return +0.
386 if (isNaN(number) || 1 / number === Infinity || 1 / number === - Infinity || number === Infinity || number === - Infinity) {
387 return 0;
388 }
389 // 3. Let int be the mathematical value that is the same sign as number and whose magnitude is floor(abs(number)).
390 var int = ((number < 0) ? - 1 : 1) * Math.floor(Math.abs(number));
391 // 4. Let int32bit be int modulo 2^32.
392 var int32bit = int >>> 0;
393 // 5. Return int32bit.
394 return int32bit;
395 }
396
397 // _ESAbstract.Type
398 // "Type(x)" is used as shorthand for "the type of x"...
399 function Type(x) {
400 // eslint-disable-line no-unused-vars
401 switch (typeof x) {
402 case 'undefined':
403 return 'undefined';
404 case 'boolean':
405 return 'boolean';
406 case 'number':
407 return 'number';
408 case 'string':
409 return 'string';
410 case 'symbol':
411 return 'symbol';
412 default:
413 // typeof null is 'object'
414 if (x === null)
415 return 'null';
416 // Polyfill.io - This is here because a Symbol polyfill will have a typeof `object`.
417 if ('Symbol' in this && x instanceof this.Symbol)
418 return 'symbol';
419 return 'object';
420 }
421 }
422
423 // _ESAbstract.GetPrototypeFromConstructor
424 /* global Get, Type */
425 // 9.1.14. GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
426 function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) {
427 // eslint-disable-line no-unused-vars
428 // 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.
429 // 2. Assert: IsCallable(constructor) is true.
430 // 3. Let proto be ? Get(constructor, "prototype").
431 var proto = Get(constructor, "prototype");
432 // 4. If Type(proto) is not Object, then
433 if (Type(proto) !== 'object') {
434 // a. Let realm be ? GetFunctionRealm(constructor).
435 // b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
436 proto = intrinsicDefaultProto;
437 }
438 // 5. Return proto.
439 return proto;
440 }
441
442 // _ESAbstract.IsConstructor
443 /* global Type */
444 // 7.2.4. IsConstructor ( argument )
445 function IsConstructor(argument) {
446 // eslint-disable-line no-unused-vars
447 // 1. If Type(argument) is not Object, return false.
448 if (Type(argument) !== 'object') {
449 return false;
450 }
451 // 2. If argument has a [[Construct]] internal method, return true.
452 // 3. Return false.
453
454 // Polyfill.io - `new argument` is the only way to truly test if a function is a constructor.
455 // We choose to not use`new argument` because the argument could have side effects when called.
456 // Instead we check to see if the argument is a function and if it has a prototype.
457 // Arrow functions do not have a [[Construct]] internal method, nor do they have a prototype.
458 return typeof argument === 'function' && !!argument.prototype;
459 }
460
461 // _ESAbstract.IsRegExp
462 /* global Type, Get, ToBoolean */
463 // 7.2.8. IsRegExp ( argument )
464 function IsRegExp(argument) {
465 // eslint-disable-line no-unused-vars
466 // 1. If Type(argument) is not Object, return false.
467 if (Type(argument) !== 'object') {
468 return false;
469 }
470 // 2. Let matcher be ? Get(argument, @@match).
471 var matcher = 'Symbol' in this && 'match' in this.Symbol ? Get(argument, this.Symbol.match) : undefined;
472 // 3. If matcher is not undefined, return ToBoolean(matcher).
473 if (matcher !== undefined) {
474 return ToBoolean(matcher);
475 }
476 // 4. If argument has a [[RegExpMatcher]] internal slot, return true.
477 try {
478 var lastIndex = argument.lastIndex;
479 argument.lastIndex = 0;
480 RegExp.prototype.exec.call(argument);
481 return true;
482 } catch (e) {} finally {
483 argument.lastIndex = lastIndex;
484 }
485 // 5. Return false.
486 return false;
487 }
488
489 // _ESAbstract.IteratorClose
490 /* global GetMethod, Type, Call */
491 // 7.4.6. IteratorClose ( iteratorRecord, completion )
492 function IteratorClose(iteratorRecord, completion) {
493 // eslint-disable-line no-unused-vars
494 // 1. Assert: Type(iteratorRecord.[[Iterator]]) is Object.
495 if (Type(iteratorRecord['[[Iterator]]']) !== 'object') {
496 throw new Error(Object.prototype.toString.call(iteratorRecord['[[Iterator]]']) + 'is not an Object.');
497 }
498 // 2. Assert: completion is a Completion Record.
499 // Polyfill.io - Ignoring this step as there is no way to check if something is a Completion Record in userland JavaScript.
500
501 // 3. Let iterator be iteratorRecord.[[Iterator]].
502 var iterator = iteratorRecord['[[Iterator]]'];
503 // 4. Let return be ? GetMethod(iterator, "return").
504 // 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).
505 var returnMethod = GetMethod(iterator, "return");
506 // 5. If return is undefined, return Completion(completion).
507 if (returnMethod === undefined) {
508 return completion;
509 }
510 // 6. Let innerResult be Call(return, iterator, « »).
511 try {
512 var innerResult = Call(returnMethod, iterator);
513 } catch (error) {
514 var innerException = error;
515 }
516 // 7. If completion.[[Type]] is throw, return Completion(completion).
517 if (completion) {
518 return completion;
519 }
520 // 8. If innerResult.[[Type]] is throw, return Completion(innerResult).
521 if (innerException) {
522 throw innerException;
523 }
524 // 9. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
525 if (Type(innerResult) !== 'object') {
526 throw new TypeError("Iterator's return method returned a non-object.");
527 }
528 // 10. Return Completion(completion).
529 return completion;
530 }
531
532 // _ESAbstract.IteratorComplete
533 /* global Type, ToBoolean, Get */
534 // 7.4.3 IteratorComplete ( iterResult )
535 function IteratorComplete(iterResult) {
536 // eslint-disable-line no-unused-vars
537 // 1. Assert: Type(iterResult) is Object.
538 if (Type(iterResult) !== 'object') {
539 throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
540 }
541 // 2. Return ToBoolean(? Get(iterResult, "done")).
542 return ToBoolean(Get(iterResult, "done"));
543 }
544
545 // _ESAbstract.IteratorNext
546 /* global Call, Type */
547 // 7.4.2. IteratorNext ( iteratorRecord [ , value ] )
548 function IteratorNext(iteratorRecord /* [, value] */
549 ) {
550 // eslint-disable-line no-unused-vars
551 // 1. If value is not present, then
552 if (arguments.length < 2) {
553 // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « »).
554 var result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']);
555 // 2. Else,
556 } else {
557 // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « value »).
558 result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]);
559 }
560 // 3. If Type(result) is not Object, throw a TypeError exception.
561 if (Type(result) !== 'object') {
562 throw new TypeError('bad iterator');
563 }
564 // 4. Return result.
565 return result;
566 }
567
568 // _ESAbstract.IteratorStep
569 /* global IteratorNext, IteratorComplete */
570 // 7.4.5. IteratorStep ( iteratorRecord )
571 function IteratorStep(iteratorRecord) {
572 // eslint-disable-line no-unused-vars
573 // 1. Let result be ? IteratorNext(iteratorRecord).
574 var result = IteratorNext(iteratorRecord);
575 // 2. Let done be ? IteratorComplete(result).
576 var done = IteratorComplete(result);
577 // 3. If done is true, return false.
578 if (done === true) {
579 return false;
580 }
581 // 4. Return result.
582 return result;
583 }
584
585 // _ESAbstract.IteratorValue
586 /* global Type, Get */
587 // 7.4.4 IteratorValue ( iterResult )
588 function IteratorValue(iterResult) {
589 // eslint-disable-line no-unused-vars
590 // Assert: Type(iterResult) is Object.
591 if (Type(iterResult) !== 'object') {
592 throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
593 }
594 // Return ? Get(iterResult, "value").
595 return Get(iterResult, "value");
596 }
597
598 // _ESAbstract.OrdinaryToPrimitive
599 /* global Get, IsCallable, Call, Type */
600 // 7.1.1.1. OrdinaryToPrimitive ( O, hint )
601 function OrdinaryToPrimitive(O, hint) {
602 // eslint-disable-line no-unused-vars
603 // 1. Assert: Type(O) is Object.
604 // 2. Assert: Type(hint) is String and its value is either "string" or "number".
605 // 3. If hint is "string", then
606 if (hint === 'string') {
607 // a. Let methodNames be « "toString", "valueOf" ».
608 var methodNames = ['toString', 'valueOf'];
609 // 4. Else,
610 } else {
611 // a. Let methodNames be « "valueOf", "toString" ».
612 methodNames = ['valueOf', 'toString'];
613 }
614 // 5. For each name in methodNames in List order, do
615 for (var i = 0; i < methodNames.length; ++i) {
616 var name = methodNames[i];
617 // a. Let method be ? Get(O, name).
618 var method = Get(O, name);
619 // b. If IsCallable(method) is true, then
620 if (IsCallable(method)) {
621 // i. Let result be ? Call(method, O).
622 var result = Call(method, O);
623 // ii. If Type(result) is not Object, return result.
624 if (Type(result) !== 'object') {
625 return result;
626 }
627 }
628 }
629 // 6. Throw a TypeError exception.
630 throw new TypeError('Cannot convert to primitive.');
631 }
632
633 // _ESAbstract.SameValue
634 /* global Type, SameValueNonNumber */
635 // 7.2.10. SameValue ( x, y )
636 function SameValue(x, y) {
637 // eslint-disable-line no-unused-vars
638 // 1. If Type(x) is different from Type(y), return false.
639 if (Type(x) !== Type(y)) {
640 return false;
641 }
642 // 2. If Type(x) is Number, then
643 if (Type(x) === 'number') {
644 // a. If x is NaN and y is NaN, return true.
645 if (isNaN(x) && isNaN(y)) {
646 return true;
647 }
648 // Polyfill.io - 0 === -0 is true, but they are not the same value.
649 // b. If x is +0 and y is -0, return false.
650 // c. If x is -0 and y is +0, return false.
651 if (x === 0 && y === 0 && 1 / x !== 1 / y) {
652 return false;
653 }
654 // d. If x is the same Number value as y, return true.
655 if (x === y) {
656 return true;
657 }
658 // e. Return false.
659 return false;
660 }
661 // 3. Return SameValueNonNumber(x, y).
662 return SameValueNonNumber(x, y);
663 }
664
665 // _ESAbstract.SameValueZero
666 /* global Type, SameValueNonNumber */
667 // 7.2.11. SameValueZero ( x, y )
668 function SameValueZero (x, y) {
669 // eslint-disable-line no-unused-vars
670 // 1. If Type(x) is different from Type(y), return false.
671 if (Type(x) !== Type(y)) {
672 return false;
673 }
674 // 2. If Type(x) is Number, then
675 if (Type(x) === 'number') {
676 // a. If x is NaN and y is NaN, return true.
677 if (isNaN(x) && isNaN(y)) {
678 return true;
679 }
680 // b. If x is +0 and y is -0, return true.
681 if (1 / x === Infinity && 1 / y === - Infinity) {
682 return true;
683 }
684 // c. If x is -0 and y is +0, return true.
685 if (1 / x === - Infinity && 1 / y === Infinity) {
686 return true;
687 }
688 // d. If x is the same Number value as y, return true.
689 if (x === y) {
690 return true;
691 }
692 // e. Return false.
693 return false;
694 }
695 // 3. Return SameValueNonNumber(x, y).
696 return SameValueNonNumber(x, y);
697 }
698
699 // _ESAbstract.ToPrimitive
700 /* global Type, GetMethod, Call, OrdinaryToPrimitive */
701 // 7.1.1. ToPrimitive ( input [ , PreferredType ] )
702 function ToPrimitive(input /* [, PreferredType] */
703 ) {
704 // eslint-disable-line no-unused-vars
705 var PreferredType = arguments.length > 1 ? arguments[1] : undefined;
706 // 1. Assert: input is an ECMAScript language value.
707 // 2. If Type(input) is Object, then
708 if (Type(input) === 'object') {
709 // a. If PreferredType is not present, let hint be "default".
710 if (arguments.length < 2) {
711 var hint = 'default';
712 // b. Else if PreferredType is hint String, let hint be "string".
713 } else if (PreferredType === String) {
714 hint = 'string';
715 // c. Else PreferredType is hint Number, let hint be "number".
716 } else if (PreferredType === Number) {
717 hint = 'number';
718 }
719 // d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
720 var exoticToPrim = typeof this.Symbol === 'function' && typeof this.Symbol.toPrimitive === 'symbol' ? GetMethod(input, this.Symbol.toPrimitive) : undefined;
721 // e. If exoticToPrim is not undefined, then
722 if (exoticToPrim !== undefined) {
723 // i. Let result be ? Call(exoticToPrim, input, « hint »).
724 var result = Call(exoticToPrim, input, [hint]);
725 // ii. If Type(result) is not Object, return result.
726 if (Type(result) !== 'object') {
727 return result;
728 }
729 // iii. Throw a TypeError exception.
730 throw new TypeError('Cannot convert exotic object to primitive.');
731 }
732 // f. If hint is "default", set hint to "number".
733 if (hint === 'default') {
734 hint = 'number';
735 }
736 // g. Return ? OrdinaryToPrimitive(input, hint).
737 return OrdinaryToPrimitive(input, hint);
738 }
739 // 3. Return input
740 return input;
741 }
742
743 // _ESAbstract.ToString
744 /* global Type, ToPrimitive */
745 // 7.1.12. ToString ( argument )
746 // The abstract operation ToString converts argument to a value of type String according to Table 11:
747 // Table 11: ToString Conversions
748 /*
749 |---------------|--------------------------------------------------------|
750 | Argument Type | Result |
751 |---------------|--------------------------------------------------------|
752 | Undefined | Return "undefined". |
753 |---------------|--------------------------------------------------------|
754 | Null | Return "null". |
755 |---------------|--------------------------------------------------------|
756 | Boolean | If argument is true, return "true". |
757 | | If argument is false, return "false". |
758 |---------------|--------------------------------------------------------|
759 | Number | Return NumberToString(argument). |
760 |---------------|--------------------------------------------------------|
761 | String | Return argument. |
762 |---------------|--------------------------------------------------------|
763 | Symbol | Throw a TypeError exception. |
764 |---------------|--------------------------------------------------------|
765 | Object | Apply the following steps: |
766 | | Let primValue be ? ToPrimitive(argument, hint String). |
767 | | Return ? ToString(primValue). |
768 |---------------|--------------------------------------------------------|
769 */
770 function ToString(argument) {
771 // eslint-disable-line no-unused-vars
772 switch (Type(argument)) {
773 case 'symbol':
774 throw new TypeError('Cannot convert a Symbol value to a string');
775 break;
776 case 'object':
777 var primValue = ToPrimitive(argument, 'string');
778 return ToString(primValue);
779 default:
780 return String(argument);
781 }
782 }
783
784 // _ESAbstract.UTF16Decode
785 // 10.1.2. Static Semantics: UTF16Decode( lead, trail )
786 function UTF16Decode(lead, trail) {
787 // eslint-disable-line no-unused-vars
788 // 1. Assert: 0xD800 ≤ lead ≤ 0xDBFF and 0xDC00 ≤ trail ≤ 0xDFFF.
789 // 2. Let cp be (lead - 0xD800) × 0x400 + (trail - 0xDC00) + 0x10000.
790 var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
791 // 3. Return the code point cp.
792 return cp;
793 }
794
795 // _TypedArray
796 /*
797 Copyright (c) 2010, Linden Research, Inc.
798 Copyright (c) 2014, Joshua Bell
799
800 Permission is hereby granted, free of charge, to any person obtaining a copy
801 of this software and associated documentation files (the "Software"), to deal
802 in the Software without restriction, including without limitation the rights
803 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
804 copies of the Software, and to permit persons to whom the Software is
805 furnished to do so, subject to the following conditions:
806
807 The above copyright notice and this permission notice shall be included in
808 all copies or substantial portions of the Software.
809
810 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
811 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
812 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
813 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
814 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
815 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
816 THE SOFTWARE.
817 $/LicenseInfo$
818 */
819
820 // Original can be found at:
821 // https://bitbucket.org/lindenlab/llsd
822 // Modifications by Joshua Bell inexorabletash@gmail.com
823 // https://github.com/inexorabletash/polyfill
824
825 // ES3/ES5 implementation of the Krhonos Typed Array Specification
826 // Ref: http://www.khronos.org/registry/typedarray/specs/latest/
827 // Date: 2011-02-01
828 //
829 // Variations:
830 // * Allows typed_array.get/set() as alias for subscripts (typed_array[])
831 // * Gradually migrating structure from Khronos spec to ES2015 spec
832 //
833 // Caveats:
834 // * Beyond 10000 or so entries, polyfilled array accessors (ta[0],
835 // etc) become memory-prohibitive, so array creation will fail. Set
836 // self.TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS=true to disable
837 // creation of accessors. Your code will need to use the
838 // non-standard get()/set() instead, and will need to add those to
839 // native arrays for interop.
840 (function(global) {
841 'use strict';
842 var undefined = (void 0); // Paranoia
843
844 // Beyond this value, index getters/setters (i.e. array[0], array[1]) are so slow to
845 // create, and consume so much memory, that the browser appears frozen.
846 var MAX_ARRAY_LENGTH = 1e5;
847
848 // Approximations of internal ECMAScript conversion functions
849 function Type(v) {
850 switch (typeof v) {
851 case 'undefined':
852 return 'undefined';
853 case 'boolean':
854 return 'boolean';
855 case 'number':
856 return 'number';
857 case 'string':
858 return 'string';
859 default:
860 return v === null ? 'null' : 'object';
861 }
862 }
863
864 // Class returns internal [[Class]] property, used to avoid cross-frame instanceof issues:
865 function Class(v) {
866 return Object.prototype.toString.call(v).replace(/^\[object *|\]$/g, '');
867 }
868 function IsCallable(o) {
869 return typeof o === 'function';
870 }
871 function ToObject(v) {
872 if (v === null || v === undefined)
873 throw TypeError();
874 return Object(v);
875 }
876 function ToInt32(v) {
877 return v >> 0;
878 }
879 function ToUint32(v) {
880 return v >>> 0;
881 }
882
883 // Snapshot intrinsics
884 var LN2 = Math.LN2,
885 abs = Math.abs,
886 floor = Math.floor,
887 log = Math.log,
888 max = Math.max,
889 min = Math.min,
890 pow = Math.pow,
891 round = Math.round;
892
893 // emulate ES5 getter/setter API using legacy APIs
894 // http://blogs.msdn.com/b/ie/archive/2010/09/07/transitioning-existing-code-to-the-es5-getter-setter-apis.aspx
895 // (second clause tests for Object.defineProperty() in IE<9 that only supports extending DOM prototypes, but
896 // note that IE<9 does not support __defineGetter__ or __defineSetter__ so it just renders the method harmless)
897
898 (function() {
899 var orig = Object.defineProperty;
900 var dom_only = !(function() {
901 try {
902 return Object.defineProperty({}, 'x', {});
903 } catch (_) {
904 return false;
905 }
906 }());
907
908 if (!orig || dom_only) {
909 Object.defineProperty = function (o, prop, desc) {
910 // In IE8 try built-in implementation for defining properties on DOM prototypes.
911 if (orig)
912 try {
913 return orig(o, prop, desc);
914 } catch (_) {}
915 if (o !== Object(o))
916 throw TypeError('Object.defineProperty called on non-object');
917 if (Object.prototype.__defineGetter__ && ('get' in desc))
918 Object.prototype.__defineGetter__.call(o, prop, desc.get);
919 if (Object.prototype.__defineSetter__ && ('set' in desc))
920 Object.prototype.__defineSetter__.call(o, prop, desc.set);
921 if ('value' in desc)
922 o[prop] = desc.value;
923 return o;
924 };
925 }
926 }());
927
928 // ES5: Make obj[index] an alias for obj._getter(index)/obj._setter(index, value)
929 // for index in 0 ... obj.length
930 function makeArrayAccessors(obj) {
931 if ('TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS' in global)
932 return;
933
934 if (obj.length > MAX_ARRAY_LENGTH)
935 throw RangeError('Array too large for polyfill');
936
937 function makeArrayAccessor(index) {
938 Object.defineProperty(obj, index, {
939 'get': function() {
940 return obj._getter(index);
941 },
942 'set': function(v) {
943 obj._setter(index, v);
944 },
945 enumerable: true,
946 configurable: false
947 });
948 }
949
950 var i;
951 for (i = 0; i < obj.length; i += 1) {
952 makeArrayAccessor(i);
953 }
954 }
955
956 // Internal conversion functions:
957 // pack<Type>() - take a number (interpreted as Type), output a byte array
958 // unpack<Type>() - take a byte array, output a Type-like number
959
960 function as_signed(value, bits) {
961 var s = 32 - bits;
962 return (value << s) >> s;
963 }
964 function as_unsigned(value, bits) {
965 var s = 32 - bits;
966 return (value << s) >>> s;
967 }
968
969 function packI8(n) {
970 return [n & 0xff];
971 }
972 function unpackI8(bytes) {
973 return as_signed(bytes[0], 8);
974 }
975
976 function packU8(n) {
977 return [n & 0xff];
978 }
979 function unpackU8(bytes) {
980 return as_unsigned(bytes[0], 8);
981 }
982
983 function packU8Clamped(n) {
984 n = round(Number(n));
985 return [n < 0 ? 0 : n > 0xff ? 0xff : n & 0xff];
986 }
987
988 function packI16(n) {
989 return [n & 0xff, (n >> 8) & 0xff];
990 }
991 function unpackI16(bytes) {
992 return as_signed(bytes[1] << 8 | bytes[0], 16);
993 }
994
995 function packU16(n) {
996 return [n & 0xff, (n >> 8) & 0xff];
997 }
998 function unpackU16(bytes) {
999 return as_unsigned(bytes[1] << 8 | bytes[0], 16);
1000 }
1001
1002 function packI32(n) {
1003 return [n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, (n >> 24) & 0xff];
1004 }
1005 function unpackI32(bytes) {
1006 return as_signed(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0], 32);
1007 }
1008
1009 function packU32(n) {
1010 return [n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, (n >> 24) & 0xff];
1011 }
1012 function unpackU32(bytes) {
1013 return as_unsigned(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0], 32);
1014 }
1015
1016 function packIEEE754(v, ebits, fbits) {
1017
1018 var bias = (1 << (ebits - 1)) - 1;
1019
1020 function roundToEven(n) {
1021 var w = floor(n), f = n - w;
1022 if (f < 0.5)
1023 return w;
1024 if (f > 0.5)
1025 return w + 1;
1026 return w % 2 ? w + 1 : w;
1027 }
1028
1029 // Compute sign, exponent, fraction
1030 var s, e, f;
1031 if (v !== v) {
1032 // NaN
1033 // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping
1034 e = (1 << ebits) - 1;
1035 f = pow(2, fbits - 1);
1036 s = 0;
1037 } else if (v === Infinity || v === - Infinity) {
1038 e = (1 << ebits) - 1;
1039 f = 0;
1040 s = (v < 0) ? 1 : 0;
1041 } else if (v === 0) {
1042 e = 0;
1043 f = 0;
1044 s = (1 / v === - Infinity) ? 1 : 0;
1045 } else {
1046 s = v < 0;
1047 v = abs(v);
1048
1049 if (v >= pow(2, 1 - bias)) {
1050 // Normalized
1051 e = min(floor(log(v) / LN2), 1023);
1052 var significand = v / pow(2, e);
1053 if (significand < 1) {
1054 e -= 1;
1055 significand *= 2;
1056 }
1057 if (significand >= 2) {
1058 e += 1;
1059 significand /= 2;
1060 }
1061 var d = pow(2, fbits);
1062 f = roundToEven(significand * d) - d;
1063 e += bias;
1064 if (f / d >= 1) {
1065 e += 1;
1066 f = 0;
1067 }
1068 if (e > 2 * bias) {
1069 // Overflow
1070 e = (1 << ebits) - 1;
1071 f = 0;
1072 }
1073 } else {
1074 // Denormalized
1075 e = 0;
1076 f = roundToEven(v / pow(2, 1 - bias - fbits));
1077 }
1078 }
1079
1080 // Pack sign, exponent, fraction
1081 var bits = [], i;
1082 for (i = fbits; i; i -= 1) {
1083 bits.push(f % 2 ? 1 : 0);
1084 f = floor(f / 2);
1085 }
1086 for (i = ebits; i; i -= 1) {
1087 bits.push(e % 2 ? 1 : 0);
1088 e = floor(e / 2);
1089 }
1090 bits.push(s ? 1 : 0);
1091 bits.reverse();
1092 var str = bits.join('');
1093
1094 // Bits to bytes
1095 var bytes = [];
1096 while (str.length) {
1097 bytes.unshift(parseInt(str.substring(0, 8), 2));
1098 str = str.substring(8);
1099 }
1100 return bytes;
1101 }
1102
1103 function unpackIEEE754(bytes, ebits, fbits) {
1104 // Bytes to bits
1105 var bits = [], i, j, b, str,
1106 bias, s, e, f;
1107
1108 for (i = 0; i < bytes.length; ++i) {
1109 b = bytes[i];
1110 for (j = 8; j; j -= 1) {
1111 bits.push(b % 2 ? 1 : 0);
1112 b = b >> 1;
1113 }
1114 }
1115 bits.reverse();
1116 str = bits.join('');
1117
1118 // Unpack sign, exponent, fraction
1119 bias = (1 << (ebits - 1)) - 1;
1120 s = parseInt(str.substring(0, 1), 2) ? - 1 : 1;
1121 e = parseInt(str.substring(1, 1 + ebits), 2);
1122 f = parseInt(str.substring(1 + ebits), 2);
1123
1124 // Produce number
1125 if (e === (1 << ebits) - 1) {
1126 return f !== 0 ? NaN : s * Infinity;
1127 } else if (e > 0) {
1128 // Normalized
1129 return s * pow(2, e - bias) * (1 + f / pow(2, fbits));
1130 } else if (f !== 0) {
1131 // Denormalized
1132 return s * pow(2, - (bias - 1)) * (f / pow(2, fbits));
1133 } else {
1134 return s < 0 ? - 0 : 0;
1135 }
1136 }
1137
1138 function unpackF64(b) {
1139 return unpackIEEE754(b, 11, 52);
1140 }
1141 function packF64(v) {
1142 return packIEEE754(v, 11, 52);
1143 }
1144 function unpackF32(b) {
1145 return unpackIEEE754(b, 8, 23);
1146 }
1147 function packF32(v) {
1148 return packIEEE754(v, 8, 23);
1149 }
1150
1151 //
1152 // 3 The ArrayBuffer Type
1153 //
1154
1155 (function() {
1156
1157 function ArrayBuffer(length) {
1158 length = ToInt32(length);
1159 if (length < 0)
1160 throw RangeError('ArrayBuffer size is not a small enough positive integer.');
1161 Object.defineProperty(this, 'byteLength', {
1162 value: length
1163 });
1164 Object.defineProperty(this, '_bytes', {
1165 value: Array(length)
1166 });
1167
1168 for (var i = 0; i < length; i += 1)
1169 this._bytes[i] = 0;
1170 }
1171
1172 global.ArrayBuffer = global.ArrayBuffer || ArrayBuffer;
1173
1174 //
1175 // 5 The Typed Array View Types
1176 //
1177
1178 function $TypedArray$() {
1179
1180 // %TypedArray% ( length )
1181 if (!arguments.length || typeof arguments[0] !== 'object') {
1182 return (function(length) {
1183 length = ToInt32(length);
1184 if (length < 0)
1185 throw RangeError('length is not a small enough positive integer.');
1186 Object.defineProperty(this, 'length', {
1187 value: length
1188 });
1189 Object.defineProperty(this, 'byteLength', {
1190 value: length * this.BYTES_PER_ELEMENT
1191 });
1192 Object.defineProperty(this, 'buffer', {
1193 value: new ArrayBuffer(this.byteLength)
1194 });
1195 Object.defineProperty(this, 'byteOffset', {
1196 value: 0
1197 });
1198
1199 }).apply(this, arguments);
1200 }
1201
1202 // %TypedArray% ( typedArray )
1203 if (arguments.length >= 1 &&
1204 Type(arguments[0]) === 'object' &&
1205 arguments[0] instanceof $TypedArray$) {
1206 return (function(typedArray) {
1207 if (this.constructor !== typedArray.constructor)
1208 throw TypeError();
1209
1210 var byteLength = typedArray.length * this.BYTES_PER_ELEMENT;
1211 Object.defineProperty(this, 'buffer', {
1212 value: new ArrayBuffer(byteLength)
1213 });
1214 Object.defineProperty(this, 'byteLength', {
1215 value: byteLength
1216 });
1217 Object.defineProperty(this, 'byteOffset', {
1218 value: 0
1219 });
1220 Object.defineProperty(this, 'length', {
1221 value: typedArray.length
1222 });
1223
1224 for (var i = 0; i < this.length; i += 1)
1225 this._setter(i, typedArray._getter(i));
1226
1227 }).apply(this, arguments);
1228 }
1229
1230 // %TypedArray% ( array )
1231 if (arguments.length >= 1 &&
1232 Type(arguments[0]) === 'object' &&
1233 !(arguments[0] instanceof $TypedArray$) &&
1234 !(arguments[0] instanceof ArrayBuffer || Class(arguments[0]) === 'ArrayBuffer')) {
1235 return (function(array) {
1236
1237 var byteLength = array.length * this.BYTES_PER_ELEMENT;
1238 Object.defineProperty(this, 'buffer', {
1239 value: new ArrayBuffer(byteLength)
1240 });
1241 Object.defineProperty(this, 'byteLength', {
1242 value: byteLength
1243 });
1244 Object.defineProperty(this, 'byteOffset', {
1245 value: 0
1246 });
1247 Object.defineProperty(this, 'length', {
1248 value: array.length
1249 });
1250
1251 for (var i = 0; i < this.length; i += 1) {
1252 var s = array[i];
1253 this._setter(i, Number(s));
1254 }
1255 }).apply(this, arguments);
1256 }
1257
1258 // %TypedArray% ( buffer, byteOffset=0, length=undefined )
1259 if (arguments.length >= 1 &&
1260 Type(arguments[0]) === 'object' &&
1261 (arguments[0] instanceof ArrayBuffer || Class(arguments[0]) === 'ArrayBuffer')) {
1262 return (function(buffer, byteOffset, length) {
1263
1264 byteOffset = ToUint32(byteOffset);
1265 if (byteOffset > buffer.byteLength)
1266 throw RangeError('byteOffset out of range');
1267
1268 // The given byteOffset must be a multiple of the element
1269 // size of the specific type, otherwise an exception is raised.
1270 if (byteOffset % this.BYTES_PER_ELEMENT)
1271 throw RangeError('buffer length minus the byteOffset is not a multiple of the element size.');
1272
1273 if (length === undefined) {
1274 var byteLength = buffer.byteLength - byteOffset;
1275 if (byteLength % this.BYTES_PER_ELEMENT)
1276 throw RangeError('length of buffer minus byteOffset not a multiple of the element size');
1277 length = byteLength / this.BYTES_PER_ELEMENT;
1278
1279 } else {
1280 length = ToUint32(length);
1281 byteLength = length * this.BYTES_PER_ELEMENT;
1282 }
1283
1284 if ((byteOffset + byteLength) > buffer.byteLength)
1285 throw RangeError('byteOffset and length reference an area beyond the end of the buffer');
1286
1287 Object.defineProperty(this, 'buffer', {
1288 value: buffer
1289 });
1290 Object.defineProperty(this, 'byteLength', {
1291 value: byteLength
1292 });
1293 Object.defineProperty(this, 'byteOffset', {
1294 value: byteOffset
1295 });
1296 Object.defineProperty(this, 'length', {
1297 value: length
1298 });
1299
1300 }).apply(this, arguments);
1301 }
1302
1303 // %TypedArray% ( all other argument combinations )
1304 throw TypeError();
1305 }
1306
1307 // Properties of the %TypedArray Instrinsic Object
1308
1309 // %TypedArray%.from ( source , mapfn=undefined, thisArg=undefined )
1310 Object.defineProperty($TypedArray$, 'from', {
1311 value: function(iterable) {
1312 return new this (iterable);
1313 }
1314 });
1315
1316 // %TypedArray%.of ( ...items )
1317 Object.defineProperty($TypedArray$, 'of', {
1318 value: function( /*...items*/
1319 ) {
1320 return new this (arguments);
1321 }
1322 });
1323
1324 // %TypedArray%.prototype
1325 var $TypedArrayPrototype$ = {};
1326 $TypedArray$.prototype = $TypedArrayPrototype$;
1327
1328 // WebIDL: getter type (unsigned long index);
1329 Object.defineProperty($TypedArray$.prototype, '_getter', {
1330 value: function(index) {
1331 if (arguments.length < 1)
1332 throw SyntaxError('Not enough arguments');
1333
1334 index = ToUint32(index);
1335 if (index >= this.length)
1336 return undefined;
1337
1338 var bytes = [], i, o;
1339 for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT;
1340 i < this.BYTES_PER_ELEMENT;
1341 i += 1, o += 1) {
1342 bytes.push(this.buffer._bytes[o]);
1343 }
1344 return this._unpack(bytes);
1345 }
1346 });
1347
1348 // NONSTANDARD: convenience alias for getter: type get(unsigned long index);
1349 Object.defineProperty($TypedArray$.prototype, 'get', {
1350 value: $TypedArray$.prototype._getter
1351 });
1352
1353 // WebIDL: setter void (unsigned long index, type value);
1354 Object.defineProperty($TypedArray$.prototype, '_setter', {
1355 value: function(index, value) {
1356 if (arguments.length < 2)
1357 throw SyntaxError('Not enough arguments');
1358
1359 index = ToUint32(index);
1360 if (index >= this.length)
1361 return;
1362
1363 var bytes = this._pack(value), i, o;
1364 for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT;
1365 i < this.BYTES_PER_ELEMENT;
1366 i += 1, o += 1) {
1367 this.buffer._bytes[o] = bytes[i];
1368 }
1369 }
1370 });
1371
1372 // get %TypedArray%.prototype.buffer
1373 // get %TypedArray%.prototype.byteLength
1374 // get %TypedArray%.prototype.byteOffset
1375 // -- applied directly to the object in the constructor
1376
1377 // %TypedArray%.prototype.constructor
1378 Object.defineProperty($TypedArray$.prototype, 'constructor', {
1379 value: $TypedArray$
1380 });
1381
1382 // %TypedArray%.prototype.copyWithin (target, start, end = this.length )
1383 Object.defineProperty($TypedArray$.prototype, 'copyWithin', {
1384 value: function(target, start) {
1385 var end = arguments[2];
1386
1387 var o = ToObject(this);
1388 var lenVal = o.length;
1389 var len = ToUint32(lenVal);
1390 len = max(len, 0);
1391 var relativeTarget = ToInt32(target);
1392 var to;
1393 if (relativeTarget < 0)
1394 to = max(len + relativeTarget, 0);
1395 else
1396 to = min(relativeTarget, len);
1397 var relativeStart = ToInt32(start);
1398 var from;
1399 if (relativeStart < 0)
1400 from = max(len + relativeStart, 0);
1401 else
1402 from = min(relativeStart, len);
1403 var relativeEnd;
1404 if (end === undefined)
1405 relativeEnd = len;
1406 else
1407 relativeEnd = ToInt32(end);
1408 var final;
1409 if (relativeEnd < 0)
1410 final = max(len + relativeEnd, 0);
1411 else
1412 final = min(relativeEnd, len);
1413 var count = min(final - from, len - to);
1414 var direction;
1415 if (from < to && to < from + count) {
1416 direction = - 1;
1417 from = from + count - 1;
1418 to = to + count - 1;
1419 } else {
1420 direction = 1;
1421 }
1422 while (count > 0) {
1423 o._setter(to, o._getter(from));
1424 from = from + direction;
1425 to = to + direction;
1426 count = count - 1;
1427 }
1428 return o;
1429 }
1430 });
1431
1432 // %TypedArray%.prototype.entries ( )
1433 // -- defined in es6.js to shim browsers w/ native TypedArrays
1434
1435 // %TypedArray%.prototype.every ( callbackfn, thisArg = undefined )
1436 Object.defineProperty($TypedArray$.prototype, 'every', {
1437 value: function(callbackfn) {
1438 if (this === undefined || this === null)
1439 throw TypeError();
1440 var t = Object(this);
1441 var len = ToUint32(t.length);
1442 if (!IsCallable(callbackfn))
1443 throw TypeError();
1444 var thisArg = arguments[1];
1445 for (var i = 0; i < len; i++) {
1446 if (!callbackfn.call(thisArg, t._getter(i), i, t))
1447 return false;
1448 }
1449 return true;
1450 }
1451 });
1452
1453 // %TypedArray%.prototype.fill (value, start = 0, end = this.length )
1454 Object.defineProperty($TypedArray$.prototype, 'fill', {
1455 value: function(value) {
1456 var start = arguments[1],
1457 end = arguments[2];
1458
1459 var o = ToObject(this);
1460 var lenVal = o.length;
1461 var len = ToUint32(lenVal);
1462 len = max(len, 0);
1463 var relativeStart = ToInt32(start);
1464 var k;
1465 if (relativeStart < 0)
1466 k = max((len + relativeStart), 0);
1467 else
1468 k = min(relativeStart, len);
1469 var relativeEnd;
1470 if (end === undefined)
1471 relativeEnd = len;
1472 else
1473 relativeEnd = ToInt32(end);
1474 var final;
1475 if (relativeEnd < 0)
1476 final = max((len + relativeEnd), 0);
1477 else
1478 final = min(relativeEnd, len);
1479 while (k < final) {
1480 o._setter(k, value);
1481 k += 1;
1482 }
1483 return o;
1484 }
1485 });
1486
1487 // %TypedArray%.prototype.filter ( callbackfn, thisArg = undefined )
1488 Object.defineProperty($TypedArray$.prototype, 'filter', {
1489 value: function(callbackfn) {
1490 if (this === undefined || this === null)
1491 throw TypeError();
1492 var t = Object(this);
1493 var len = ToUint32(t.length);
1494 if (!IsCallable(callbackfn))
1495 throw TypeError();
1496 var res = [];
1497 var thisp = arguments[1];
1498 for (var i = 0; i < len; i++) {
1499 var val = t._getter(i); // in case fun mutates this
1500 if (callbackfn.call(thisp, val, i, t))
1501 res.push(val);
1502 }
1503 return new this.constructor(res);
1504 }
1505 });
1506
1507 // %TypedArray%.prototype.find (predicate, thisArg = undefined)
1508 Object.defineProperty($TypedArray$.prototype, 'find', {
1509 value: function(predicate) {
1510 var o = ToObject(this);
1511 var lenValue = o.length;
1512 var len = ToUint32(lenValue);
1513 if (!IsCallable(predicate))
1514 throw TypeError();
1515 var t = arguments.length > 1 ? arguments[1] : undefined;
1516 var k = 0;
1517 while (k < len) {
1518 var kValue = o._getter(k);
1519 var testResult = predicate.call(t, kValue, k, o);
1520 if (Boolean(testResult))
1521 return kValue;
1522 ++k;
1523 }
1524 return undefined;
1525 }
1526 });
1527
1528 // %TypedArray%.prototype.findIndex ( predicate, thisArg = undefined )
1529 Object.defineProperty($TypedArray$.prototype, 'findIndex', {
1530 value: function(predicate) {
1531 var o = ToObject(this);
1532 var lenValue = o.length;
1533 var len = ToUint32(lenValue);
1534 if (!IsCallable(predicate))
1535 throw TypeError();
1536 var t = arguments.length > 1 ? arguments[1] : undefined;
1537 var k = 0;
1538 while (k < len) {
1539 var kValue = o._getter(k);
1540 var testResult = predicate.call(t, kValue, k, o);
1541 if (Boolean(testResult))
1542 return k;
1543 ++k;
1544 }
1545 return - 1;
1546 }
1547 });
1548
1549 // %TypedArray%.prototype.forEach ( callbackfn, thisArg = undefined )
1550 Object.defineProperty($TypedArray$.prototype, 'forEach', {
1551 value: function(callbackfn) {
1552 if (this === undefined || this === null)
1553 throw TypeError();
1554 var t = Object(this);
1555 var len = ToUint32(t.length);
1556 if (!IsCallable(callbackfn))
1557 throw TypeError();
1558 var thisp = arguments[1];
1559 for (var i = 0; i < len; i++)
1560 callbackfn.call(thisp, t._getter(i), i, t);
1561 }
1562 });
1563
1564 // %TypedArray%.prototype.indexOf (searchElement, fromIndex = 0 )
1565 Object.defineProperty($TypedArray$.prototype, 'indexOf', {
1566 value: function(searchElement) {
1567 if (this === undefined || this === null)
1568 throw TypeError();
1569 var t = Object(this);
1570 var len = ToUint32(t.length);
1571 if (len === 0)
1572 return - 1;
1573 var n = 0;
1574 if (arguments.length > 0) {
1575 n = Number(arguments[1]);
1576 if (n !== n) {
1577 n = 0;
1578 } else if (n !== 0 && n !== (1 / 0) && n !== - (1 / 0)) {
1579 n = (n > 0 || - 1) * floor(abs(n));
1580 }
1581 }
1582 if (n >= len)
1583 return - 1;
1584 var k = n >= 0 ? n : max(len - abs(n), 0);
1585 for (; k < len; k++) {
1586 if (t._getter(k) === searchElement) {
1587 return k;
1588 }
1589 }
1590 return - 1;
1591 }
1592 });
1593
1594 // %TypedArray%.prototype.join ( separator )
1595 Object.defineProperty($TypedArray$.prototype, 'join', {
1596 value: function(separator) {
1597 if (this === undefined || this === null)
1598 throw TypeError();
1599 var t = Object(this);
1600 var len = ToUint32(t.length);
1601 var tmp = Array(len);
1602 for (var i = 0; i < len; ++i)
1603 tmp[i] = t._getter(i);
1604 return tmp.join(separator === undefined ? ',' : separator); // Hack for IE7
1605 }
1606 });
1607
1608 // %TypedArray%.prototype.keys ( )
1609 // -- defined in es6.js to shim browsers w/ native TypedArrays
1610
1611 // %TypedArray%.prototype.lastIndexOf ( searchElement, fromIndex = this.length-1 )
1612 Object.defineProperty($TypedArray$.prototype, 'lastIndexOf', {
1613 value: function(searchElement) {
1614 if (this === undefined || this === null)
1615 throw TypeError();
1616 var t = Object(this);
1617 var len = ToUint32(t.length);
1618 if (len === 0)
1619 return - 1;
1620 var n = len;
1621 if (arguments.length > 1) {
1622 n = Number(arguments[1]);
1623 if (n !== n) {
1624 n = 0;
1625 } else if (n !== 0 && n !== (1 / 0) && n !== - (1 / 0)) {
1626 n = (n > 0 || - 1) * floor(abs(n));
1627 }
1628 }
1629 var k = n >= 0 ? min(n, len - 1) : len - abs(n);
1630 for (; k >= 0; k--) {
1631 if (t._getter(k) === searchElement)
1632 return k;
1633 }
1634 return - 1;
1635 }
1636 });
1637
1638 // get %TypedArray%.prototype.length
1639 // -- applied directly to the object in the constructor
1640
1641 // %TypedArray%.prototype.map ( callbackfn, thisArg = undefined )
1642 Object.defineProperty($TypedArray$.prototype, 'map', {
1643 value: function(callbackfn) {
1644 if (this === undefined || this === null)
1645 throw TypeError();
1646 var t = Object(this);
1647 var len = ToUint32(t.length);
1648 if (!IsCallable(callbackfn))
1649 throw TypeError();
1650 var res = [];
1651 res.length = len;
1652 var thisp = arguments[1];
1653 for (var i = 0; i < len; i++)
1654 res[i] = callbackfn.call(thisp, t._getter(i), i, t);
1655 return new this.constructor(res);
1656 }
1657 });
1658
1659 // %TypedArray%.prototype.reduce ( callbackfn [, initialValue] )
1660 Object.defineProperty($TypedArray$.prototype, 'reduce', {
1661 value: function(callbackfn) {
1662 if (this === undefined || this === null)
1663 throw TypeError();
1664 var t = Object(this);
1665 var len = ToUint32(t.length);
1666 if (!IsCallable(callbackfn))
1667 throw TypeError();
1668 // no value to return if no initial value and an empty array
1669 if (len === 0 && arguments.length === 1)
1670 throw TypeError();
1671 var k = 0;
1672 var accumulator;
1673 if (arguments.length >= 2) {
1674 accumulator = arguments[1];
1675 } else {
1676 accumulator = t._getter(k++);
1677 }
1678 while (k < len) {
1679 accumulator = callbackfn.call(undefined, accumulator, t._getter(k), k, t);
1680 k++;
1681 }
1682 return accumulator;
1683 }
1684 });
1685
1686 // %TypedArray%.prototype.reduceRight ( callbackfn [, initialValue] )
1687 Object.defineProperty($TypedArray$.prototype, 'reduceRight', {
1688 value: function(callbackfn) {
1689 if (this === undefined || this === null)
1690 throw TypeError();
1691 var t = Object(this);
1692 var len = ToUint32(t.length);
1693 if (!IsCallable(callbackfn))
1694 throw TypeError();
1695 // no value to return if no initial value, empty array
1696 if (len === 0 && arguments.length === 1)
1697 throw TypeError();
1698 var k = len - 1;
1699 var accumulator;
1700 if (arguments.length >= 2) {
1701 accumulator = arguments[1];
1702 } else {
1703 accumulator = t._getter(k--);
1704 }
1705 while (k >= 0) {
1706 accumulator = callbackfn.call(undefined, accumulator, t._getter(k), k, t);
1707 k--;
1708 }
1709 return accumulator;
1710 }
1711 });
1712
1713 // %TypedArray%.prototype.reverse ( )
1714 Object.defineProperty($TypedArray$.prototype, 'reverse', {
1715 value: function() {
1716 if (this === undefined || this === null)
1717 throw TypeError();
1718 var t = Object(this);
1719 var len = ToUint32(t.length);
1720 var half = floor(len / 2);
1721 for (var i = 0, j = len - 1; i < half; ++i, --j) {
1722 var tmp = t._getter(i);
1723 t._setter(i, t._getter(j));
1724 t._setter(j, tmp);
1725 }
1726 return t;
1727 }
1728 });
1729
1730 // %TypedArray%.prototype.set(array, offset = 0 )
1731 // %TypedArray%.prototype.set(typedArray, offset = 0 )
1732 // WebIDL: void set(TypedArray array, optional unsigned long offset);
1733 // WebIDL: void set(sequence<type> array, optional unsigned long offset);
1734 Object.defineProperty($TypedArray$.prototype, 'set', {
1735 value: function(index, value) {
1736 if (arguments.length < 1)
1737 throw SyntaxError('Not enough arguments');
1738 var array, sequence, offset, len,
1739 i, s, d,
1740 byteOffset, byteLength, tmp;
1741
1742 if (typeof arguments[0] === 'object' && arguments[0].constructor === this.constructor) {
1743 // void set(TypedArray array, optional unsigned long offset);
1744 array = arguments[0];
1745 offset = ToUint32(arguments[1]);
1746
1747 if (offset + array.length > this.length) {
1748 throw RangeError('Offset plus length of array is out of range');
1749 }
1750
1751 byteOffset = this.byteOffset + offset * this.BYTES_PER_ELEMENT;
1752 byteLength = array.length * this.BYTES_PER_ELEMENT;
1753
1754 if (array.buffer === this.buffer) {
1755 tmp = [];
1756 for (i = 0, s = array.byteOffset; i < byteLength; i += 1, s += 1) {
1757 tmp[i] = array.buffer._bytes[s];
1758 }
1759 for (i = 0, d = byteOffset; i < byteLength; i += 1, d += 1) {
1760 this.buffer._bytes[d] = tmp[i];
1761 }
1762 } else {
1763 for (i = 0, s = array.byteOffset, d = byteOffset;
1764 i < byteLength; i += 1, s += 1, d += 1) {
1765 this.buffer._bytes[d] = array.buffer._bytes[s];
1766 }
1767 }
1768 } else if (typeof arguments[0] === 'object' && typeof arguments[0].length !== 'undefined') {
1769 // void set(sequence<type> array, optional unsigned long offset);
1770 sequence = arguments[0];
1771 len = ToUint32(sequence.length);
1772 offset = ToUint32(arguments[1]);
1773
1774 if (offset + len > this.length) {
1775 throw RangeError('Offset plus length of array is out of range');
1776 }
1777
1778 for (i = 0; i < len; i += 1) {
1779 s = sequence[i];
1780 this._setter(offset + i, Number(s));
1781 }
1782 } else {
1783 throw TypeError('Unexpected argument type(s)');
1784 }
1785 }
1786 });
1787
1788 // %TypedArray%.prototype.slice ( start, end )
1789 Object.defineProperty($TypedArray$.prototype, 'slice', {
1790 value: function(start, end) {
1791 var o = ToObject(this);
1792 var lenVal = o.length;
1793 var len = ToUint32(lenVal);
1794 var relativeStart = ToInt32(start);
1795 var k = (relativeStart < 0) ? max(len + relativeStart, 0) : min(relativeStart, len);
1796 var relativeEnd = (end === undefined) ? len : ToInt32(end);
1797 var final = (relativeEnd < 0) ? max(len + relativeEnd, 0) : min(relativeEnd, len);
1798 var count = final - k;
1799 var c = o.constructor;
1800 var a = new c(count);
1801 var n = 0;
1802 while (k < final) {
1803 var kValue = o._getter(k);
1804 a._setter(n, kValue);
1805 ++k;
1806 ++n;
1807 }
1808 return a;
1809 }
1810 });
1811
1812 // %TypedArray%.prototype.some ( callbackfn, thisArg = undefined )
1813 Object.defineProperty($TypedArray$.prototype, 'some', {
1814 value: function(callbackfn) {
1815 if (this === undefined || this === null)
1816 throw TypeError();
1817 var t = Object(this);
1818 var len = ToUint32(t.length);
1819 if (!IsCallable(callbackfn))
1820 throw TypeError();
1821 var thisp = arguments[1];
1822 for (var i = 0; i < len; i++) {
1823 if (callbackfn.call(thisp, t._getter(i), i, t)) {
1824 return true;
1825 }
1826 }
1827 return false;
1828 }
1829 });
1830
1831 // %TypedArray%.prototype.sort ( comparefn )
1832 Object.defineProperty($TypedArray$.prototype, 'sort', {
1833 value: function(comparefn) {
1834 if (this === undefined || this === null)
1835 throw TypeError();
1836 var t = Object(this);
1837 var len = ToUint32(t.length);
1838 var tmp = Array(len);
1839 for (var i = 0; i < len; ++i)
1840 tmp[i] = t._getter(i);
1841 function sortCompare(x, y) {
1842 if (x !== x && y !== y)
1843 return + 0;
1844 if (x !== x)
1845 return 1;
1846 if (y !== y)
1847 return - 1;
1848 if (comparefn !== undefined) {
1849 return comparefn(x, y);
1850 }
1851 if (x < y)
1852 return - 1;
1853 if (x > y)
1854 return 1;
1855 return + 0;
1856 }
1857 tmp.sort(sortCompare);
1858 for (i = 0; i < len; ++i)
1859 t._setter(i, tmp[i]);
1860 return t;
1861 }
1862 });
1863
1864 // %TypedArray%.prototype.subarray(begin = 0, end = this.length )
1865 // WebIDL: TypedArray subarray(long begin, optional long end);
1866 Object.defineProperty($TypedArray$.prototype, 'subarray', {
1867 value: function(start, end) {
1868 function clamp(v, min, max) {
1869 return v < min ? min : v > max ? max : v;
1870 }
1871
1872 start = ToInt32(start);
1873 end = ToInt32(end);
1874
1875 if (arguments.length < 1) {
1876 start = 0;
1877 }
1878 if (arguments.length < 2) {
1879 end = this.length;
1880 }
1881
1882 if (start < 0) {
1883 start = this.length + start;
1884 }
1885 if (end < 0) {
1886 end = this.length + end;
1887 }
1888
1889 start = clamp(start, 0, this.length);
1890 end = clamp(end, 0, this.length);
1891
1892 var len = end - start;
1893 if (len < 0) {
1894 len = 0;
1895 }
1896
1897 return new this.constructor(
1898 this.buffer, this.byteOffset + start * this.BYTES_PER_ELEMENT, len);
1899 }
1900 });
1901
1902 // %TypedArray%.prototype.toLocaleString ( )
1903 // %TypedArray%.prototype.toString ( )
1904 // %TypedArray%.prototype.values ( )
1905 // %TypedArray%.prototype [ @@iterator ] ( )
1906 // get %TypedArray%.prototype [ @@toStringTag ]
1907 // -- defined in es6.js to shim browsers w/ native TypedArrays
1908
1909 function makeTypedArray(elementSize, pack, unpack) {
1910 // Each TypedArray type requires a distinct constructor instance with
1911 // identical logic, which this produces.
1912 var TypedArray = function() {
1913 Object.defineProperty(this, 'constructor', {
1914 value: TypedArray
1915 });
1916 $TypedArray$.apply(this, arguments);
1917 makeArrayAccessors(this);
1918 };
1919 if ('__proto__' in TypedArray) {
1920 TypedArray.__proto__ = $TypedArray$;
1921 } else {
1922 TypedArray.from = $TypedArray$.from;
1923 TypedArray.of = $TypedArray$.of;
1924 }
1925
1926 TypedArray.BYTES_PER_ELEMENT = elementSize;
1927
1928 var TypedArrayPrototype = function() {};
1929 TypedArrayPrototype.prototype = $TypedArrayPrototype$;
1930
1931 TypedArray.prototype = new TypedArrayPrototype();
1932
1933 Object.defineProperty(TypedArray.prototype, 'BYTES_PER_ELEMENT', {
1934 value: elementSize
1935 });
1936 Object.defineProperty(TypedArray.prototype, '_pack', {
1937 value: pack
1938 });
1939 Object.defineProperty(TypedArray.prototype, '_unpack', {
1940 value: unpack
1941 });
1942
1943 return TypedArray;
1944 }
1945
1946 var Int8Array = makeTypedArray(1, packI8, unpackI8);
1947 var Uint8Array = makeTypedArray(1, packU8, unpackU8);
1948 var Uint8ClampedArray = makeTypedArray(1, packU8Clamped, unpackU8);
1949 var Int16Array = makeTypedArray(2, packI16, unpackI16);
1950 var Uint16Array = makeTypedArray(2, packU16, unpackU16);
1951 var Int32Array = makeTypedArray(4, packI32, unpackI32);
1952 var Uint32Array = makeTypedArray(4, packU32, unpackU32);
1953 var Float32Array = makeTypedArray(4, packF32, unpackF32);
1954 var Float64Array = makeTypedArray(8, packF64, unpackF64);
1955
1956 global.Int8Array = global.Int8Array || Int8Array;
1957 global.Uint8Array = global.Uint8Array || Uint8Array;
1958 global.Uint8ClampedArray = global.Uint8ClampedArray || Uint8ClampedArray;
1959 global.Int16Array = global.Int16Array || Int16Array;
1960 global.Uint16Array = global.Uint16Array || Uint16Array;
1961 global.Int32Array = global.Int32Array || Int32Array;
1962 global.Uint32Array = global.Uint32Array || Uint32Array;
1963 global.Float32Array = global.Float32Array || Float32Array;
1964 global.Float64Array = global.Float64Array || Float64Array;
1965 }());
1966
1967 //
1968 // 6 The DataView View Type
1969 //
1970
1971 (function() {
1972 function r(array, index) {
1973 return IsCallable(array.get) ? array.get(index) : array[index];
1974 }
1975
1976 var IS_BIG_ENDIAN = (function() {
1977 var u16array = new Uint16Array([0x1234]),
1978 u8array = new Uint8Array(u16array.buffer);
1979 return r(u8array, 0) === 0x12;
1980 }());
1981
1982 // DataView(buffer, byteOffset=0, byteLength=undefined)
1983 // WebIDL: Constructor(ArrayBuffer buffer,
1984 // optional unsigned long byteOffset,
1985 // optional unsigned long byteLength)
1986 function DataView(buffer, byteOffset, byteLength) {
1987 if (!(buffer instanceof ArrayBuffer || Class(buffer) === 'ArrayBuffer'))
1988 throw TypeError();
1989
1990 byteOffset = ToUint32(byteOffset);
1991 if (byteOffset > buffer.byteLength)
1992 throw RangeError('byteOffset out of range');
1993
1994 if (byteLength === undefined)
1995 byteLength = buffer.byteLength - byteOffset;
1996 else
1997 byteLength = ToUint32(byteLength);
1998
1999 if ((byteOffset + byteLength) > buffer.byteLength)
2000 throw RangeError('byteOffset and length reference an area beyond the end of the buffer');
2001
2002 Object.defineProperty(this, 'buffer', {
2003 value: buffer
2004 });
2005 Object.defineProperty(this, 'byteLength', {
2006 value: byteLength
2007 });
2008 Object.defineProperty(this, 'byteOffset', {
2009 value: byteOffset
2010 });
2011 };
2012
2013 // get DataView.prototype.buffer
2014 // get DataView.prototype.byteLength
2015 // get DataView.prototype.byteOffset
2016 // -- applied directly to instances by the constructor
2017
2018 function makeGetter(arrayType) {
2019 return function GetViewValue(byteOffset, littleEndian) {
2020 byteOffset = ToUint32(byteOffset);
2021
2022 if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength)
2023 throw RangeError('Array index out of range');
2024
2025 byteOffset += this.byteOffset;
2026
2027 var uint8Array = new Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT),
2028 bytes = [];
2029 for (var i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1)
2030 bytes.push(r(uint8Array, i));
2031
2032 if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN))
2033 bytes.reverse();
2034
2035 return r(new arrayType(new Uint8Array(bytes).buffer), 0);
2036 };
2037 }
2038
2039 Object.defineProperty(DataView.prototype, 'getUint8', {
2040 value: makeGetter(Uint8Array)
2041 });
2042 Object.defineProperty(DataView.prototype, 'getInt8', {
2043 value: makeGetter(Int8Array)
2044 });
2045 Object.defineProperty(DataView.prototype, 'getUint16', {
2046 value: makeGetter(Uint16Array)
2047 });
2048 Object.defineProperty(DataView.prototype, 'getInt16', {
2049 value: makeGetter(Int16Array)
2050 });
2051 Object.defineProperty(DataView.prototype, 'getUint32', {
2052 value: makeGetter(Uint32Array)
2053 });
2054 Object.defineProperty(DataView.prototype, 'getInt32', {
2055 value: makeGetter(Int32Array)
2056 });
2057 Object.defineProperty(DataView.prototype, 'getFloat32', {
2058 value: makeGetter(Float32Array)
2059 });
2060 Object.defineProperty(DataView.prototype, 'getFloat64', {
2061 value: makeGetter(Float64Array)
2062 });
2063
2064 function makeSetter(arrayType) {
2065 return function SetViewValue(byteOffset, value, littleEndian) {
2066 byteOffset = ToUint32(byteOffset);
2067 if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength)
2068 throw RangeError('Array index out of range');
2069
2070 // Get bytes
2071 var typeArray = new arrayType([value]),
2072 byteArray = new Uint8Array(typeArray.buffer),
2073 bytes = [], i, byteView;
2074
2075 for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1)
2076 bytes.push(r(byteArray, i));
2077
2078 // Flip if necessary
2079 if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN))
2080 bytes.reverse();
2081
2082 // Write them
2083 byteView = new Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT);
2084 byteView.set(bytes);
2085 };
2086 }
2087
2088 Object.defineProperty(DataView.prototype, 'setUint8', {
2089 value: makeSetter(Uint8Array)
2090 });
2091 Object.defineProperty(DataView.prototype, 'setInt8', {
2092 value: makeSetter(Int8Array)
2093 });
2094 Object.defineProperty(DataView.prototype, 'setUint16', {
2095 value: makeSetter(Uint16Array)
2096 });
2097 Object.defineProperty(DataView.prototype, 'setInt16', {
2098 value: makeSetter(Int16Array)
2099 });
2100 Object.defineProperty(DataView.prototype, 'setUint32', {
2101 value: makeSetter(Uint32Array)
2102 });
2103 Object.defineProperty(DataView.prototype, 'setInt32', {
2104 value: makeSetter(Int32Array)
2105 });
2106 Object.defineProperty(DataView.prototype, 'setFloat32', {
2107 value: makeSetter(Float32Array)
2108 });
2109 Object.defineProperty(DataView.prototype, 'setFloat64', {
2110 value: makeSetter(Float64Array)
2111 });
2112
2113 global.DataView = global.DataView || DataView;
2114
2115 }());
2116
2117 }(self));
2118 if (!("defineProperty"in Object && function() {
2119 try {
2120 var e = {}
2121 return Object.defineProperty(e, "test", {
2122 value: 42
2123 }), !0
2124 } catch (t) {
2125 return !1
2126 }
2127 }()
2128 )) {
2129
2130 // Object.defineProperty
2131 (function (nativeDefineProperty) {
2132
2133 var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
2134 var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
2135 var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
2136
2137 // Polyfill.io - This does not use CreateMethodProperty because our CreateMethodProperty function uses Object.defineProperty.
2138 Object['defineProperty'] = function defineProperty(object, property, descriptor) {
2139
2140 // Where native support exists, assume it
2141 if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
2142 return nativeDefineProperty(object, property, descriptor);
2143 }
2144
2145 if (object === null || !(object instanceof Object || typeof object === 'object')) {
2146 throw new TypeError('Object.defineProperty called on non-object');
2147 }
2148
2149 if (!(descriptor instanceof Object)) {
2150 throw new TypeError('Property description must be an object');
2151 }
2152
2153 var propertyString = String(property);
2154 var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
2155 var getterType = 'get' in descriptor && typeof descriptor.get;
2156 var setterType = 'set' in descriptor && typeof descriptor.set;
2157
2158 // handle descriptor.get
2159 if (getterType) {
2160 if (getterType !== 'function') {
2161 throw new TypeError('Getter must be a function');
2162 }
2163 if (!supportsAccessors) {
2164 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
2165 }
2166 if (hasValueOrWritable) {
2167 throw new TypeError(ERR_VALUE_ACCESSORS);
2168 }
2169 Object.__defineGetter__.call(object, propertyString, descriptor.get);
2170 } else {
2171 object[propertyString] = descriptor.value;
2172 }
2173
2174 // handle descriptor.set
2175 if (setterType) {
2176 if (setterType !== 'function') {
2177 throw new TypeError('Setter must be a function');
2178 }
2179 if (!supportsAccessors) {
2180 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
2181 }
2182 if (hasValueOrWritable) {
2183 throw new TypeError(ERR_VALUE_ACCESSORS);
2184 }
2185 Object.__defineSetter__.call(object, propertyString, descriptor.set);
2186 }
2187
2188 // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
2189 if ('value' in descriptor) {
2190 object[propertyString] = descriptor.value;
2191 }
2192
2193 return object;
2194 };
2195 }(Object.defineProperty));
2196
2197 }
2198
2199
2200 // _ESAbstract.CreateDataProperty
2201 // 7.3.4. CreateDataProperty ( O, P, V )
2202 // NOTE
2203 // This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator.
2204 // 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.
2205 function CreateDataProperty(O, P, V) {
2206 // eslint-disable-line no-unused-vars
2207 // 1. Assert: Type(O) is Object.
2208 // 2. Assert: IsPropertyKey(P) is true.
2209 // 3. Let newDesc be the PropertyDescriptor{ [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.
2210 var newDesc = {
2211 value: V,
2212 writable: true,
2213 enumerable: true,
2214 configurable: true
2215 };
2216 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
2217 try {
2218 Object.defineProperty(O, P, newDesc);
2219 return true;
2220 } catch (e) {
2221 return false;
2222 }
2223 }
2224
2225 // _ESAbstract.CreateDataPropertyOrThrow
2226 /* global CreateDataProperty */
2227 // 7.3.6. CreateDataPropertyOrThrow ( O, P, V )
2228 function CreateDataPropertyOrThrow(O, P, V) {
2229 // eslint-disable-line no-unused-vars
2230 // 1. Assert: Type(O) is Object.
2231 // 2. Assert: IsPropertyKey(P) is true.
2232 // 3. Let success be ? CreateDataProperty(O, P, V).
2233 var success = CreateDataProperty(O, P, V);
2234 // 4. If success is false, throw a TypeError exception.
2235 if (!success) {
2236 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) + '`');
2237 }
2238 // 5. Return success.
2239 return success;
2240 }
2241
2242 // _ESAbstract.CreateIterResultObject
2243 /* global Type, CreateDataProperty */
2244 // 7.4.7. CreateIterResultObject ( value, done )
2245 function CreateIterResultObject(value, done) {
2246 // eslint-disable-line no-unused-vars
2247 // 1. Assert: Type(done) is Boolean.
2248 if (Type(done) !== 'boolean') {
2249 throw new Error();
2250 }
2251 // 2. Let obj be ObjectCreate(%ObjectPrototype%).
2252 var obj = {};
2253 // 3. Perform CreateDataProperty(obj, "value", value).
2254 CreateDataProperty(obj, "value", value);
2255 // 4. Perform CreateDataProperty(obj, "done", done).
2256 CreateDataProperty(obj, "done", done);
2257 // 5. Return obj.
2258 return obj;
2259 }
2260
2261 // _ESAbstract.CreateMethodProperty
2262 // 7.3.5. CreateMethodProperty ( O, P, V )
2263 function CreateMethodProperty(O, P, V) {
2264 // eslint-disable-line no-unused-vars
2265 // 1. Assert: Type(O) is Object.
2266 // 2. Assert: IsPropertyKey(P) is true.
2267 // 3. Let newDesc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}.
2268 var newDesc = {
2269 value: V,
2270 writable: true,
2271 enumerable: false,
2272 configurable: true
2273 };
2274 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
2275 Object.defineProperty(O, P, newDesc);
2276 }
2277 if (!("isArray"in Array
2278 )) {
2279
2280 // Array.isArray
2281 /* global CreateMethodProperty, IsArray */
2282 // 22.1.2.2. Array.isArray ( arg )
2283 CreateMethodProperty(Array, 'isArray', function isArray(arg) {
2284 // 1. Return ? IsArray(arg).
2285 return IsArray(arg);
2286 });
2287
2288 }
2289
2290 if (!("copyWithin"in Array.prototype && function() {
2291 try {
2292 var t = function n() {}
2293 t.prototype[0] = "foo"
2294 var o = new t
2295 o[1] = 1, o[2] = 2, o.length = 3
2296 var r = Array.prototype.copyWithin.call(o, 1, 0)
2297 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)
2298 } catch (e) {
2299 return !1
2300 }
2301 }()
2302 )) {
2303
2304 // Array.prototype.copyWithin
2305 /* global CreateMethodProperty, HasProperty, ToInteger */
2306 // 22.1.3.3 Array.prototype.copyWithin ( target, start [ , end ] )
2307 CreateMethodProperty(Array.prototype, 'copyWithin', function copyWithin(target, start /* [ , end ] */
2308 ) {
2309 'use strict';
2310 var end = arguments[2];
2311
2312 // 22.1.3.3.1 Let O be ? ToObject(this value).
2313 if (this === null || this === undefined) {
2314 throw new TypeError('Cannot call method on ' + this);
2315 }
2316
2317 var o = Object(this);
2318
2319 // 22.1.3.3.2 Let len be ? ToLength(? Get(O, "length")).
2320 var len = ToInteger(o.length);
2321 if (len <= 0) {
2322 len = 0;
2323 }
2324 if (len === Infinity) {
2325 len = Math.pow(2, 53) - 1;
2326 } else {
2327 len = Math.min(len, Math.pow(2, 53) - 1);
2328 }
2329 len = Math.max(len, 0);
2330
2331 // 22.1.3.3.3 Let relativeTarget be ? ToInteger(target).
2332 var relativeTarget = ToInteger(target);
2333
2334 // 22.1.3.3.4 If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let to be min(relativeTarget, len).
2335 var to;
2336 if (relativeTarget < 0) {
2337 to = Math.max(len + relativeTarget, 0);
2338 } else {
2339 to = Math.min(relativeTarget, len);
2340 }
2341
2342 // 22.1.3.3.5 Let relativeStart be ? ToInteger(start).
2343 var relativeStart = ToInteger(start);
2344
2345 // 22.1.3.3.6 If relativeStart < 0, let from be max((len + relativeStart), 0); else let from be min(relativeStart, len).
2346 var from;
2347 if (relativeStart < 0) {
2348 from = Math.max(len + relativeStart, 0);
2349 } else {
2350 from = Math.min(relativeStart, len);
2351 }
2352
2353 // 22.1.3.3.7 If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
2354 var relativeEnd;
2355 if (end === undefined) {
2356 relativeEnd = len;
2357 } else {
2358 relativeEnd = ToInteger(end);
2359 }
2360
2361 // 22.1.3.3.8 If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
2362 var final;
2363 if (relativeEnd < 0) {
2364 final = Math.max(len + relativeEnd, 0);
2365 } else {
2366 final = Math.min(relativeEnd, len);
2367 }
2368
2369 // 22.1.3.3.9 Let count be min(final-from, len-to).
2370 var count = Math.min(final - from, len - to);
2371
2372 // 22.1.3.3.10 If from<to and to<from+count, then
2373 var direction;
2374 if (from < to && to < from + count) {
2375 // 22.1.3.3.10.a Let direction be -1.
2376 direction = - 1;
2377
2378 // 22.1.3.3.10.b Let from be from + count - 1.
2379 from = from + count - 1;
2380
2381 // 22.1.3.3.10.c Let to be to + count - 1.
2382 to = to + count - 1;
2383 } else {
2384 // 22.1.3.3.11 Else,
2385 // 22.1.3.3.11.a Let direction be 1.
2386 direction = 1;
2387 }
2388
2389 // 22.1.3.3.12 Repeat, while count > 0
2390 while (count > 0) {
2391 // 22.1.3.3.12.a Let fromKey be ! ToString(from).
2392 var fromKey = String(from);
2393 // 22.1.3.3.12.b Let toKey be ! ToString(to).
2394 var toKey = String(to);
2395 // 22.1.3.3.12.c Let fromPresent be ? HasProperty(O, fromKey).
2396 var fromPresent = HasProperty(o, fromKey);
2397 // 22.1.3.3.12.d If fromPresent is true, then
2398 if (fromPresent) {
2399 // 22.1.3.3.12.d.i Let fromVal be ? Get(O, fromKey).
2400 var fromVal = o[fromKey];
2401 // 22.1.3.3.12.d.ii Perform ? Set(O, toKey, fromVal, true).
2402 o[toKey] = fromVal;
2403 } else {
2404 // 22.1.3.3.12.e Else fromPresent is false,
2405 // 22.1.3.3.12.e.i Perform ? DeletePropertyOrThrow(O, toKey).
2406 delete o[toKey];
2407 }
2408 // 22.1.3.3.12.f Let from be from + direction.
2409 from = from + direction;
2410 // 22.1.3.3.12.g Let to be to + direction.
2411 to = to + direction;
2412 // 22.1.3.3.12.h Let count be count - 1.
2413 count = count - 1;
2414 }
2415 // 22.1.3.3.13 Return O.
2416 return o;
2417 });
2418
2419 }
2420
2421 if (!("fill"in Array.prototype
2422 )) {
2423
2424 // Array.prototype.fill
2425 /* global CreateMethodProperty, Get, ToInteger, ToLength, ToObject, ToString */
2426 // 22.1.3.6. Array.prototype.fill ( value [ , start [ , end ] ] )
2427 CreateMethodProperty(Array.prototype, 'fill', function fill(value /* [ , start [ , end ] ] */
2428 ) {
2429 var start = arguments[1];
2430 var end = arguments[2];
2431 // 1. Let O be ? ToObject(this value).
2432 var O = ToObject(this);
2433 // 2. Let len be ? ToLength(? Get(O, "length")).
2434 var len = ToLength(Get(O, "length"));
2435 // 3. Let relativeStart be ? ToInteger(start).
2436 var relativeStart = ToInteger(start);
2437 // 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be min(relativeStart, len)
2438 var k = relativeStart < 0 ? Math.max((len + relativeStart), 0) : Math.min(relativeStart, len);
2439 // 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
2440 var relativeEnd = end === undefined ? len : ToInteger(end);
2441 // 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
2442 var final = relativeEnd < 0 ? Math.max((len + relativeEnd), 0) : Math.min(relativeEnd, len);
2443 // 7. Repeat, while k < final
2444 while (k < final) {
2445 // a. Let Pk be ! ToString(k).
2446 var Pk = ToString(k);
2447 // b. Perform ? Set(O, Pk, value, true).
2448 O[Pk] = value;
2449 // c. Increase k by 1.
2450 k = k + 1;
2451 }
2452 // 8. Return O.
2453 return O;
2454 });
2455
2456 }
2457
2458 if (!("find"in Array.prototype
2459 )) {
2460
2461 // Array.prototype.find
2462 /* global Call, CreateMethodProperty, Get, IsCallable, ToBoolean, ToLength, ToObject, ToString */
2463 // 22.1.3.8 Array.prototype.find ( predicate [ , thisArg ] )
2464 CreateMethodProperty(Array.prototype, 'find', function find( predicate /* [ , thisArg ] */
2465 ) {
2466 // 1. Let O be ? ToObject(this value).
2467 var O = ToObject(this);
2468 // 2. Let len be ? ToLength(? Get(O, "length")).
2469 var len = ToLength(Get(O, "length"));
2470 // 3. If IsCallable(predicate) is false, throw a TypeError exception.
2471 if (IsCallable(predicate) === false) {
2472 throw new TypeError(predicate + ' is not a function');
2473 }
2474 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
2475 var T = arguments.length > 1 ? arguments[1] : undefined;
2476 // 5. Let k be 0.
2477 var k = 0;
2478 // 6. Repeat, while k < len
2479 while (k < len) {
2480 // a. Let Pk be ! ToString(k).
2481 var Pk = ToString(k);
2482 // b. Let kValue be ? Get(O, Pk).
2483 var kValue = Get(O, Pk);
2484 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
2485 var testResult = ToBoolean(Call(predicate, T, [kValue, k, O ]));
2486 // d. If testResult is true, return kValue.
2487 if (testResult) {
2488 return kValue;
2489 }
2490 // e. Increase k by 1.
2491 var k = k + 1;
2492 }
2493 // 7. Return undefined.
2494 return undefined;
2495 });
2496
2497 }
2498
2499 if (!("findIndex"in Array.prototype
2500 )) {
2501
2502 // Array.prototype.findIndex
2503 /* global Call, CreateMethodProperty, Get, IsCallable, ToBoolean, ToLength, ToObject, ToString */
2504 // 22.1.3.9. Array.prototype.findIndex ( predicate [ , thisArg ] )
2505 CreateMethodProperty(Array.prototype, 'findIndex', function findIndex(predicate /* [ , thisArg ] */
2506 ) {
2507 // 1. Let O be ? ToObject(this value).
2508 var O = ToObject(this);
2509 // 2. Let len be ? ToLength(? Get(O, "length")).
2510 var len = ToLength(Get(O, "length"));
2511 // 3. If IsCallable(predicate) is false, throw a TypeError exception.
2512 if (IsCallable(predicate) === false) {
2513 throw new TypeError(predicate + ' is not a function');
2514 }
2515 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
2516 var T = arguments.length > 1 ? arguments[1] : undefined;
2517 // 5. Let k be 0.
2518 var k = 0;
2519 // 6. Repeat, while k < len
2520 while (k < len) {
2521 // a. Let Pk be ! ToString(k).
2522 var Pk = ToString(k);
2523 // b. Let kValue be ? Get(O, Pk).
2524 var kValue = Get(O, Pk);
2525 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
2526 var testResult = ToBoolean(Call(predicate, T, [kValue, k, O]));
2527 // d. If testResult is true, return k.
2528 if (testResult) {
2529 return k;
2530 }
2531 // e. Increase k by 1.
2532 k = k + 1;
2533 }
2534 // 7. Return -1.
2535 return - 1;
2536 });
2537
2538 }
2539
2540 if (!("forEach"in Array.prototype
2541 )) {
2542
2543 // Array.prototype.forEach
2544 /* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
2545 // 22.1.3.10. Array.prototype.forEach ( callbackfn [ , thisArg ] )
2546 CreateMethodProperty(Array.prototype, 'forEach', function forEach(callbackfn /* [ , thisArg ] */
2547 ) {
2548 // 1. Let O be ? ToObject(this value).
2549 var O = ToObject(this);
2550 // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
2551 // We will use arrayLike in place of O when we are iterating through the list.
2552 var arraylike = O instanceof String ? O.split('') : O;
2553 // 2. Let len be ? ToLength(? Get(O, "length")).
2554 var len = ToLength(Get(O, "length"));
2555 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
2556 if (IsCallable(callbackfn) === false) {
2557 throw new TypeError(callbackfn + ' is not a function');
2558 }
2559 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
2560 var T = arguments.length > 1 ? arguments[1] : undefined;
2561 // 5. Let k be 0.
2562 var k = 0;
2563 // 6. Repeat, while k < len
2564 while (k < len) {
2565 // a. Let Pk be ! ToString(k).
2566 var Pk = ToString(k);
2567 // b. Let kPresent be ? HasProperty(O, Pk).
2568 var kPresent = HasProperty(arraylike, Pk);
2569 // c. If kPresent is true, then
2570 if (kPresent) {
2571 // i. Let kValue be ? Get(O, Pk).
2572 var kValue = Get(arraylike, Pk);
2573 // ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
2574 Call(callbackfn, T, [kValue, k, O]);
2575 }
2576 // d. Increase k by 1.
2577 k = k + 1;
2578 }
2579 // 7. Return undefined.
2580 return undefined;
2581 });
2582
2583 }
2584
2585 if (!("includes"in Array.prototype
2586 )) {
2587
2588 // Array.prototype.includes
2589 /* global CreateMethodProperty, Get, SameValueZero, ToInteger, ToLength, ToObject, ToString */
2590 // 22.1.3.11. Array.prototype.includes ( searchElement [ , fromIndex ] )
2591 CreateMethodProperty(Array.prototype, 'includes', function includes(searchElement /* [ , fromIndex ] */
2592 ) {
2593 'use strict';
2594 // 1. Let O be ? ToObject(this value).
2595 var O = ToObject(this);
2596 // 2. Let len be ? ToLength(? Get(O, "length")).
2597 var len = ToLength(Get(O, "length"));
2598 // 3. If len is 0, return false.
2599 if (len === 0) {
2600 return false;
2601 }
2602 // 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.)
2603 var n = ToInteger(arguments[1]);
2604 // 5. If n ≥ 0, then
2605 if (n >= 0) {
2606 // a. Let k be n.
2607 var k = n;
2608 // 6. Else n < 0,
2609 } else {
2610 // a. Let k be len + n.
2611 k = len + n;
2612 // b. If k < 0, let k be 0.
2613 if (k < 0) {
2614 k = 0;
2615 }
2616 }
2617 // 7. Repeat, while k < len
2618 while (k < len) {
2619 // a. Let elementK be the result of ? Get(O, ! ToString(k)).
2620 var elementK = Get(O, ToString(k));
2621 // b. If SameValueZero(searchElement, elementK) is true, return true.
2622 if (SameValueZero(searchElement, elementK)) {
2623 return true;
2624 }
2625 // c. Increase k by 1.
2626 k = k + 1;
2627 }
2628 // 8. Return false.
2629 return false;
2630 });
2631
2632 }
2633
2634 if (!("bind"in Function.prototype
2635 )) {
2636
2637 // Function.prototype.bind
2638 /* global CreateMethodProperty, IsCallable */
2639 // 19.2.3.2. Function.prototype.bind ( thisArg, ...args )
2640 // https://github.com/es-shims/es5-shim/blob/d6d7ff1b131c7ba14c798cafc598bb6780d37d3b/es5-shim.js#L182
2641 CreateMethodProperty(Function.prototype, 'bind', function bind(that) {
2642 // .length is 1
2643 // add necessary es5-shim utilities
2644 var $Array = Array;
2645 var $Object = Object;
2646 var ArrayPrototype = $Array.prototype;
2647 var Empty = function Empty() {};
2648 var array_slice = ArrayPrototype.slice;
2649 var array_concat = ArrayPrototype.concat;
2650 var array_push = ArrayPrototype.push;
2651 var max = Math.max;
2652 // /add necessary es5-shim utilities
2653
2654 // 1. Let Target be the this value.
2655 var target = this;
2656 // 2. If IsCallable(Target) is false, throw a TypeError exception.
2657 if (!IsCallable(target)) {
2658 throw new TypeError('Function.prototype.bind called on incompatible ' + target);
2659 }
2660 // 3. Let A be a new (possibly empty) internal list of all of the
2661 // argument values provided after thisArg (arg1, arg2 etc), in order.
2662 // XXX slicedArgs will stand in for "A" if used
2663 var args = array_slice.call(arguments, 1); // for normal call
2664 // 4. Let F be a new native ECMAScript object.
2665 // 11. Set the [[Prototype]] internal property of F to the standard
2666 // built-in Function prototype object as specified in 15.3.3.1.
2667 // 12. Set the [[Call]] internal property of F as described in
2668 // 15.3.4.5.1.
2669 // 13. Set the [[Construct]] internal property of F as described in
2670 // 15.3.4.5.2.
2671 // 14. Set the [[HasInstance]] internal property of F as described in
2672 // 15.3.4.5.3.
2673 var bound;
2674 var binder = function () {
2675
2676 if (this instanceof bound) {
2677 // 15.3.4.5.2 [[Construct]]
2678 // When the [[Construct]] internal method of a function object,
2679 // F that was created using the bind function is called with a
2680 // list of arguments ExtraArgs, the following steps are taken:
2681 // 1. Let target be the value of F's [[TargetFunction]]
2682 // internal property.
2683 // 2. If target has no [[Construct]] internal method, a
2684 // TypeError exception is thrown.
2685 // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
2686 // property.
2687 // 4. Let args be a new list containing the same values as the
2688 // list boundArgs in the same order followed by the same
2689 // values as the list ExtraArgs in the same order.
2690 // 5. Return the result of calling the [[Construct]] internal
2691 // method of target providing args as the arguments.
2692
2693 var result = target.apply(
2694 this,
2695 array_concat.call(args, array_slice.call(arguments))
2696 );
2697 if ($Object(result) === result) {
2698 return result;
2699 }
2700 return this;
2701
2702 } else {
2703 // 15.3.4.5.1 [[Call]]
2704 // When the [[Call]] internal method of a function object, F,
2705 // which was created using the bind function is called with a
2706 // this value and a list of arguments ExtraArgs, the following
2707 // steps are taken:
2708 // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
2709 // property.
2710 // 2. Let boundThis be the value of F's [[BoundThis]] internal
2711 // property.
2712 // 3. Let target be the value of F's [[TargetFunction]] internal
2713 // property.
2714 // 4. Let args be a new list containing the same values as the
2715 // list boundArgs in the same order followed by the same
2716 // values as the list ExtraArgs in the same order.
2717 // 5. Return the result of calling the [[Call]] internal method
2718 // of target providing boundThis as the this value and
2719 // providing args as the arguments.
2720
2721 // equiv: target.call(this, ...boundArgs, ...args)
2722 return target.apply(
2723 that,
2724 array_concat.call(args, array_slice.call(arguments))
2725 );
2726
2727 }
2728
2729 };
2730
2731 // 15. If the [[Class]] internal property of Target is "Function", then
2732 // a. Let L be the length property of Target minus the length of A.
2733 // b. Set the length own property of F to either 0 or L, whichever is
2734 // larger.
2735 // 16. Else set the length own property of F to 0.
2736
2737 var boundLength = max(0, target.length - args.length);
2738
2739 // 17. Set the attributes of the length own property of F to the values
2740 // specified in 15.3.5.1.
2741 var boundArgs = [];
2742 for (var i = 0; i < boundLength; i++) {
2743 array_push.call(boundArgs, '$' + i);
2744 }
2745
2746 // XXX Build a dynamic function with desired amount of arguments is the only
2747 // way to set the length property of a function.
2748 // In environments where Content Security Policies enabled (Chrome extensions,
2749 // for ex.) all use of eval or Function costructor throws an exception.
2750 // However in all of these environments Function.prototype.bind exists
2751 // and so this code will never be executed.
2752 bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
2753
2754 if (target.prototype) {
2755 Empty.prototype = target.prototype;
2756 bound.prototype = new Empty();
2757 // Clean up dangling references.
2758 Empty.prototype = null;
2759 }
2760
2761 // TODO
2762 // 18. Set the [[Extensible]] internal property of F to true.
2763
2764 // TODO
2765 // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
2766 // 20. Call the [[DefineOwnProperty]] internal method of F with
2767 // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
2768 // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
2769 // false.
2770 // 21. Call the [[DefineOwnProperty]] internal method of F with
2771 // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
2772 // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
2773 // and false.
2774
2775 // TODO
2776 // NOTE Function objects created using Function.prototype.bind do not
2777 // have a prototype property or the [[Code]], [[FormalParameters]], and
2778 // [[Scope]] internal properties.
2779 // XXX can't delete prototype in pure-js.
2780
2781 // 22. Return F.
2782 return bound;
2783 });
2784
2785 }
2786
2787 if (!("acosh"in Math
2788 )) {
2789
2790 // Math.acosh
2791 /* global CreateMethodProperty */
2792 // 20.2.2.3. Math.acosh ( x )
2793 CreateMethodProperty(Math, 'acosh', function acosh(x) {
2794 // If x is NaN, the result is NaN.
2795 if (isNaN(x)) {
2796 return NaN;
2797 }
2798 // If x is less than 1, the result is NaN.
2799 if (x < 1) {
2800 return NaN;
2801 }
2802 // If x is 1, the result is +0.
2803 if (x === 1) {
2804 return 0;
2805 }
2806 // If x is +∞, the result is +∞.
2807 if (x === Infinity) {
2808 return Infinity;
2809 }
2810 return Math.log(x + Math.sqrt(x * x - 1));
2811 });
2812
2813 }
2814
2815 if (!("asinh"in Math
2816 )) {
2817
2818 // Math.asinh
2819 /* global CreateMethodProperty */
2820 // 20.2.2.5. Math.asinh ( x )
2821 CreateMethodProperty(Math, 'asinh', function asinh(x) {
2822 // If x is NaN, the result is NaN.
2823 if (isNaN(x)) {
2824 return NaN;
2825 }
2826 // If x is +0, the result is +0.
2827 if (x === 0 && 1 / x === Infinity) {
2828 return 0;
2829 }
2830 // If x is -0, the result is -0.
2831 if (x === 0 && 1 / x === - Infinity) {
2832 return - 0;
2833 }
2834 // If x is +∞, the result is +∞.
2835 if (x === Infinity) {
2836 return Infinity;
2837 }
2838 // If x is -∞, the result is -∞.
2839 if (x === - Infinity) {
2840 return - Infinity;
2841 }
2842 return Math.log(x + Math.sqrt(x * x + 1));
2843 });
2844
2845 }
2846
2847 if (!("atanh"in Math
2848 )) {
2849
2850 // Math.atanh
2851 /* global CreateMethodProperty */
2852 // 20.2.2.7. Math.atanh ( x )
2853 CreateMethodProperty(Math, 'atanh', function atanh(x) {
2854 // If x is NaN, the result is NaN.
2855 if (isNaN(x)) {
2856 return NaN;
2857 }
2858 // If x is less than -1, the result is NaN.
2859 if (x < - 1) {
2860 return NaN;
2861 }
2862 // If x is greater than 1, the result is NaN.
2863 if (x > 1) {
2864 return NaN;
2865 }
2866 // If x is -1, the result is -∞.
2867 if (x === - 1) {
2868 return - Infinity;
2869 }
2870 // If x is +1, the result is +∞.
2871 if (x === 1) {
2872 return Infinity;
2873 }
2874 // If x is +0, the result is +0.
2875 if (x === 0 && 1 / x === Infinity) {
2876 return 0;
2877 }
2878 // If x is -0, the result is -0.
2879 if (x === 0 && 1 / x === - Infinity) {
2880 return - 0;
2881 }
2882 return Math.log((1 + x) / (1 - x)) / 2;
2883 });
2884
2885 }
2886
2887 if (!("cbrt"in Math
2888 )) {
2889
2890 // Math.cbrt
2891 /* global CreateMethodProperty */
2892 // 20.2.2.9. Math.cbrt ( x )
2893 CreateMethodProperty(Math, 'cbrt', function cbrt(x) {
2894 // If x is NaN, the result is NaN.
2895 if (isNaN(x)) {
2896 return NaN;
2897 }
2898 // If x is +0, the result is +0.
2899 if (x === 0 && 1 / x === Infinity) {
2900 return 0;
2901 }
2902 // If x is -0, the result is -0.
2903 if (x === 0 && 1 / x === - Infinity) {
2904 return - 0;
2905 }
2906 // If x is +∞, the result is +∞.
2907 if (x === Infinity) {
2908 return Infinity;
2909 }
2910 // If x is -∞, the result is -∞.
2911 if (x === - Infinity) {
2912 return - Infinity;
2913 }
2914 var y = Math.pow(Math.abs(x), 1 / 3);
2915 return x < 0 ? - y : y;
2916 });
2917
2918 }
2919
2920 if (!("clz32"in Math
2921 )) {
2922
2923 // Math.clz32
2924 /* global CreateMethodProperty, ToUint32 */
2925 // 20.2.2.11. Math.clz32 ( x )
2926 CreateMethodProperty(Math, 'clz32', function clz32(x) {
2927 // 1. Let n be ToUint32(x).
2928 var n = ToUint32(x);
2929 // 2. Let p be the number of leading zero bits in the 32-bit binary representation of n.
2930 var p = n ? 32 - n.toString(2).length : 32;
2931 // 3. Return p.
2932 return p;
2933 });
2934
2935 }
2936
2937 if (!("cosh"in Math
2938 )) {
2939
2940 // Math.cosh
2941 /* global CreateMethodProperty */
2942 // 20.2.2.1. 3Math.cosh ( x )
2943 CreateMethodProperty(Math, 'cosh', function cosh(x) {
2944 // If x is NaN, the result is NaN.
2945 if (isNaN(x)) {
2946 return NaN;
2947 }
2948 // If x is +0, the result is 1.
2949 if (x === 0 && 1 / x === Infinity) {
2950 return 1;
2951 }
2952 // If x is -0, the result is 1.
2953 if (x === 0 && 1 / x === - Infinity) {
2954 return 1;
2955 }
2956 // If x is +∞, the result is +∞.
2957 if (x === Infinity) {
2958 return Infinity;
2959 }
2960 // If x is -∞, the result is +∞.
2961 if (x === - Infinity) {
2962 return Infinity;
2963 }
2964 x = Math.abs(x);
2965 if (x > 709) {
2966 var y = Math.exp(0.5 * x);
2967 return y / 2 * y;
2968 }
2969 var y = Math.exp(x);
2970 return (y + 1 / y) / 2;
2971 });
2972
2973 }
2974
2975 if (!("expm1"in Math
2976 )) {
2977
2978 // Math.expm1
2979 /* global CreateMethodProperty */
2980 // 20.2.2.15. Math.expm1 ( x )
2981 CreateMethodProperty(Math, 'expm1', function expm1(x) {
2982 // If x is NaN, the result is NaN.
2983 if (isNaN(x)) {
2984 return NaN;
2985 }
2986 // If x is +0, the result is +0.
2987 if (x === 0 && 1 / x === Infinity) {
2988 return 0;
2989 }
2990 // If x is -0, the result is -0.
2991 if (x === 0 && 1 / x === - Infinity) {
2992 return - 0;
2993 }
2994 // If x is +∞, the result is +∞.
2995 if (x === Infinity) {
2996 return Infinity;
2997 }
2998 // If x is -∞, the result is -1.
2999 if (x === - Infinity) {
3000 return - 1;
3001 }
3002
3003 if (x > - 1e-6 && x < 1e-6) {
3004 return x + x * x / 2;
3005 } else {
3006 return Math.exp(x) - 1;
3007 }
3008 });
3009
3010 }
3011
3012 if (!("fround"in Math
3013 )) {
3014
3015 // Math.fround
3016 /* global Float32Array, CreateMethodProperty */
3017 // 20.2.2.17 Math.fround ( x )
3018 CreateMethodProperty(Math, 'fround', function (x) {
3019 // 1. If x is NaN, return NaN.
3020 if (isNaN(x)) {
3021 return NaN;
3022 }
3023 // 2. If x is one of +0, -0, +∞, -∞, return x.
3024 if (1 / x === + Infinity || 1 / x === - Infinity || x === + Infinity || x === - Infinity) {
3025 return x;
3026 }
3027 // 3. Let x32 be the result of converting x to a value in IEEE 754-2008 binary32 format using roundTiesToEven.
3028 // 4. Let x64 be the result of converting x32 to a value in IEEE 754-2008 binary64 format.
3029 // 5. Return the ECMAScript Number value corresponding to x64.
3030 return (new Float32Array([x]))[0];
3031 });
3032
3033 }
3034
3035 if (!("hypot"in Math
3036 )) {
3037
3038 // Math.hypot
3039 /* global CreateMethodProperty */
3040 // 20.2.2.18. Math.hypot ( value1, value2, ...values )
3041 CreateMethodProperty(Math, 'hypot', function hypot(value1, value2) {
3042 // eslint-disable-line no-unused-vars
3043 // If no arguments are passed, the result is +0.
3044 if (arguments.length === 0) {
3045 return 0;
3046 }
3047 var y = 0;
3048 var max = 0;
3049 for (var i = 0; i < arguments.length; ++i) {
3050 // If any argument is +∞, the result is +∞.
3051 if (arguments[i] === Infinity) {
3052 return Infinity;
3053 }
3054
3055 // If any argument is -∞, the result is +∞.
3056 if (arguments[i] === - Infinity) {
3057 return Infinity;
3058 }
3059
3060 // If no argument is +∞ or -∞, and any argument is NaN, the result is NaN.
3061 // If all arguments are either +0 or -0, the result is +0.
3062 // Polyfill.io - The two conditions above are handled in the math.
3063
3064 var arg = Math.abs(Number(arguments[i]));
3065 if (arg > max) {
3066 y = y * Math.pow(max / arg, 2);
3067 max = arg;
3068 }
3069 if (arg !== 0 || max !== 0) {
3070 y = y + Math.pow(arg / max, 2);
3071 }
3072 }
3073
3074 return max * Math.sqrt(y);
3075 });
3076
3077 }
3078
3079 if (!("imul"in Math
3080 )) {
3081
3082 // Math.imul
3083 /* global CreateMethodProperty, ToUint32 */
3084 // 20.2.2.19. Math.imul ( x, y )
3085 CreateMethodProperty(Math, 'imul', function imul(x, y) {
3086 // 1. Let a be ToUint32(x).
3087 var a = ToUint32(x);
3088 // 2. Let b be ToUint32(y).
3089 var b = ToUint32(y);
3090 var UINT16 = 0xffff;
3091 var aHigh = a >>> 16 & UINT16;
3092 var aLow = UINT16 & a;
3093 var bHigh = b >>> 16 & UINT16;
3094 var bLow = UINT16 & b;
3095 // the shift by 0 fixes the sign on the high part
3096 // the final |0 converts the unsigned value into a signed value
3097 return aLow * bLow + (aHigh * bLow + aLow * bHigh << 16 >>> 0) | 0;
3098 });
3099 }
3100
3101 if (!("log10"in Math
3102 )) {
3103
3104 // Math.log10
3105 /* global CreateMethodProperty */
3106 // 20.2.2.22. Math.log10 ( x )
3107 CreateMethodProperty(Math, 'log10', function log10(x) {
3108 return Math.log(x) / Math.LN10;
3109 });
3110
3111 }
3112
3113 if (!("log1p"in Math
3114 )) {
3115
3116 // Math.log1p
3117 /* global CreateMethodProperty */
3118 // 20.2.2.21. Math.log1p ( x )
3119 CreateMethodProperty(Math, 'log1p', function log1p(x) {
3120 x = Number(x);
3121 if ( - 1 < x && x < 1) {
3122 // Polyfill.io - For numbers in the range −1 < x < 1
3123 // Because we are using log, the precision of the result will be identical to log(1).
3124 // To fix this we avoid using log and use the Taylor Series expansion of log.
3125 // This series converges when |x| < 1. As we can not sum to infinity,
3126 // we instead sum the first 300 parts of the series to give a close approximation.
3127 // |x|<1, log(1+x) = x - x^2/2 + x^3/3 - ... + (-1)^(n-1)*x^n/n + ...
3128 var y = x;
3129 for (var i = 2; i <= 300; i++) {
3130 y += Math.pow(( - 1), (i - 1)) * Math.pow(x, i) / i;
3131 }
3132 return y;
3133 }
3134
3135 return Math.log(1 + x);
3136 });
3137 }
3138
3139 if (!("log2"in Math
3140 )) {
3141
3142 // Math.log2
3143 /* global CreateMethodProperty */
3144 // 20.2.2.23. Math.log2 ( x )
3145 CreateMethodProperty(Math, 'log2', function log2(x) {
3146 return Math.log(x) / Math.LN2;
3147 });
3148
3149 }
3150
3151 if (!("sign"in Math
3152 )) {
3153
3154 // Math.sign
3155 /* global CreateMethodProperty */
3156 // 20.2.2.29. Math.sign ( x )
3157 CreateMethodProperty(Math, 'sign', function sign(x) {
3158 var x = Number(x);
3159 // If x is NaN, the result is NaN.
3160 if (isNaN(x)) {
3161 return NaN;
3162 }
3163 // If x is -0, the result is -0.
3164 if (1 / x === - Infinity) {
3165 return - 0;
3166 }
3167 // If x is +0, the result is +0.
3168 if (1 / x === Infinity) {
3169 return 0;
3170 }
3171 // If x is negative and not -0, the result is -1.
3172 if (x < 0) {
3173 return - 1;
3174 }
3175 // If x is positive and not +0, the result is +1.
3176 if (x > 0) {
3177 return 1;
3178 }
3179 });
3180
3181 }
3182
3183 if (!("sinh"in Math
3184 )) {
3185
3186 // Math.sinh
3187 /* global CreateMethodProperty */
3188 // 20.2.2.31. Math.sinh ( x )
3189 CreateMethodProperty(Math, 'sinh', function sinh(x) {
3190 var s = (x < 0) ? - 1 : 1;
3191 var absx = Math.abs(x);
3192 if (absx < 22) {
3193 if (absx < Math.pow(2, - 28)) {
3194 return x;
3195 }
3196 var t = Math.exp(absx) - 1;
3197 if (absx < 1) {
3198 return (s * (2 * t - t * t / (t + 1))) / 2;
3199 }
3200 return (s * (t + t / (t + 1))) / 2;
3201 }
3202 if (absx < 709.7822265625) {
3203 return (s * Math.exp(absx)) / 2;
3204 }
3205 var w = Math.exp(0.5 * absx);
3206 var t = (s * w) / 2;
3207 return t * w;
3208 });
3209
3210 }
3211
3212 if (!("tanh"in Math
3213 )) {
3214
3215 // Math.tanh
3216 /* global CreateMethodProperty */
3217 // 20.2.2.34. Math.tanh ( x )
3218 CreateMethodProperty(Math, 'tanh', function tanh(x) {
3219 var y;
3220
3221 return x === Infinity ? 1 : x === - Infinity ? - 1 : (y = Math.exp(2 * x), (y - 1) / (y + 1));
3222 });
3223
3224 }
3225
3226 if (!("trunc"in Math
3227 )) {
3228
3229 // Math.trunc
3230 /* global CreateMethodProperty */
3231 CreateMethodProperty(Math, 'trunc', function trunc(x) {
3232 return x < 0 ? Math.ceil(x) : Math.floor(x);
3233 });
3234
3235 }
3236
3237 if (!("isFinite"in Number
3238 )) {
3239
3240 // Number.isFinite
3241 /* global CreateMethodProperty, Type */
3242 (function () {
3243 var that = this;
3244 // 20.1.2.2. Number.isFinite ( number )
3245 CreateMethodProperty(Number, 'isFinite', function isFinite(number) {
3246 // 1. If Type(number) is not Number, return false.
3247 if (Type(number) !== 'number') {
3248 return false;
3249 }
3250 // 2. If number is NaN, +∞, or -∞, return false.
3251 // 3. Otherwise, return true.
3252 // Polyfill.io - We use isFinite as it implements steps 2 and 3.
3253 return that.isFinite(number);
3254 });
3255 }());
3256
3257 }
3258
3259 if (!("isInteger"in Number
3260 )) {
3261
3262 // Number.isInteger
3263 /* global CreateMethodProperty, ToInteger, Type */
3264 // 20.1.2.3. Number.isInteger ( number )
3265 CreateMethodProperty(Number, 'isInteger', function isInteger(number) {
3266 // 1. If Type(number) is not Number, return false.
3267 if (Type(number) !== 'number') {
3268 return false;
3269 }
3270 // 2. If number is NaN, +∞, or -∞, return false.
3271 if (isNaN(number) || number === Infinity || number === - Infinity) {
3272 return false;
3273 }
3274 // 3. Let integer be ToInteger(number).
3275 var integer = ToInteger(number);
3276 // 4. If integer is not equal to number, return false.
3277 if (integer !== number) {
3278 return false;
3279 }
3280 // 5. Otherwise, return true.
3281 return true;
3282 });
3283
3284 }
3285
3286 if (!("isNaN"in Number
3287 )) {
3288
3289 // Number.isNaN
3290 /* global CreateMethodProperty, Type */
3291 (function () {
3292 var that = this;
3293 // 20.1.2.4. Number.isNaN ( number )
3294 CreateMethodProperty(Number, 'isNaN', function isNaN(number) {
3295 // 1. If Type(number) is not Number, return false.
3296 if (Type(number) !== 'number') {
3297 return false;
3298 }
3299 // 2. If number is NaN, return true.
3300 if (that.isNaN(number)) {
3301 return true;
3302 }
3303 // 3. Otherwise, return false.
3304 return false;
3305 });
3306 }());
3307
3308 }
3309
3310 if (!("isSafeInteger"in Number
3311 )) {
3312
3313 // Number.isSafeInteger
3314 /* global CreateMethodProperty, Type, ToInteger */
3315 // 20.1.2.5. Number.isSafeInteger ( number )
3316 CreateMethodProperty(Number, 'isSafeInteger', function isSafeInteger(number) {
3317 // 1. If Type(number) is not Number, return false.
3318 if (Type(number) !== 'number') {
3319 return false;
3320 }
3321 // 2. If number is NaN, +∞, or -∞, return false.
3322 if (isNaN(number) || number === Infinity || number === - Infinity) {
3323 return false;
3324 }
3325 // 3. Let integer be ToInteger(number).
3326 var integer = ToInteger(number);
3327 // 4. If integer is not equal to number, return false.
3328 if (integer !== number) {
3329 return false;
3330 }
3331 // 5. If abs(integer) ≤ 2^53-1, return true.
3332 if (Math.abs(integer) <= (Math.pow(2, 53) - 1)) {
3333 return true;
3334 }
3335 // 6. Otherwise, return false.
3336 return false;
3337 });
3338
3339 }
3340
3341 if (!("parseFloat"in Number
3342 )) {
3343
3344 // Number.parseFloat
3345 /* global CreateMethodProperty */
3346 // 20.1.2.12. Number.parseFloat ( string )
3347 // 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.
3348 CreateMethodProperty(Number, 'parseFloat', parseFloat);
3349
3350 }
3351
3352 if (!("parseInt"in Number
3353 )) {
3354
3355 // Number.parseInt
3356 /* global CreateMethodProperty */
3357 // 20.1.2.13. Number.parseInt ( string, radix )
3358 // 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.
3359 CreateMethodProperty(Number, 'parseInt', parseInt);
3360
3361 }
3362
3363 if (!("name"in Function.prototype && "x" === function n() {}.name
3364 )) {
3365
3366 // Function.prototype.name
3367 (function () {
3368
3369 var
3370 accessorName = 'name',
3371 fnNameMatchRegex = /^\s*function\s+([^\(\s]*)\s*/,
3372 $Function = Function,
3373 FunctionName = 'Function',
3374 FunctionProto = $Function.prototype,
3375 FunctionProtoCtor = FunctionProto.constructor,
3376 getFunctionName = function(fn) {
3377 var match, name;
3378
3379 if (fn === $Function || fn === FunctionProtoCtor) {
3380 name = FunctionName;
3381 } else if (fn !== FunctionProto) {
3382 match = ('' + fn).match(fnNameMatchRegex);
3383 name = match && match[1];
3384 }
3385 return name || '';
3386 };
3387
3388
3389 Object.defineProperty(FunctionProto, accessorName, {
3390 get: function Function$name() {
3391 var
3392 fn = this,
3393 fnName = getFunctionName(fn);
3394
3395 // Since named function definitions have immutable names, also memoize the
3396 // output by defining the `name` property directly on this Function
3397 // instance so the accessor function will not need to be invoked again.
3398 if (fn !== FunctionProto) {
3399 Object.defineProperty(fn, accessorName, {
3400 value: fnName,
3401 configurable: true
3402 });
3403 }
3404
3405 return fnName;
3406 },
3407 configurable: true
3408 });
3409
3410 }());
3411
3412 }
3413
3414 if (!("EPSILON"in Number
3415 )) {
3416
3417 // Number.Epsilon
3418 // 20.1.2.1. Number.EPSILON
3419 // 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.
3420 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
3421 Object.defineProperty(Number, 'EPSILON', {
3422 enumerable: false,
3423 configurable: false,
3424 writable: false,
3425 value: Math.pow(2, - 52)
3426 });
3427
3428 }
3429
3430 if (!("MAX_SAFE_INTEGER"in Number
3431 )) {
3432
3433 // Number.MAX_SAFE_INTEGER
3434 // 20.1.2.6. Number.MAX_SAFE_INTEGER
3435 // The value of Number.MAX_SAFE_INTEGER is 9007199254740991 (2^53-1).
3436 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
3437 Object.defineProperty(Number, 'MAX_SAFE_INTEGER', {
3438 enumerable: false,
3439 configurable: false,
3440 writable: false,
3441 value: Math.pow(2, 53) - 1
3442 });
3443
3444 }
3445
3446 if (!("MIN_SAFE_INTEGER"in Number
3447 )) {
3448
3449 // Number.MIN_SAFE_INTEGER
3450 // 20.1.2.8. Number.MIN_SAFE_INTEGER
3451 // The value of Number.MIN_SAFE_INTEGER is -9007199254740991 (-(253-1)).
3452 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
3453 Object.defineProperty(Number, 'MIN_SAFE_INTEGER', {
3454 enumerable: false,
3455 configurable: false,
3456 writable: false,
3457 value: - (Math.pow(2, 53) - 1)
3458 });
3459
3460 }
3461
3462 if (!("freeze"in Object
3463 )) {
3464
3465 // Object.freeze
3466 /* global CreateMethodProperty */
3467 // 19.1.2.6. Object.freeze ( O )
3468 CreateMethodProperty(Object, 'freeze', function freeze(O) {
3469 // This feature cannot be implemented fully as a polyfill.
3470 // We choose to silently fail which allows "securable" code
3471 // to "gracefully" degrade to working but insecure code.
3472 return O;
3473 });
3474
3475 }
3476
3477 if (!("getOwnPropertyDescriptor"in Object && "function" == typeof Object.getOwnPropertyDescriptor && function() {
3478 try {
3479 var t = {}
3480 return t.test = 0, 0 === Object.getOwnPropertyDescriptor(t, "test").value
3481 } catch (e) {
3482 return !1
3483 }
3484 }()
3485 )) {
3486
3487 // Object.getOwnPropertyDescriptor
3488 /* global CreateMethodProperty */
3489 (function () {
3490 var call = Function.prototype.call;
3491 var prototypeOfObject = Object.prototype;
3492 var owns = call.bind(prototypeOfObject.hasOwnProperty);
3493
3494 var lookupGetter;
3495 var lookupSetter;
3496 var supportsAccessors;
3497 if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
3498 lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
3499 lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
3500 }
3501 function doesGetOwnPropertyDescriptorWork(object) {
3502 try {
3503 object.sentinel = 0;
3504 return Object.getOwnPropertyDescriptor(
3505 object,
3506 "sentinel"
3507 ).value === 0;
3508 } catch (exception) {
3509 // returns falsy
3510 }
3511 }
3512 // check whether getOwnPropertyDescriptor works if it's given. Otherwise,
3513 // shim partially.
3514 if (Object.defineProperty) {
3515 var getOwnPropertyDescriptorWorksOnObject =
3516 doesGetOwnPropertyDescriptorWork({});
3517 var getOwnPropertyDescriptorWorksOnDom = typeof document == "undefined" ||
3518 doesGetOwnPropertyDescriptorWork(document.createElement("div"));
3519 if (!getOwnPropertyDescriptorWorksOnDom ||
3520 !getOwnPropertyDescriptorWorksOnObject
3521 ) {
3522 var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
3523 }
3524 }
3525
3526 if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
3527 var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
3528
3529 CreateMethodProperty(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(object, property) {
3530 if ((typeof object != "object" && typeof object != "function") || object === null) {
3531 throw new TypeError(ERR_NON_OBJECT + object);
3532 }
3533
3534 // make a valiant attempt to use the real getOwnPropertyDescriptor
3535 // for I8's DOM elements.
3536 if (getOwnPropertyDescriptorFallback) {
3537 try {
3538 return getOwnPropertyDescriptorFallback.call(Object, object, property);
3539 } catch (exception) {
3540 // try the shim if the real one doesn't work
3541 }
3542 }
3543
3544 // If object does not owns property return undefined immediately.
3545 if (!owns(object, property)) {
3546 return;
3547 }
3548
3549 // If object has a property then it's for sure both `enumerable` and
3550 // `configurable`.
3551 var descriptor = {
3552 enumerable: true,
3553 configurable: true
3554 };
3555
3556 // If JS engine supports accessor properties then property may be a
3557 // getter or setter.
3558 if (supportsAccessors) {
3559 // Unfortunately `__lookupGetter__` will return a getter even
3560 // if object has own non getter property along with a same named
3561 // inherited getter. To avoid misbehavior we temporary remove
3562 // `__proto__` so that `__lookupGetter__` will return getter only
3563 // if it's owned by an object.
3564 var prototype = object.__proto__;
3565 object.__proto__ = prototypeOfObject;
3566
3567 var getter = lookupGetter(object, property);
3568 var setter = lookupSetter(object, property);
3569
3570 // Once we have getter and setter we can put values back.
3571 object.__proto__ = prototype;
3572
3573 if (getter || setter) {
3574 if (getter) {
3575 descriptor.get = getter;
3576 }
3577 if (setter) {
3578 descriptor.set = setter;
3579 }
3580 // If it was accessor property we're done and return here
3581 // in order to avoid adding `value` to the descriptor.
3582 return descriptor;
3583 }
3584 }
3585
3586 // If we got this far we know that object has an own property that is
3587 // not an accessor so we set it as a value and return descriptor.
3588 descriptor.value = object[property];
3589 descriptor.writable = true;
3590 return descriptor;
3591 });
3592 }
3593 }());
3594
3595 }
3596
3597 if (!("getOwnPropertyNames"in Object
3598 )) {
3599
3600 // Object.getOwnPropertyNames
3601 /* global CreateMethodProperty */
3602
3603 var toString = ({}).toString;
3604 var split = ''.split;
3605
3606 CreateMethodProperty(Object, 'getOwnPropertyNames', function getOwnPropertyNames(object) {
3607 var buffer = [];
3608 var key;
3609
3610 // Non-enumerable properties cannot be discovered but can be checked for by name.
3611 // Define those used internally by JS to allow an incomplete solution
3612 var commonProps = ['length', "name", "arguments", "caller", "prototype", "observe", "unobserve"];
3613
3614 if (typeof object === 'undefined' || object === null) {
3615 throw new TypeError('Cannot convert undefined or null to object');
3616 }
3617
3618 // Polyfill.io fallback for non-array-like strings which exist in some ES3 user-agents (IE 8)
3619 object = toString.call(object) == '[object String]' ? split.call(object, '') : Object(object);
3620
3621 // Enumerable properties only
3622 for (key in object) {
3623 if (Object.prototype.hasOwnProperty.call(object, key)) {
3624 buffer.push(key);
3625 }
3626 }
3627
3628 // Check for and add the common non-enumerable properties
3629 for (var i = 0, s = commonProps.length; i < s; i++) {
3630 if (commonProps[i] in object)
3631 buffer.push(commonProps[i]);
3632 }
3633
3634 return buffer;
3635 });
3636
3637 }
3638
3639 if (!("getPrototypeOf"in Object
3640 )) {
3641
3642 // Object.getPrototypeOf
3643 /* global CreateMethodProperty */
3644 // Based on: https://github.com/es-shims/es5-shim/blob/master/es5-sham.js
3645
3646 // https://github.com/es-shims/es5-shim/issues#issue/2
3647 // http://ejohn.org/blog/objectgetprototypeof/
3648 // recommended by fschaefer on github
3649 //
3650 // sure, and webreflection says ^_^
3651 // ... this will nerever possibly return null
3652 // ... Opera Mini breaks here with infinite loops
3653 CreateMethodProperty(Object, 'getPrototypeOf', function getPrototypeOf(object) {
3654 if (object !== Object(object)) {
3655 throw new TypeError('Object.getPrototypeOf called on non-object');
3656 }
3657 var proto = object.__proto__;
3658 if (proto || proto === null) {
3659 return proto;
3660 } else if (typeof object.constructor == 'function' && object instanceof object.constructor) {
3661 return object.constructor.prototype;
3662 } else if (object instanceof Object) {
3663 return Object.prototype;
3664 } else {
3665 // Correctly return null for Objects created with `Object.create(null)`
3666 // (shammed or native) or `{ __proto__: null}`. Also returns null for
3667 // cross-realm objects on browsers that lack `__proto__` support (like
3668 // IE <11), but that's the best we can do.
3669 return null;
3670 }
3671 });
3672
3673 }
3674
3675 if (!("is"in Object
3676 )) {
3677
3678 // Object.is
3679 /* global CreateMethodProperty, SameValue */
3680 // 19.1.2.12. Object.is ( value1, value2 )
3681 CreateMethodProperty(Object, 'is', function is(value1, value2) {
3682 // 1. Return SameValue(value1, value2).
3683 return SameValue(value1, value2);
3684 });
3685
3686 }
3687
3688 if (!("keys"in Object && function() {
3689 return 2 === Object.keys(arguments).length
3690 }(1, 2) && function() {
3691 try {
3692 return Object.keys(""), !0
3693 } catch (t) {
3694 return !1
3695 }
3696 }()
3697 )) {
3698
3699 // Object.keys
3700 /* global CreateMethodProperty */
3701 CreateMethodProperty(Object, "keys", (function() {
3702 'use strict';
3703
3704 // modified from https://github.com/es-shims/object-keys
3705
3706 var has = Object.prototype.hasOwnProperty;
3707 var toStr = Object.prototype.toString;
3708 var isEnumerable = Object.prototype.propertyIsEnumerable;
3709 var hasDontEnumBug = !isEnumerable.call({
3710 toString: null
3711 }, 'toString');
3712 var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
3713 var dontEnums = [
3714 'toString',
3715 'toLocaleString',
3716 'valueOf',
3717 'hasOwnProperty',
3718 'isPrototypeOf',
3719 'propertyIsEnumerable',
3720 'constructor'
3721 ];
3722 var equalsConstructorPrototype = function (o) {
3723 var ctor = o.constructor;
3724 return ctor && ctor.prototype === o;
3725 };
3726 var excludedKeys = {
3727 $console: true,
3728 $external: true,
3729 $frame: true,
3730 $frameElement: true,
3731 $frames: true,
3732 $innerHeight: true,
3733 $innerWidth: true,
3734 $outerHeight: true,
3735 $outerWidth: true,
3736 $pageXOffset: true,
3737 $pageYOffset: true,
3738 $parent: true,
3739 $scrollLeft: true,
3740 $scrollTop: true,
3741 $scrollX: true,
3742 $scrollY: true,
3743 $self: true,
3744 $webkitIndexedDB: true,
3745 $webkitStorageInfo: true,
3746 $window: true
3747 };
3748 var hasAutomationEqualityBug = (function () {
3749 /* global window */
3750 if (typeof window === 'undefined') {
3751 return false;
3752 }
3753 for (var k in window) {
3754 try {
3755 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
3756 try {
3757 equalsConstructorPrototype(window[k]);
3758 } catch (e) {
3759 return true;
3760 }
3761 }
3762 } catch (e) {
3763 return true;
3764 }
3765 }
3766 return false;
3767 }());
3768 var equalsConstructorPrototypeIfNotBuggy = function (o) {
3769 /* global window */
3770 if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
3771 return equalsConstructorPrototype(o);
3772 }
3773 try {
3774 return equalsConstructorPrototype(o);
3775 } catch (e) {
3776 return false;
3777 }
3778 };
3779
3780 function isArgumentsObject(value) {
3781 var str = toStr.call(value);
3782 var isArgs = str === '[object Arguments]';
3783 if (!isArgs) {
3784 isArgs = str !== '[object Array]' &&
3785 value !== null &&
3786 typeof value === 'object' &&
3787 typeof value.length === 'number' &&
3788 value.length >= 0 &&
3789 toStr.call(value.callee) === '[object Function]';
3790 }
3791 return isArgs;
3792 }
3793
3794 return function keys(object) {
3795 var isFunction = toStr.call(object) === '[object Function]';
3796 var isArguments = isArgumentsObject(object);
3797 var isString = toStr.call(object) === '[object String]';
3798 var theKeys = [];
3799
3800 if (object === undefined || object === null) {
3801 throw new TypeError('Cannot convert undefined or null to object');
3802 }
3803
3804 var skipProto = hasProtoEnumBug && isFunction;
3805 if (isString && object.length > 0 && !has.call(object, 0)) {
3806 for (var i = 0; i < object.length; ++i) {
3807 theKeys.push(String(i));
3808 }
3809 }
3810
3811 if (isArguments && object.length > 0) {
3812 for (var j = 0; j < object.length; ++j) {
3813 theKeys.push(String(j));
3814 }
3815 } else {
3816 for (var name in object) {
3817 if (!(skipProto && name === 'prototype') && has.call(object, name)) {
3818 theKeys.push(String(name));
3819 }
3820 }
3821 }
3822
3823 if (hasDontEnumBug) {
3824 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
3825
3826 for (var k = 0; k < dontEnums.length; ++k) {
3827 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
3828 theKeys.push(dontEnums[k]);
3829 }
3830 }
3831 }
3832 return theKeys;
3833 };
3834 }()));
3835
3836 }
3837
3838 if (!("assign"in Object
3839 )) {
3840
3841 // Object.assign
3842 /* global CreateMethodProperty, Get, ToObject */
3843 // 19.1.2.1 Object.assign ( target, ...sources )
3844 CreateMethodProperty(Object, 'assign', function assign(target, source) {
3845 // eslint-disable-line no-unused-vars
3846 // 1. Let to be ? ToObject(target).
3847 var to = ToObject(target);
3848
3849 // 2. If only one argument was passed, return to.
3850 if (arguments.length === 1) {
3851 return to;
3852 }
3853
3854 // 3. Let sources be the List of argument values starting with the second argument
3855 var sources = Array.prototype.slice.call(arguments, 1);
3856
3857 // 4. For each element nextSource of sources, in ascending index order, do
3858 var index1;
3859 var index2;
3860 var keys;
3861 var from;
3862 for (index1 = 0; index1 < sources.length; index1++) {
3863 var nextSource = sources[index1];
3864 // a. If nextSource is undefined or null, let keys be a new empty List.
3865 if (nextSource === undefined || nextSource === null) {
3866 keys = [];
3867 // b. Else,
3868 } else {
3869 // i. Let from be ! ToObject(nextSource).
3870 from = ToObject(nextSource);
3871 // ii. Let keys be ? from.[[OwnPropertyKeys]]().
3872 /*
3873 This step in our polyfill is not complying with the specification.
3874 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
3875 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
3876 */
3877 keys = Object.keys(from);
3878 }
3879
3880 // c. For each element nextKey of keys in List order, do
3881 for (index2 = 0; index2 < keys.length; index2++) {
3882 var nextKey = keys[index2];
3883 var enumerable;
3884 try {
3885 // i. Let desc be ? from.[[GetOwnProperty]](nextKey).
3886 var desc = Object.getOwnPropertyDescriptor(from, nextKey);
3887 // ii. If desc is not undefined and desc.[[Enumerable]] is true, then
3888 enumerable = desc !== undefined && desc.enumerable === true;
3889 } catch (e) {
3890 // Polyfill.io - We use Object.prototype.propertyIsEnumerable as a fallback
3891 // because `Object.getOwnPropertyDescriptor(window.location, 'hash')` causes Internet Explorer 11 to crash.
3892 enumerable = Object.prototype.propertyIsEnumerable.call(from, nextKey);
3893 }
3894 if (enumerable) {
3895 // 1. Let propValue be ? Get(from, nextKey).
3896 var propValue = Get(from, nextKey);
3897 // 2. Perform ? Set(to, nextKey, propValue, true).
3898 to[nextKey] = propValue;
3899 }
3900 }
3901 }
3902 // 5. Return to.
3903 return to;
3904 });
3905
3906 }
3907
3908 if (!("defineProperties"in Object
3909 )) {
3910
3911 // Object.defineProperties
3912 /* global CreateMethodProperty, Get, ToObject, Type */
3913 // 19.1.2.3. Object.defineProperties ( O, Properties )
3914 CreateMethodProperty(Object, 'defineProperties', function defineProperties(O, Properties) {
3915 // 1. If Type(O) is not Object, throw a TypeError exception.
3916 if (Type(O) !== 'object') {
3917 throw new TypeError('Object.defineProperties called on non-object');
3918 }
3919 // 2. Let props be ? ToObject(Properties).
3920 var props = ToObject(Properties);
3921 // 3. Let keys be ? props.[[OwnPropertyKeys]]().
3922 /*
3923 Polyfill.io - This step in our polyfill is not complying with the specification.
3924 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
3925 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
3926 */
3927 var keys = Object.keys(props);
3928 // 4. Let descriptors be a new empty List.
3929 var descriptors = [];
3930 // 5. For each element nextKey of keys in List order, do
3931 for (var i = 0; i < keys.length; i++) {
3932 var nextKey = keys[i];
3933 // a. Let propDesc be ? props.[[GetOwnProperty]](nextKey).
3934 var propDesc = Object.getOwnPropertyDescriptor(props, nextKey);
3935 // b. If propDesc is not undefined and propDesc.[[Enumerable]] is true, then
3936 if (propDesc !== undefined && propDesc.enumerable) {
3937 // i. Let descObj be ? Get(props, nextKey).
3938 var descObj = Get(props, nextKey);
3939 // ii. Let desc be ? ToPropertyDescriptor(descObj).
3940 // Polyfill.io - We skip this step because Object.defineProperty deals with it.
3941 // TODO: Implement this step?
3942 var desc = descObj;
3943 // iii. Append the pair (a two element List) consisting of nextKey and desc to the end of descriptors.
3944 descriptors.push([nextKey, desc]);
3945 }
3946 }
3947 // 6. For each pair from descriptors in list order, do
3948 for (var i = 0; i < descriptors.length; i++) {
3949 // a. Let P be the first element of pair.
3950 var P = descriptors[i][0];
3951 // b. Let desc be the second element of pair.
3952 var desc = descriptors[i][1];
3953 // c. Perform ? DefinePropertyOrThrow(O, P, desc).
3954 Object.defineProperty(O, P, desc);
3955 }
3956 // 7. Return O.
3957 return O;
3958 });
3959
3960 }
3961
3962 if (!("create"in Object
3963 )) {
3964
3965 // Object.create
3966 /* global CreateMethodProperty, Type */
3967 CreateMethodProperty(Object, 'create', function create(O, properties) {
3968 // 1. If Type(O) is neither Object nor Null, throw a TypeError exception.
3969 if (Type(O) !== 'object' && Type(O) !== 'null') {
3970 throw new TypeError('Object prototype may only be an Object or null');
3971 }
3972 // 2. Let obj be ObjectCreate(O).
3973 var obj = new Function('e', 'function Object() {}Object.prototype=e;return new Object')(O);
3974
3975 obj.constructor.prototype = O;
3976
3977 // 3. If Properties is not undefined, then
3978 if (1 in arguments) {
3979 // a. Return ? ObjectDefineProperties(obj, Properties).
3980 return Object.defineProperties(obj, properties);
3981 }
3982
3983 return obj;
3984 });
3985
3986 }
3987
3988
3989 // _ESAbstract.OrdinaryCreateFromConstructor
3990 /* global GetPrototypeFromConstructor */
3991 // 9.1.13. OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
3992 function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) {
3993 // eslint-disable-line no-unused-vars
3994 var internalSlotsList = arguments[2] || {};
3995 // 1. Assert: intrinsicDefaultProto is a String value that is this specification's name of an intrinsic object.
3996 // The corresponding object must be an intrinsic that is intended to be used as the[[Prototype]] value of an object.
3997
3998 // 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
3999 var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto);
4000
4001 // 3. Return ObjectCreate(proto, internalSlotsList).
4002 // 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.
4003 var obj = Object.create(proto);
4004 for (var name in internalSlotsList) {
4005 if (Object.prototype.hasOwnProperty.call(internalSlotsList, name)) {
4006 Object.defineProperty(obj, name, {
4007 configurable: true,
4008 enumerable: false,
4009 writable: true,
4010 value: internalSlotsList[name]
4011 });
4012 }
4013 }
4014 return obj;
4015 }
4016
4017 // _ESAbstract.Construct
4018 /* global IsConstructor, OrdinaryCreateFromConstructor, Call */
4019 // 7.3.13. Construct ( F [ , argumentsList [ , newTarget ]] )
4020 function Construct(F /* [ , argumentsList [ , newTarget ]] */
4021 ) {
4022 // eslint-disable-line no-unused-vars
4023 // 1. If newTarget is not present, set newTarget to F.
4024 var newTarget = arguments.length > 2 ? arguments[2] : F;
4025
4026 // 2. If argumentsList is not present, set argumentsList to a new empty List.
4027 var argumentsList = arguments.length > 1 ? arguments[1] : [];
4028
4029 // 3. Assert: IsConstructor(F) is true.
4030 if (!IsConstructor(F)) {
4031 throw new TypeError('F must be a constructor.');
4032 }
4033
4034 // 4. Assert: IsConstructor(newTarget) is true.
4035 if (!IsConstructor(newTarget)) {
4036 throw new TypeError('newTarget must be a constructor.');
4037 }
4038
4039 // 5. Return ? F.[[Construct]](argumentsList, newTarget).
4040 // Polyfill.io - If newTarget is the same as F, it is equivalent to new F(...argumentsList).
4041 if (newTarget === F) {
4042 return new (Function.prototype.bind.apply(F, [null].concat(argumentsList)))();
4043 } else {
4044 // Polyfill.io - This is mimicking section 9.2.2 step 5.a.
4045 var obj = OrdinaryCreateFromConstructor(newTarget, Object.prototype);
4046 return Call(F, obj, argumentsList);
4047 }
4048 }
4049
4050 // _ESAbstract.ArraySpeciesCreate
4051 /* global IsArray, ArrayCreate, Get, Type, IsConstructor, Construct */
4052 // 9.4.2.3. ArraySpeciesCreate ( originalArray, length )
4053 function ArraySpeciesCreate(originalArray, length) {
4054 // eslint-disable-line no-unused-vars
4055 // 1. Assert: length is an integer Number ≥ 0.
4056 // 2. If length is -0, set length to +0.
4057 if (1 / length === - Infinity) {
4058 length = 0;
4059 }
4060
4061 // 3. Let isArray be ? IsArray(originalArray).
4062 var isArray = IsArray(originalArray);
4063
4064 // 4. If isArray is false, return ? ArrayCreate(length).
4065 if (isArray === false) {
4066 return ArrayCreate(length);
4067 }
4068
4069 // 5. Let C be ? Get(originalArray, "constructor").
4070 var C = Get(originalArray, 'constructor');
4071
4072 // Polyfill.io - We skip this section as not sure how to make a cross-realm normal Array, a same-realm Array.
4073 // 6. If IsConstructor(C) is true, then
4074 // if (IsConstructor(C)) {
4075 // a. Let thisRealm be the current Realm Record.
4076 // b. Let realmC be ? GetFunctionRealm(C).
4077 // c. If thisRealm and realmC are not the same Realm Record, then
4078 // i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined.
4079 // }
4080 // 7. If Type(C) is Object, then
4081 if (Type(C) === 'object') {
4082 // a. Set C to ? Get(C, @@species).
4083 C = 'Symbol' in this && 'species' in this.Symbol ? Get(C, this.Symbol.species) : undefined;
4084 // b. If C is null, set C to undefined.
4085 if (C === null) {
4086 C = undefined;
4087 }
4088 }
4089 // 8. If C is undefined, return ? ArrayCreate(length).
4090 if (C === undefined) {
4091 return ArrayCreate(length);
4092 }
4093 // 9. If IsConstructor(C) is false, throw a TypeError exception.
4094 if (!IsConstructor(C)) {
4095 throw new TypeError('C must be a constructor');
4096 }
4097 // 10. Return ? Construct(C, « length »).
4098 return Construct(C, [length]);
4099 }
4100 if (!("filter"in Array.prototype
4101 )) {
4102
4103 // Array.prototype.filter
4104 /* global CreateMethodProperty, ToObject, ToLength, Get, IsCallable, ArraySpeciesCreate, ToString, HasProperty, ToBoolean, Call, CreateDataPropertyOrThrow */
4105 // 22.1.3.7. Array.prototype.filter ( callbackfn [ , thisArg ] )
4106 CreateMethodProperty(Array.prototype, 'filter', function filter(callbackfn /* [ , thisArg ] */
4107 ) {
4108 // 1. Let O be ? ToObject(this value).
4109 var O = ToObject(this);
4110 // 2. Let len be ? ToLength(? Get(O, "length")).
4111 var len = ToLength(Get(O, "length"));
4112 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
4113 if (IsCallable(callbackfn) === false) {
4114 throw new TypeError(callbackfn + ' is not a function');
4115 }
4116 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
4117 var T = arguments.length > 1 ? arguments[1] : undefined;
4118 // 5. Let A be ? ArraySpeciesCreate(O, 0).
4119 var A = ArraySpeciesCreate(O, 0);
4120 // 6. Let k be 0.
4121 var k = 0;
4122 // 7. Let to be 0.
4123 var to = 0;
4124 // 8. Repeat, while k < len
4125 while (k < len) {
4126 // a. Let Pk be ! ToString(k).
4127 var Pk = ToString(k);
4128 // b. Let kPresent be ? HasProperty(O, Pk).
4129 var kPresent = HasProperty(O, Pk);
4130 // c. If kPresent is true, then
4131 if (kPresent) {
4132 // i. Let kValue be ? Get(O, Pk).
4133 var kValue = Get(O, Pk);
4134 // ii. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
4135 var selected = ToBoolean(Call(callbackfn, T, [kValue, k, O]));
4136 // iii. If selected is true, then
4137 if (selected) {
4138 // 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue)
4139 CreateDataPropertyOrThrow(A, ToString(to), kValue);
4140 // 2. Increase to by 1.
4141 to = to + 1;
4142 }
4143
4144 }
4145 // d. Increase k by 1.
4146 k = k + 1;
4147 }
4148 // 9. Return A.
4149 return A;
4150 });
4151
4152 }
4153
4154 if (!("map"in Array.prototype
4155 )) {
4156
4157 // Array.prototype.map
4158 /* global ArraySpeciesCreate, Call, CreateDataPropertyOrThrow, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
4159 /* global CreateMethodProperty, ToObject, ToLength, Get, ArraySpeciesCreate, ToString, HasProperty, Call, CreateDataPropertyOrThrow */
4160 // 22.1.3.16. Array.prototype.map ( callbackfn [ , thisArg ] )
4161 CreateMethodProperty(Array.prototype, 'map', function map(callbackfn /* [ , thisArg ] */
4162 ) {
4163 // 1. Let O be ? ToObject(this value).
4164 var O = ToObject(this);
4165 // 2. Let len be ? ToLength(? Get(O, "length")).
4166 var len = ToLength(Get(O, "length"));
4167 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
4168 if (IsCallable(callbackfn) === false) {
4169 throw new TypeError(callbackfn + ' is not a function');
4170 }
4171 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
4172 var T = arguments.length > 1 ? arguments[1] : undefined;
4173 // 5. Let A be ? ArraySpeciesCreate(O, len).
4174 var A = ArraySpeciesCreate(O, len);
4175 // 6. Let k be 0.
4176 var k = 0;
4177 // 7. Repeat, while k < len
4178 while (k < len) {
4179 // a. Let Pk be ! ToString(k).
4180 var Pk = ToString(k);
4181 // b. Let kPresent be ? HasProperty(O, Pk).
4182 var kPresent = HasProperty(O, Pk);
4183 // c. If kPresent is true, then
4184 if (kPresent) {
4185 // i. Let kValue be ? Get(O, Pk).
4186 var kValue = Get(O, Pk);
4187 // ii. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
4188 var mappedValue = Call(callbackfn, T, [kValue, k, O]);
4189 // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
4190 CreateDataPropertyOrThrow(A, Pk, mappedValue);
4191 }
4192 // d. Increase k by 1.
4193 k = k + 1;
4194 }
4195 // 8. Return A.
4196 return A;
4197 });
4198
4199 }
4200
4201 if (!("of"in Array
4202 )) {
4203
4204 // Array.of
4205 /* global ArrayCreate, Construct, CreateDataPropertyOrThrow, CreateMethodProperty, IsConstructor, ToString */
4206 // 22.1.2.3. Array.of ( ...items )
4207 CreateMethodProperty(Array, 'of', function of() {
4208 // 1. Let len be the actual number of arguments passed to this function.
4209 var len = arguments.length;
4210 // 2. Let items be the List of arguments passed to this function.
4211 var items = arguments;
4212 // 3. Let C be the this value.
4213 var C = this;
4214 // 4. If IsConstructor(C) is true, then
4215 if (IsConstructor(C)) {
4216 // a. Let A be ? Construct(C, « len »).
4217 var A = Construct(C, [len]);
4218 // 5. Else,
4219 } else {
4220 // a. Let A be ? ArrayCreate(len).
4221 var A = ArrayCreate(len);
4222 }
4223 // 6. Let k be 0.
4224 var k = 0;
4225 // 7. Repeat, while k < len
4226 while (k < len) {
4227 // a. Let kValue be items[k].
4228 var kValue = items[k];
4229 // b. Let Pk be ! ToString(k).
4230 var Pk = ToString(k);
4231 // c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue).
4232 CreateDataPropertyOrThrow(A, Pk, kValue);
4233 // d. Increase k by 1.
4234 var k = k + 1;
4235
4236 }
4237 // 8. Perform ? Set(A, "length", len, true)
4238 A["length"] = len;
4239 // 9. Return A.
4240 return A;
4241 });
4242
4243 }
4244
4245 if (!("seal"in Object && function() {
4246 try {
4247 return Object.seal("1"), !0
4248 } catch (t) {
4249 return !1
4250 }
4251 })) {
4252
4253 // Object.seal
4254 /* global CreateMethodProperty, Type */
4255 // 19.1.2.19 Object.seal ( O )
4256 (function(originalObjectSeal) {
4257 CreateMethodProperty(Object, 'seal', function seal(O) {
4258 // 1. If Type(O) is not Object, return O.
4259 if (Type(O) === 'object') {
4260 return O;
4261 }
4262 // 2. Let status be ? SetIntegrityLevel(O, "sealed").
4263 // 3. If status is false, throw a TypeError exception.
4264 // 4. Return O.
4265 return originalObjectSeal ? originalObjectSeal(O) : O;
4266 });
4267 }(Object.seal));
4268
4269
4270 }
4271
4272
4273 // Object.setPrototypeOf
4274 /* global CreateMethodProperty */
4275 // ES6-shim 0.16.0 (c) 2013-2014 Paul Miller (http://paulmillr.com)
4276 // ES6-shim may be freely distributed under the MIT license.
4277 // For more details and documentation:
4278 // https://github.com/paulmillr/es6-shim/
4279
4280 // NOTE: This versions needs object ownership
4281 // because every promoted object needs to be reassigned
4282 // otherwise uncompatible browsers cannot work as expected
4283 //
4284 // NOTE: This might need es5-shim or polyfills upfront
4285 // because it's based on ES5 API.
4286 // (probably just an IE <= 8 problem)
4287 //
4288 // NOTE: nodejs is fine in version 0.8, 0.10, and future versions.
4289 (function () {
4290 if (Object.setPrototypeOf) {
4291 return;
4292 }
4293
4294 /*jshint proto: true */
4295 // @author Andrea Giammarchi - @WebReflection
4296
4297 var getOwnPropertyNames = Object.getOwnPropertyNames;
4298 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
4299 var create = Object.create;
4300 var defineProperty = Object.defineProperty;
4301 var getPrototypeOf = Object.getPrototypeOf;
4302 var objProto = Object.prototype;
4303
4304 var copyDescriptors = function (target, source) {
4305 // define into target descriptors from source
4306 getOwnPropertyNames(source).forEach(function (key) {
4307 defineProperty(
4308 target,
4309 key,
4310 getOwnPropertyDescriptor(source, key)
4311 );
4312 });
4313 return target;
4314 };
4315 // used as fallback when no promotion is possible
4316 var createAndCopy = function setPrototypeOf(origin, proto) {
4317 return copyDescriptors(create(proto), origin);
4318 };
4319 var set, sPOf;
4320 try {
4321 // this might fail for various reasons
4322 // ignore if Chrome cought it at runtime
4323 set = getOwnPropertyDescriptor(objProto, '__proto__').set;
4324 set.call({}, null);
4325 // setter not poisoned, it can promote
4326 // Firefox, Chrome
4327 sPOf = function setPrototypeOf(origin, proto) {
4328 set.call(origin, proto);
4329 return origin;
4330 };
4331 } catch (e) {
4332 // do one or more feature detections
4333 set = {
4334 __proto__: null
4335 };
4336 // if proto does not work, needs to fallback
4337 // some Opera, Rhino, ducktape
4338 if (set instanceof Object) {
4339 sPOf = createAndCopy;
4340 } else {
4341 // verify if null objects are buggy
4342 /* eslint-disable no-proto */
4343 set.__proto__ = objProto;
4344 /* eslint-enable no-proto */
4345 // if null objects are buggy
4346 // nodejs 0.8 to 0.10
4347 if (set instanceof Object) {
4348 sPOf = function setPrototypeOf(origin, proto) {
4349 // use such bug to promote
4350 /* eslint-disable no-proto */
4351 origin.__proto__ = proto;
4352 /* eslint-enable no-proto */
4353 return origin;
4354 };
4355 } else {
4356 // try to use proto or fallback
4357 // Safari, old Firefox, many others
4358 sPOf = function setPrototypeOf(origin, proto) {
4359 // if proto is not null
4360 if (getPrototypeOf(origin)) {
4361 // use __proto__ to promote
4362 /* eslint-disable no-proto */
4363 origin.__proto__ = proto;
4364 /* eslint-enable no-proto */
4365 return origin;
4366 } else {
4367 // otherwise unable to promote: fallback
4368 return createAndCopy(origin, proto);
4369 }
4370 };
4371 }
4372 }
4373 }
4374 CreateMethodProperty(Object, 'setPrototypeOf', sPOf);
4375 }());
4376 if (!("Promise"in this
4377 )) {
4378
4379 // Promise
4380 !function(n) {
4381 function t(r) {
4382 if (e[r])
4383 return e[r].exports;
4384 var o = e[r] = {
4385 i: r,
4386 l: !1,
4387 exports: {}
4388 };
4389 return n[r].call(o.exports, o, o.exports, t), o.l=!0, o.exports
4390 }
4391 var e = {};
4392 t.m = n, t.c = e, t.i = function(n) {
4393 return n
4394 }, t.d = function(n, e, r) {
4395 t.o(n, e) || Object.defineProperty(n, e, {
4396 configurable: !1,
4397 enumerable: !0,
4398 get: r
4399 })
4400 }, t.n = function(n) {
4401 var e = n && n.__esModule ? function() {
4402 return n["default"]
4403 }
4404 : function() {
4405 return n
4406 };
4407 return t.d(e, "a", e), e
4408 }, t.o = function(n, t) {
4409 return Object.prototype.hasOwnProperty.call(n, t)
4410 }, t.p = "", t(t.s = 100)
4411 }({
4412 100: /*!***********************!*\
4413 !*** ./src/global.js ***!
4414 \***********************/
4415 function(n, t, e) {
4416 (function(n) {
4417 var t = e( /*! ./yaku */
4418 5);
4419 try {
4420 n.Promise = t, window.Promise = t
4421 } catch (r) {}
4422 }).call(t, e( /*! ./../~/webpack/buildin/global.js */
4423 2))
4424 },
4425 2: /*!***********************************!*\
4426 !*** (webpack)/buildin/global.js ***!
4427 \***********************************/
4428 function(n, t) {
4429 var e;
4430 e = function() {
4431 return this
4432 }();
4433 try {
4434 e = e || Function("return this")() || (0, eval)("this")
4435 } catch (r) {
4436 "object" == typeof window && (e = window)
4437 }
4438 n.exports = e
4439 },
4440 5: /*!*********************!*\
4441 !*** ./src/yaku.js ***!
4442 \*********************/
4443 function(n, t, e) {
4444 (function(t) {
4445 !function() {
4446 "use strict";
4447 function e() {
4448 return rn[q][B] || D
4449 }
4450 function r(n) {
4451 return n && "object" == typeof n
4452 }
4453 function o(n) {
4454 return "function" == typeof n
4455 }
4456 function i(n, t) {
4457 return n instanceof t
4458 }
4459 function u(n) {
4460 return i(n, M)
4461 }
4462 function c(n, t, e) {
4463 if (!t(n))
4464 throw h(e)
4465 }
4466 function f() {
4467 try {
4468 return R.apply(S, arguments)
4469 } catch (n) {
4470 return nn.e = n, nn
4471 }
4472 }
4473 function s(n, t) {
4474 return R = n, S = t, f
4475 }
4476 function a(n, t) {
4477 function e() {
4478 for (var e = 0; e < o;)
4479 t(r[e], r[e + 1]), r[e++] = P, r[e++] = P;
4480 o = 0, r.length > n && (r.length = n)
4481 }
4482 var r = A(n), o = 0;
4483 return function(n, t) {
4484 r[o++] = n, r[o++] = t, 2 === o && rn.nextTick(e)
4485 }
4486 }
4487 function l(n, t) {
4488 var e, r, u, c, f = 0;
4489 if (!n)
4490 throw h(Q);
4491 var a = n[rn[q][z]];
4492 if (o(a))
4493 r = a.call(n);
4494 else {
4495 if (!o(n.next)) {
4496 if (i(n, A)) {
4497 for (e = n.length; f < e;)
4498 t(n[f], f++);
4499 return f
4500 }
4501 throw h(Q)
4502 }
4503 r = n
4504 }
4505 for (; !(u = r.next()).done;)
4506 if ((c = s(t)(u.value, f++)) === nn)
4507 throw o(r[G]) && r[G](), c.e;
4508 return f
4509 }
4510 function h(n) {
4511 return new TypeError(n)
4512 }
4513 function v(n) {
4514 return (n ? "" : V) + (new M).stack
4515 }
4516 function _(n, t) {
4517 var e = "on" + n.toLowerCase(), r = O[e];
4518 H && H.listeners(n).length ? n === Z ? H.emit(n, t._v, t) : H.emit(n, t) : r ? r({
4519 reason: t._v,
4520 promise: t
4521 }) : rn[n](t._v, t)
4522 }
4523 function p(n) {
4524 return n && n._s
4525 }
4526 function d(n) {
4527 if (p(n))
4528 return new n(tn);
4529 var t, e, r;
4530 return t = new n(function(n, o) {
4531 if (t)
4532 throw h();
4533 e = n, r = o
4534 }), c(e, o), c(r, o), t
4535 }
4536 function w(n, t) {
4537 var e=!1;
4538 return function(r) {
4539 e || (e=!0, L && (n[N] = v(!0)), t === Y ? k(n, r) : x(n, t, r))
4540 }
4541 }
4542 function y(n, t, e, r) {
4543 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
4544 }
4545 function m(n) {
4546 if (n._umark)
4547 return !0;
4548 n._umark=!0;
4549 for (var t, e = 0, r = n._c; e < r;)
4550 if (t = n[e++], t._onRejected || m(t))
4551 return !0
4552 }
4553 function j(n, t) {
4554 function e(n) {
4555 return r.push(n.replace(/^\s+|\s+$/g, ""))
4556 }
4557 var r = [];
4558 return L && (t[N] && e(t[N]), function o(n) {
4559 n && K in n && (o(n._next), e(n[K] + ""), o(n._p))
4560 }(t)), (n && n.stack ? n.stack : n) + ("\n" + r.join("\n")).replace(en, "")
4561 }
4562 function g(n, t) {
4563 return n(t)
4564 }
4565 function x(n, t, e) {
4566 var r = 0, o = n._c;
4567 if (n._s === $)
4568 for (n._s = t, n._v = e, t === U && (L && u(e) && (e.longStack = j(e, n)), un(n)); r < o;)
4569 on(n, n[r++]);
4570 return n
4571 }
4572 function k(n, t) {
4573 if (t === n && t)
4574 return x(n, U, h(W)), n;
4575 if (t !== C && (o(t) || r(t))) {
4576 var e = s(b)(t);
4577 if (e === nn)
4578 return x(n, U, e.e), n;
4579 o(e) ? (L && p(t) && (n._next = t), p(t) ? T(n, t, e) : rn.nextTick(function() {
4580 T(n, t, e)
4581 })) : x(n, Y, t)
4582 } else
4583 x(n, Y, t);
4584 return n
4585 }
4586 function b(n) {
4587 return n.then
4588 }
4589 function T(n, t, e) {
4590 var r = s(e, t)(function(e) {
4591 t && (t = C, k(n, e))
4592 }, function(e) {
4593 t && (t = C, x(n, U, e))
4594 });
4595 r === nn && t && (x(n, U, r.e), t = C)
4596 }
4597 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 = {
4598 e: C
4599 }, tn = function() {}, en = /^.+\/node_modules\/yaku\/.+\n?/gm, rn = function(n) {
4600 var t, e = this;
4601 if (!r(e) || e._s !== P)
4602 throw h("Invalid this");
4603 if (e._s = $, L && (e[K] = v()), n !== tn) {
4604 if (!o(n))
4605 throw h(Q);
4606 t = s(n)(w(e, Y), w(e, U)), t === nn && x(e, U, t.e)
4607 }
4608 };
4609 rn["default"] = rn, function(n, t) {
4610 for (var e in t)
4611 n[e] = t[e]
4612 }(rn.prototype, {
4613 then: function(n, t) {
4614 if (this._s === undefined)
4615 throw h();
4616 return y(this, d(rn.speciesConstructor(this, rn)), n, t)
4617 },
4618 "catch": function(n) {
4619 return this.then(P, n)
4620 },
4621 "finally": function(n) {
4622 return this.then(function(t) {
4623 return rn.resolve(n()).then(function() {
4624 return t
4625 })
4626 }, function(t) {
4627 return rn.resolve(n()).then(function() {
4628 throw t
4629 })
4630 })
4631 },
4632 _c: 0,
4633 _p: C
4634 }), rn.resolve = function(n) {
4635 return p(n) ? n : k(d(this), n)
4636 }, rn.reject = function(n) {
4637 return x(d(this), U, n)
4638 }, rn.race = function(n) {
4639 var t = this, e = d(t), r = function(n) {
4640 x(e, Y, n)
4641 }, o = function(n) {
4642 x(e, U, n)
4643 }, i = s(l)(n, function(n) {
4644 t.resolve(n).then(r, o)
4645 });
4646 return i === nn ? t.reject(i.e) : e
4647 }, rn.all = function(n) {
4648 function t(n) {
4649 x(o, U, n)
4650 }
4651 var e, r = this, o = d(r), i = [];
4652 return (e = s(l)(n, function(n, u) {
4653 r.resolve(n).then(function(n) {
4654 i[u] = n, --e || x(o, Y, i)
4655 }, t)
4656 })) === nn ? r.reject(e.e) : (e || x(o, Y, []), o)
4657 }, rn.Symbol = O[q] || {}, s(function() {
4658 Object.defineProperty(rn, e(), {
4659 get: function() {
4660 return this
4661 }
4662 })
4663 })(), rn.speciesConstructor = function(n, t) {
4664 var r = n.constructor;
4665 return r ? r[e()] || t : t
4666 }, rn.unhandledRejection = function(n, t) {
4667 I && I.error("Uncaught (in promise)", L ? t.longStack : j(n, t))
4668 }, rn.rejectionHandled = tn, rn.enableLongStackTrace = function() {
4669 L=!0
4670 }, rn.nextTick = F ? function(n) {
4671 E ? new E(function(n) {
4672 n()
4673 }).then(n) : setTimeout(n)
4674 } : H.nextTick, rn._s = 1;
4675 var on = a(999, function(n, t) {
4676 var e, r;
4677 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)
4678 }), un = a(9, function(n) {
4679 m(n) || (n[J] = 1, _(Z, n))
4680 });
4681 try {
4682 n.exports = rn
4683 } catch (cn) {
4684 O.Yaku = rn
4685 }
4686 }()
4687 }).call(t, e( /*! ./../~/webpack/buildin/global.js */
4688 2))
4689 }
4690 });
4691 }
4692
4693 if (!("flags"in RegExp.prototype
4694 )) {
4695
4696 // RegExp.prototype.flags
4697 /* global Get, ToBoolean, Type */
4698 Object.defineProperty(RegExp.prototype, 'flags', {
4699 configurable: true,
4700 enumerable: false,
4701 get: function () {
4702 // 21.2.5.3.1 Let R be the this value.
4703 var R = this;
4704
4705 // 21.2.5.3.2 If Type(R) is not Object, throw a TypeError exception.
4706 if (Type(R) !== 'object') {
4707 throw new TypeError('Method called on incompatible type: must be an object.');
4708 }
4709 // 21.2.5.3.3 Let result be the empty String.
4710 var result = '';
4711
4712 // 21.2.5.3.4 Let global be ToBoolean(? Get(R, "global")).
4713 var global = ToBoolean(Get(R, 'global'));
4714
4715 // 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.
4716 if (global) {
4717 result += 'g';
4718 }
4719
4720 // 21.2.5.3.6 Let ignoreCase be ToBoolean(? Get(R, "ignoreCase")).
4721 var ignoreCase = ToBoolean(Get(R, 'ignoreCase'));
4722
4723 // 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.
4724 if (ignoreCase) {
4725 result += 'i';
4726 }
4727
4728 // 21.2.5.3.8 Let multiline be ToBoolean(? Get(R, "multiline")).
4729 var multiline = ToBoolean(Get(R, 'multiline'));
4730
4731 // 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.
4732 if (multiline) {
4733 result += 'm';
4734 }
4735
4736 // 21.2.5.3.10 Let unicode be ToBoolean(? Get(R, "unicode")).
4737 var unicode = ToBoolean(Get(R, 'unicode'));
4738
4739 // 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.
4740 if (unicode) {
4741 result += 'u';
4742 }
4743
4744 // 21.2.5.3.12 Let sticky be ToBoolean(? Get(R, "sticky")).
4745 var sticky = ToBoolean(Get(R, 'sticky'));
4746
4747 // 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.
4748 if (sticky) {
4749 result += 'y';
4750 }
4751
4752 // 21.2.5.3.14 Return result.
4753 return result;
4754 }
4755 });
4756
4757 }
4758
4759 if (!("codePointAt"in String.prototype
4760 )) {
4761
4762 // String.prototype.codePointAt
4763 /* global CreateMethodProperty, RequireObjectCoercible, ToInteger, ToString, UTF16Decode */
4764 // 21.1.3.3. String.prototype.codePointAt ( pos )
4765 CreateMethodProperty(String.prototype, 'codePointAt', function codePointAt(pos) {
4766 // 1. Let O be ? RequireObjectCoercible(this value).
4767 var O = RequireObjectCoercible(this);
4768 // 2. Let S be ? ToString(O).
4769 var S = ToString(O);
4770 // 3. Let position be ? ToInteger(pos).
4771 var position = ToInteger(pos);
4772 // 4. Let size be the length of S.
4773 var size = S.length;
4774 // 5. If position < 0 or position ≥ size, return undefined.
4775 if (position < 0 || position >= size) {
4776 return undefined;
4777 }
4778 // 6. Let first be the numeric value of the code unit at index position within the String S.
4779 var first = String.prototype.charCodeAt.call(S, position);
4780 // 7. If first < 0xD800 or first > 0xDBFF or position+1 = size, return first.
4781 if (first < 0xD800 || first > 0xDBFF || position + 1 === size) {
4782 return first;
4783 }
4784 // 8. Let second be the numeric value of the code unit at index position+1 within the String S.
4785 var second = String.prototype.charCodeAt.call(S, position + 1);
4786 // 9. If second < 0xDC00 or second > 0xDFFF, return first.
4787 if (second < 0xDC00 || second > 0xDFFF) {
4788 return first;
4789 }
4790 // 10. Return UTF16Decode(first, second).
4791 // 21.1.3.3.10 Return UTF16Decode(first, second).
4792 return UTF16Decode(first, second);
4793 });
4794
4795 }
4796
4797 if (!("endsWith"in String.prototype
4798 )) {
4799
4800 // String.prototype.endsWith
4801 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
4802 // 21.1.3.6. String.prototype.endsWith ( searchString [ , endPosition ] )
4803 CreateMethodProperty(String.prototype, 'endsWith', function endsWith(searchString /* [ , endPosition ] */
4804 ) {
4805 'use strict';
4806 var endPosition = arguments.length > 1 ? arguments[1] : undefined;
4807 // 1. Let O be ? RequireObjectCoercible(this value).
4808 var O = RequireObjectCoercible(this);
4809 // 2. Let S be ? ToString(O).
4810 var S = ToString(O);
4811 // 3. Let isRegExp be ? IsRegExp(searchString).
4812 var isRegExp = IsRegExp(searchString);
4813 // 4. If isRegExp is true, throw a TypeError exception.
4814 if (isRegExp) {
4815 throw new TypeError('First argument to String.prototype.endsWith must not be a regular expression');
4816 }
4817 // 5. Let searchStr be ? ToString(searchString).
4818 var searchStr = ToString(searchString);
4819 // 6. Let len be the length of S.
4820 var len = S.length;
4821 // 7. If endPosition is undefined, let pos be len, else let pos be ? ToInteger(endPosition).
4822 var pos = endPosition === undefined ? len : ToInteger(endPosition);
4823 // 8. Let end be min(max(pos, 0), len).
4824 var end = Math.min(Math.max(pos, 0), len);
4825 // 9. Let searchLength be the length of searchStr.
4826 var searchLength = searchStr.length;
4827 // 10. Let start be end - searchLength.
4828 var start = end - searchLength;
4829 // 11. If start is less than 0, return false.
4830 if (start < 0) {
4831 return false;
4832 }
4833 // 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.
4834 if (S.substr(start, searchLength) === searchStr) {
4835 return true;
4836 }
4837 // 13. Otherwise, return false.
4838 return false;
4839 });
4840
4841 }
4842
4843 if (!("includes"in String.prototype
4844 )) {
4845
4846 // String.prototype.includes
4847 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
4848 // 21.1.3.7. String.prototype.includes ( searchString [ , position ] )
4849 CreateMethodProperty(String.prototype, 'includes', function includes(searchString /* [ , position ] */
4850 ) {
4851 'use strict';
4852 var position = arguments.length > 1 ? arguments[1] : undefined;
4853 // 1. Let O be ? RequireObjectCoercible(this value).
4854 var O = RequireObjectCoercible(this);
4855 // 2. Let S be ? ToString(O).
4856 var S = ToString(O);
4857 // 3. Let isRegExp be ? IsRegExp(searchString).
4858 var isRegExp = IsRegExp(searchString);
4859 // 4. If isRegExp is true, throw a TypeError exception.
4860 if (isRegExp) {
4861 throw new TypeError('First argument to String.prototype.includes must not be a regular expression');
4862 }
4863 // 5. Let searchStr be ? ToString(searchString).
4864 var searchStr = ToString(searchString);
4865 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
4866 var pos = ToInteger(position);
4867 // 7. Let len be the length of S.
4868 var len = S.length;
4869 // 8. Let start be min(max(pos, 0), len).
4870 var start = Math.min(Math.max(pos, 0), len);
4871 // 9. Let searchLen be the length of searchStr.
4872 // var searchLength = searchStr.length;
4873 // 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.
4874 return String.prototype.indexOf.call(S, searchStr, start) !== - 1;
4875 });
4876
4877 }
4878
4879 if (!("padEnd"in String.prototype
4880 )) {
4881
4882 // String.prototype.padEnd
4883 /* global CreateMethodProperty, RequireObjectCoercible, ToLength, ToString */
4884 // 21.1.3.13. String.prototype.padEnd( maxLength [ , fillString ] )
4885 CreateMethodProperty(String.prototype, 'padEnd', function padEnd(maxLength /* [ , fillString ] */
4886 ) {
4887 'use strict';
4888 var fillString = arguments.length > 1 ? arguments[1] : undefined;
4889 // 1. Let O be ? RequireObjectCoercible(this value).
4890 var O = RequireObjectCoercible(this);
4891 // 2. Let S be ? ToString(O).
4892 var S = ToString(O);
4893 // 3. Let intMaxLength be ? ToLength(maxLength).
4894 var intMaxLength = ToLength(maxLength);
4895 // 4. Let stringLength be the length of S.
4896 var stringLength = S.length;
4897 // 5. If intMaxLength is not greater than stringLength, return S.
4898 if (intMaxLength <= stringLength) {
4899 return S;
4900 }
4901 // 6. If fillString is undefined, let filler be the String value consisting solely of the code unit 0x0020 (SPACE).
4902 if (fillString === undefined) {
4903 var filler = ' ';
4904 // 7. Else, let filler be ? ToString(fillString).
4905 } else {
4906 var filler = ToString(fillString);
4907 }
4908 // 8. If filler is the empty String, return S.
4909 if (filler === '') {
4910 return S;
4911 }
4912 // 9. Let fillLen be intMaxLength - stringLength.
4913 var fillLen = intMaxLength - stringLength;
4914 // 10. Let truncatedStringFiller be the String value consisting of repeated concatenations of filler truncated to length fillLen.
4915 var truncatedStringFiller = '';
4916 for (var i = 0; i < fillLen; i++) {
4917 truncatedStringFiller += filler;
4918 }
4919 truncatedStringFiller = truncatedStringFiller.substr(0, fillLen);
4920 // 11. Return the string-concatenation of S and truncatedStringFiller.
4921 return S + truncatedStringFiller;
4922 });
4923
4924 }
4925
4926 if (!("padStart"in String.prototype
4927 )) {
4928
4929 // String.prototype.padStart
4930 /* global CreateMethodProperty, RequireObjectCoercible, ToLength, ToString */
4931 // 21.1.3.14. String.prototype.padStart( maxLength [ , fillString ] )
4932 CreateMethodProperty(String.prototype, 'padStart', function padStart(maxLength /* [ , fillString ] */
4933 ) {
4934 'use strict';
4935 var fillString = arguments.length > 1 ? arguments[1] : undefined;
4936 // 1. Let O be ? RequireObjectCoercible(this value).
4937 var O = RequireObjectCoercible(this);
4938 // 2. Let S be ? ToString(O).
4939 var S = ToString(O);
4940 // 3. Let intMaxLength be ? ToLength(maxLength).
4941 var intMaxLength = ToLength(maxLength);
4942 // 4. Let stringLength be the length of S.
4943 var stringLength = S.length;
4944 // 5. If intMaxLength is not greater than stringLength, return S.
4945 if (intMaxLength <= stringLength) {
4946 return S;
4947 }
4948 // 6. If fillString is undefined, let filler be the String value consisting solely of the code unit 0x0020 (SPACE).
4949 if (fillString === undefined) {
4950 var filler = ' ';
4951 // 7. Else, let filler be ? ToString(fillString).
4952 } else {
4953 var filler = ToString(fillString);
4954 }
4955 // 8. If filler is the empty String, return S.
4956 if (filler === '') {
4957 return S;
4958 }
4959 // 9. Let fillLen be intMaxLength - stringLength.
4960 var fillLen = intMaxLength - stringLength;
4961 // 10. Let truncatedStringFiller be the String value consisting of repeated concatenations of filler truncated to length fillLen.
4962 var truncatedStringFiller = '';
4963 for (var i = 0; i < fillLen; i++) {
4964 truncatedStringFiller += filler;
4965 }
4966 truncatedStringFiller = truncatedStringFiller.substr(0, fillLen);
4967 // 11. Return the string-concatenation of truncatedStringFiller and S.
4968 return truncatedStringFiller + S;
4969 });
4970
4971 }
4972
4973 if (!("repeat"in String.prototype
4974 )) {
4975
4976 // String.prototype.repeat
4977 /* global CreateMethodProperty, RequireObjectCoercible, ToInteger, ToString */
4978 // 21.1.3.15String.prototype.repeat ( count )
4979 CreateMethodProperty(String.prototype, 'repeat', function repeat(count) {
4980 'use strict';
4981 // 1. Let O be ? RequireObjectCoercible(this value).
4982 var O = RequireObjectCoercible(this);
4983 // 2. Let S be ? ToString(O).
4984 var S = ToString(O);
4985 // 3. Let n be ? ToInteger(count).
4986 var n = ToInteger(count);
4987 // 4. If n < 0, throw a RangeError exception.
4988 if (n < 0) {
4989 throw new RangeError('Invalid count value');
4990 }
4991 // 5. If n is +∞, throw a RangeError exception.
4992 if (n === Infinity) {
4993 throw new RangeError('Invalid count value');
4994 }
4995 // 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.
4996 var T = n === 0 ? '' : new Array(n + 1).join(S);
4997 // 7. Return T.
4998 return T;
4999 });
5000
5001 }
5002
5003 if (!("startsWith"in String.prototype
5004 )) {
5005
5006 // String.prototype.startsWith
5007 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
5008 // 21.1.3.20. String.prototype.startsWith ( searchString [ , position ] )
5009 CreateMethodProperty(String.prototype, 'startsWith', function startsWith(searchString /* [ , position ] */
5010 ) {
5011 'use strict';
5012 var position = arguments.length > 1 ? arguments[1] : undefined;
5013 // 1. Let O be ? RequireObjectCoercible(this value).
5014 var O = RequireObjectCoercible(this);
5015 // 2. Let S be ? ToString(O).
5016 var S = ToString(O);
5017 // 3. Let isRegExp be ? IsRegExp(searchString).
5018 var isRegExp = IsRegExp(searchString);
5019 // 4. If isRegExp is true, throw a TypeError exception.
5020 if (isRegExp) {
5021 throw new TypeError('First argument to String.prototype.startsWith must not be a regular expression');
5022 }
5023 // 5. Let searchStr be ? ToString(searchString).
5024 var searchStr = ToString(searchString);
5025 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
5026 var pos = ToInteger(position);
5027 // 7. Let len be the length of S.
5028 var len = S.length;
5029 // 8. Let start be min(max(pos, 0), len).
5030 var start = Math.min(Math.max(pos, 0), len);
5031 // 9. Let searchLength be the length of searchStr.
5032 var searchLength = searchStr.length;
5033 // 10. If searchLength+start is greater than len, return false.
5034 if (searchLength + start > len) {
5035 return false;
5036 }
5037 // 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.
5038 if (S.substr(start).indexOf(searchString) === 0) {
5039 return true;
5040 }
5041 // 12. Otherwise, return false.
5042 return false;
5043 });
5044
5045 }
5046
5047 if (!("Symbol"in this && 0 === this.Symbol.length
5048 )) {
5049
5050 // Symbol
5051 // A modification of https://github.com/WebReflection/get-own-property-symbols
5052 // (C) Andrea Giammarchi - MIT Licensed
5053
5054 (function (Object, GOPS, global) {
5055 'use strict'; //so that ({}).toString.call(null) returns the correct [object Null] rather than [object Window]
5056
5057 var setDescriptor;
5058 var id = 0;
5059 var random = '' + Math.random();
5060 var prefix = '__\x01symbol:';
5061 var prefixLength = prefix.length;
5062 var internalSymbol = '__\x01symbol@@' + random;
5063 var DP = 'defineProperty';
5064 var DPies = 'defineProperties';
5065 var GOPN = 'getOwnPropertyNames';
5066 var GOPD = 'getOwnPropertyDescriptor';
5067 var PIE = 'propertyIsEnumerable';
5068 var ObjectProto = Object.prototype;
5069 var hOP = ObjectProto.hasOwnProperty;
5070 var pIE = ObjectProto[PIE];
5071 var toString = ObjectProto.toString;
5072 var concat = Array.prototype.concat;
5073 var cachedWindowNames = Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
5074 var nGOPN = Object[GOPN];
5075 var gOPN = function getOwnPropertyNames (obj) {
5076 if (toString.call(obj) === '[object Window]') {
5077 try {
5078 return nGOPN(obj);
5079 } catch (e) {
5080 // IE bug where layout engine calls userland gOPN for cross-domain `window` objects
5081 return concat.call([], cachedWindowNames);
5082 }
5083 }
5084 return nGOPN(obj);
5085 };
5086 var gOPD = Object[GOPD];
5087 var create = Object.create;
5088 var keys = Object.keys;
5089 var freeze = Object.freeze || Object;
5090 var defineProperty = Object[DP];
5091 var $defineProperties = Object[DPies];
5092 var descriptor = gOPD(Object, GOPN);
5093 var addInternalIfNeeded = function (o, uid, enumerable) {
5094 if (!hOP.call(o, internalSymbol)) {
5095 try {
5096 defineProperty(o, internalSymbol, {
5097 enumerable: false,
5098 configurable: false,
5099 writable: false,
5100 value: {}
5101 });
5102 } catch (e) {
5103 o[internalSymbol] = {};
5104 }
5105 }
5106 o[internalSymbol]['@@' + uid] = enumerable;
5107 };
5108 var createWithSymbols = function (proto, descriptors) {
5109 var self = create(proto);
5110 gOPN(descriptors).forEach(function (key) {
5111 if (propertyIsEnumerable.call(descriptors, key)) {
5112 $defineProperty(self, key, descriptors[key]);
5113 }
5114 });
5115 return self;
5116 };
5117 var copyAsNonEnumerable = function (descriptor) {
5118 var newDescriptor = create(descriptor);
5119 newDescriptor.enumerable = false;
5120 return newDescriptor;
5121 };
5122 var get = function get() {};
5123 var onlyNonSymbols = function (name) {
5124 return name != internalSymbol &&
5125 !hOP.call(source, name);
5126 };
5127 var onlySymbols = function (name) {
5128 return name != internalSymbol &&
5129 hOP.call(source, name);
5130 };
5131 var propertyIsEnumerable = function propertyIsEnumerable(key) {
5132 var uid = '' + key;
5133 return onlySymbols(uid) ? (
5134 hOP.call(this, uid) &&
5135 this[internalSymbol]['@@' + uid]
5136 ) : pIE.call(this, key);
5137 };
5138 var setAndGetSymbol = function (uid) {
5139 var descriptor = {
5140 enumerable: false,
5141 configurable: true,
5142 get: get,
5143 set: function (value) {
5144 setDescriptor(this, uid, {
5145 enumerable: false,
5146 configurable: true,
5147 writable: true,
5148 value: value
5149 });
5150 addInternalIfNeeded(this, uid, true);
5151 }
5152 };
5153 try {
5154 defineProperty(ObjectProto, uid, descriptor);
5155 } catch (e) {
5156 ObjectProto[uid] = descriptor.value;
5157 }
5158 return freeze(source[uid] = defineProperty(
5159 Object(uid),
5160 'constructor',
5161 sourceConstructor
5162 ));
5163 };
5164 var Symbol = function Symbol() {
5165 var description = arguments[0];
5166 if (this instanceof Symbol) {
5167 throw new TypeError('Symbol is not a constructor');
5168 }
5169 return setAndGetSymbol(
5170 prefix.concat(description || '', random, ++id)
5171 );
5172 };
5173 var source = create(null);
5174 var sourceConstructor = {
5175 value: Symbol
5176 };
5177 var sourceMap = function (uid) {
5178 return source[uid];
5179 };
5180 var $defineProperty = function defineProp(o, key, descriptor) {
5181 var uid = '' + key;
5182 if (onlySymbols(uid)) {
5183 setDescriptor(o, uid, descriptor.enumerable ?
5184 copyAsNonEnumerable(descriptor) : descriptor);
5185 addInternalIfNeeded(o, uid, !!descriptor.enumerable);
5186 } else {
5187 defineProperty(o, key, descriptor);
5188 }
5189 return o;
5190 };
5191
5192 var onlyInternalSymbols = function (obj) {
5193 return function (name) {
5194 return hOP.call(obj, internalSymbol) && hOP.call(obj[internalSymbol], '@@' + name);
5195 };
5196 };
5197 var $getOwnPropertySymbols = function getOwnPropertySymbols(o) {
5198 return gOPN(o).filter(o === ObjectProto ? onlyInternalSymbols(o) : onlySymbols).map(sourceMap);
5199 };
5200
5201 descriptor.value = $defineProperty;
5202 defineProperty(Object, DP, descriptor);
5203
5204 descriptor.value = $getOwnPropertySymbols;
5205 defineProperty(Object, GOPS, descriptor);
5206
5207 descriptor.value = function getOwnPropertyNames(o) {
5208 return gOPN(o).filter(onlyNonSymbols);
5209 };
5210 defineProperty(Object, GOPN, descriptor);
5211
5212 descriptor.value = function defineProperties(o, descriptors) {
5213 var symbols = $getOwnPropertySymbols(descriptors);
5214 if (symbols.length) {
5215 keys(descriptors).concat(symbols).forEach(function (uid) {
5216 if (propertyIsEnumerable.call(descriptors, uid)) {
5217 $defineProperty(o, uid, descriptors[uid]);
5218 }
5219 });
5220 } else {
5221 $defineProperties(o, descriptors);
5222 }
5223 return o;
5224 };
5225 defineProperty(Object, DPies, descriptor);
5226
5227 descriptor.value = propertyIsEnumerable;
5228 defineProperty(ObjectProto, PIE, descriptor);
5229
5230 descriptor.value = Symbol;
5231 defineProperty(global, 'Symbol', descriptor);
5232
5233 // defining `Symbol.for(key)`
5234 descriptor.value = function (key) {
5235 var uid = prefix.concat(prefix, key, random);
5236 return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid);
5237 };
5238 defineProperty(Symbol, 'for', descriptor);
5239
5240 // defining `Symbol.keyFor(symbol)`
5241 descriptor.value = function (symbol) {
5242 if (onlyNonSymbols(symbol))
5243 throw new TypeError(symbol + ' is not a symbol');
5244 return hOP.call(source, symbol) ?
5245 symbol.slice(prefixLength * 2, - random.length) :
5246 void 0
5247 ;
5248 };
5249 defineProperty(Symbol, 'keyFor', descriptor);
5250
5251 descriptor.value = function getOwnPropertyDescriptor(o, key) {
5252 var descriptor = gOPD(o, key);
5253 if (descriptor && onlySymbols(key)) {
5254 descriptor.enumerable = propertyIsEnumerable.call(o, key);
5255 }
5256 return descriptor;
5257 };
5258 defineProperty(Object, GOPD, descriptor);
5259
5260 descriptor.value = function (proto, descriptors) {
5261 return arguments.length === 1 || typeof descriptors === "undefined" ?
5262 create(proto) :
5263 createWithSymbols(proto, descriptors);
5264 };
5265 defineProperty(Object, 'create', descriptor);
5266
5267 var strictModeSupported = (function() {
5268 'use strict';
5269 return this;
5270 }).call(null) === null;
5271 if (strictModeSupported) {
5272 descriptor.value = function () {
5273 var str = toString.call(this);
5274 return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
5275 };
5276 } else {
5277 descriptor.value = function () {
5278 // https://github.com/Financial-Times/polyfill-library/issues/164#issuecomment-486965300
5279 // Polyfill.io this code is here for the situation where a browser does not
5280 // support strict mode and is executing `Object.prototype.toString.call(null)`.
5281 // This code ensures that we return the correct result in that situation however,
5282 // this code also introduces a bug where it will return the incorrect result for
5283 // `Object.prototype.toString.call(window)`. We can't have the correct result for
5284 // both `window` and `null`, so we have opted for `null` as we believe this is the more
5285 // common situation.
5286 if (this === window) {
5287 return '[object Null]';
5288 }
5289
5290 var str = toString.call(this);
5291 return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
5292 };
5293 }
5294 defineProperty(ObjectProto, 'toString', descriptor);
5295
5296 setDescriptor = function (o, key, descriptor) {
5297 var protoDescriptor = gOPD(ObjectProto, key);
5298 delete ObjectProto[key];
5299 defineProperty(o, key, descriptor);
5300 if (o !== ObjectProto) {
5301 defineProperty(ObjectProto, key, protoDescriptor);
5302 }
5303 };
5304
5305 }(Object, 'getOwnPropertySymbols', this));
5306
5307 }
5308
5309 if (!("Symbol"in this && "hasInstance"in this.Symbol
5310 )) {
5311
5312 // Symbol.hasInstance
5313 /* global Symbol */
5314 Object.defineProperty(Symbol, 'hasInstance', {
5315 value: Symbol('hasInstance')
5316 });
5317
5318 }
5319
5320 if (!("Symbol"in this && "isConcatSpreadable"in this.Symbol
5321 )) {
5322
5323 // Symbol.isConcatSpreadable
5324 /* global Symbol */
5325 Object.defineProperty(Symbol, 'isConcatSpreadable', {
5326 value: Symbol('isConcatSpreadable')
5327 });
5328
5329 }
5330
5331 if (!("Symbol"in this && "iterator"in this.Symbol
5332 )) {
5333
5334 // Symbol.iterator
5335 /* global Symbol */
5336 Object.defineProperty(Symbol, 'iterator', {
5337 value: Symbol('iterator')
5338 });
5339
5340 }
5341
5342
5343 // _ESAbstract.GetIterator
5344 /* global GetMethod, Symbol, Call, Type, GetV */
5345 // 7.4.1. GetIterator ( obj [ , method ] )
5346 // The abstract operation GetIterator with argument obj and optional argument method performs the following steps:
5347 function GetIterator(obj /*, method */
5348 ) {
5349 // eslint-disable-line no-unused-vars
5350 // 1. If method is not present, then
5351 // a. Set method to ? GetMethod(obj, @@iterator).
5352 var method = arguments.length > 1 ? arguments[1] : GetMethod(obj, Symbol.iterator);
5353 // 2. Let iterator be ? Call(method, obj).
5354 var iterator = Call(method, obj);
5355 // 3. If Type(iterator) is not Object, throw a TypeError exception.
5356 if (Type(iterator) !== 'object') {
5357 throw new TypeError('bad iterator');
5358 }
5359 // 4. Let nextMethod be ? GetV(iterator, "next").
5360 var nextMethod = GetV(iterator, "next");
5361 // 5. Let iteratorRecord be Record {[[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false}.
5362 var iteratorRecord = Object.create(null);
5363 iteratorRecord['[[Iterator]]'] = iterator;
5364 iteratorRecord['[[NextMethod]]'] = nextMethod;
5365 iteratorRecord['[[Done]]'] = false;
5366 // 6. Return iteratorRecord.
5367 return iteratorRecord;
5368 }
5369 if (!("Symbol"in this && "match"in this.Symbol
5370 )) {
5371
5372 // Symbol.match
5373 /* global Symbol */
5374 Object.defineProperty(Symbol, 'match', {
5375 value: Symbol('match')
5376 });
5377
5378 }
5379
5380 if (!("Symbol"in this && "replace"in this.Symbol
5381 )) {
5382
5383 // Symbol.replace
5384 /* global Symbol */
5385 Object.defineProperty(Symbol, 'replace', {
5386 value: Symbol('replace')
5387 });
5388
5389 }
5390
5391 if (!("Symbol"in this && "search"in this.Symbol
5392 )) {
5393
5394 // Symbol.search
5395 /* global Symbol */
5396 Object.defineProperty(Symbol, 'search', {
5397 value: Symbol('search')
5398 });
5399
5400 }
5401
5402 if (!("Symbol"in this && "species"in this.Symbol
5403 )) {
5404
5405 // Symbol.species
5406 /* global Symbol */
5407 Object.defineProperty(Symbol, 'species', {
5408 value: Symbol('species')
5409 });
5410
5411 }
5412
5413 if (!("Map"in this && function(t) {
5414 try {
5415 var n = new Map([[1, 1], [2, 2]])
5416 return 0 === Map.length && 2 === n.size && "Symbol"in t && "iterator"in Symbol && "function" == typeof n[Symbol.iterator]
5417 } catch (i) {
5418 return !1
5419 }
5420 }(this)
5421 )) {
5422
5423 // Map
5424 /* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
5425 (function (global) {
5426 var supportsGetters = (function () {
5427 try {
5428 var a = {};
5429 Object.defineProperty(a, 't', {
5430 configurable: true,
5431 enumerable: false,
5432 get: function () {
5433 return true;
5434 },
5435 set: undefined
5436 });
5437 return !!a.t;
5438 } catch (e) {
5439 return false;
5440 }
5441 }());
5442
5443 // 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.
5444 var undefMarker = Symbol('undef');
5445 // 23.1.1.1 Map ( [ iterable ] )
5446 var Map = function Map( /* iterable */
5447 ) {
5448 // 1. If NewTarget is undefined, throw a TypeError exception.
5449 if (!(this instanceof Map)) {
5450 throw new TypeError('Constructor Map requires "new"');
5451 }
5452 // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%MapPrototype%", « [[MapData]] »).
5453 var map = OrdinaryCreateFromConstructor(this, Map.prototype, {
5454 _keys: [],
5455 _values: [],
5456 _size: 0,
5457 _es6Map: true
5458 });
5459
5460 // 3. Set map.[[MapData]] to a new empty List.
5461 // Polyfill.io - This step was done as part of step two.
5462
5463 // 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.
5464 if (!supportsGetters) {
5465 Object.defineProperty(map, 'size', {
5466 configurable: true,
5467 enumerable: false,
5468 writable: true,
5469 value: 0
5470 });
5471 }
5472
5473 // 4. If iterable is not present, let iterable be undefined.
5474 var iterable = arguments.length > 0 ? arguments[0] : undefined;
5475
5476 // 5. If iterable is either undefined or null, return map.
5477 if (iterable === null || iterable === undefined) {
5478 return map;
5479 }
5480
5481 // 6. Let adder be ? Get(map, "set").
5482 var adder = map.set;
5483
5484 // 7. If IsCallable(adder) is false, throw a TypeError exception.
5485 if (!IsCallable(adder)) {
5486 throw new TypeError("Map.prototype.set is not a function");
5487 }
5488
5489 // 8. Let iteratorRecord be ? GetIterator(iterable).
5490 try {
5491 var iteratorRecord = GetIterator(iterable);
5492 // 9. Repeat,
5493 while (true) {
5494 // a. Let next be ? IteratorStep(iteratorRecord).
5495 var next = IteratorStep(iteratorRecord);
5496 // b. If next is false, return map.
5497 if (next === false) {
5498 return map;
5499 }
5500 // c. Let nextItem be ? IteratorValue(next).
5501 var nextItem = IteratorValue(next);
5502 // d. If Type(nextItem) is not Object, then
5503 if (Type(nextItem) !== 'object') {
5504 // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
5505 try {
5506 throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
5507 } catch (error) {
5508 // ii. Return ? IteratorClose(iteratorRecord, error).
5509 return IteratorClose(iteratorRecord, error);
5510 }
5511 }
5512 try {
5513 // Polyfill.io - The try catch accounts for steps: f, h, and j.
5514
5515 // e. Let k be Get(nextItem, "0").
5516 var k = nextItem[0];
5517 // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
5518 // g. Let v be Get(nextItem, "1").
5519 var v = nextItem[1];
5520 // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
5521 // i. Let status be Call(adder, map, « k.[[Value]], v.[[Value]] »).
5522 adder.call(map, k, v);
5523 } catch (e) {
5524 // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
5525 return IteratorClose(iteratorRecord, e);
5526 }
5527 }
5528 } catch (e) {
5529 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
5530 if (Array.isArray(iterable) ||
5531 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
5532 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
5533 (!!iterable.callee)) {
5534 var index;
5535 var length = iterable.length;
5536 for (index = 0; index < length; index++) {
5537 adder.call(map, iterable[index][0], iterable[index][1]);
5538 }
5539 }
5540 }
5541 return map;
5542 };
5543
5544 // 23.1.2.1. Map.prototype
5545 // The initial value of Map.prototype is the intrinsic object %MapPrototype%.
5546 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
5547 Object.defineProperty(Map, 'prototype', {
5548 configurable: false,
5549 enumerable: false,
5550 writable: false,
5551 value: {}
5552 });
5553
5554 // 23.1.2.2 get Map [ @@species ]
5555 if (supportsGetters) {
5556 Object.defineProperty(Map, Symbol.species, {
5557 configurable: true,
5558 enumerable: false,
5559 get: function () {
5560 // 1. Return the this value.
5561 return this;
5562 },
5563 set: undefined
5564 });
5565 } else {
5566 CreateMethodProperty(Map, Symbol.species, Map);
5567 }
5568
5569 // 23.1.3.1 Map.prototype.clear ( )
5570 CreateMethodProperty(Map.prototype, 'clear', function clear() {
5571 // 1. Let M be the this value.
5572 var M = this;
5573 // 2. If Type(M) is not Object, throw a TypeError exception.
5574 if (Type(M) !== 'object') {
5575 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
5576 }
5577 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
5578 if (M._es6Map !== true) {
5579 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
5580 }
5581 // 4. Let entries be the List that is M.[[MapData]].
5582 var entries = M._keys;
5583 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
5584 for (var i = 0; i < entries.length; i++) {
5585 // 5.a. Set p.[[Key]] to empty.
5586 M._keys[i] = undefMarker;
5587 // 5.b. Set p.[[Value]] to empty.
5588 M._values[i] = undefMarker;
5589 }
5590 this._size = 0;
5591 if (!supportsGetters) {
5592 this.size = this._size;
5593 }
5594 // 6. Return undefined.
5595 return undefined;
5596 });
5597
5598 // 23.1.3.2. Map.prototype.constructor
5599 CreateMethodProperty(Map.prototype, 'constructor', Map);
5600
5601 // 23.1.3.3. Map.prototype.delete ( key )
5602 CreateMethodProperty(Map.prototype, 'delete', function (key) {
5603 // 1. Let M be the this value.
5604 var M = this;
5605 // 2. If Type(M) is not Object, throw a TypeError exception.
5606 if (Type(M) !== 'object') {
5607 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
5608 }
5609 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
5610 if (M._es6Map !== true) {
5611 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
5612 }
5613 // 4. Let entries be the List that is M.[[MapData]].
5614 var entries = M._keys;
5615 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
5616 for (var i = 0; i < entries.length; i++) {
5617 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
5618 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
5619 // i. Set p.[[Key]] to empty.
5620 this._keys[i] = undefMarker;
5621 // ii. Set p.[[Value]] to empty.
5622 this._values[i] = undefMarker;
5623 this._size = --this._size;
5624 if (!supportsGetters) {
5625 this.size = this._size;
5626 }
5627 // iii. Return true.
5628 return true;
5629 }
5630 }
5631 // 6. Return false.
5632 return false;
5633 });
5634
5635 // 23.1.3.4. Map.prototype.entries ( )
5636 CreateMethodProperty(Map.prototype, 'entries', function entries () {
5637 // 1. Let M be the this value.
5638 var M = this;
5639 // 2. Return ? CreateMapIterator(M, "key+value").
5640 return CreateMapIterator(M, 'key+value');
5641 });
5642
5643 // 23.1.3.5. Map.prototype.forEach ( callbackfn [ , thisArg ] )
5644 CreateMethodProperty(Map.prototype, 'forEach', function (callbackFn) {
5645 // 1. Let M be the this value.
5646 var M = this;
5647 // 2. If Type(M) is not Object, throw a TypeError exception.
5648 if (Type(M) !== 'object') {
5649 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
5650 }
5651 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
5652 if (M._es6Map !== true) {
5653 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
5654 }
5655 // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
5656 if (!IsCallable(callbackFn)) {
5657 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
5658 }
5659 // 5. If thisArg is present, let T be thisArg; else let T be undefined.
5660 if (arguments[1]) {
5661 var T = arguments[1];
5662 }
5663 // 6. Let entries be the List that is M.[[MapData]].
5664 var entries = M._keys;
5665 // 7. For each Record {[[Key]], [[Value]]} e that is an element of entries, in original key insertion order, do
5666 for (var i = 0; i < entries.length; i++) {
5667 // a. If e.[[Key]] is not empty, then
5668 if (M._keys[i] !== undefMarker && M._values[i] !== undefMarker ) {
5669 // i. Perform ? Call(callbackfn, T, « e.[[Value]], e.[[Key]], M »).
5670 callbackFn.call(T, M._values[i], M._keys[i], M);
5671 }
5672 }
5673 // 8. Return undefined.
5674 return undefined;
5675 });
5676
5677 // 23.1.3.6. Map.prototype.get ( key )
5678 CreateMethodProperty(Map.prototype, 'get', function get(key) {
5679 // 1. Let M be the this value.
5680 var M = this;
5681 // 2. If Type(M) is not Object, throw a TypeError exception.
5682 if (Type(M) !== 'object') {
5683 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
5684 }
5685 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
5686 if (M._es6Map !== true) {
5687 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
5688 }
5689 // 4. Let entries be the List that is M.[[MapData]].
5690 var entries = M._keys;
5691 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
5692 for (var i = 0; i < entries.length; i++) {
5693 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return p.[[Value]].
5694 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
5695 return M._values[i];
5696 }
5697 }
5698 // 6. Return undefined.
5699 return undefined;
5700 });
5701
5702 // 23.1.3.7. Map.prototype.has ( key )
5703 CreateMethodProperty(Map.prototype, 'has', function has (key) {
5704 // 1. Let M be the this value.
5705 var M = this;
5706 // 2. If Type(M) is not Object, throw a TypeError exception.
5707 if (typeof M !== 'object') {
5708 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
5709 }
5710 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
5711 if (M._es6Map !== true) {
5712 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
5713 }
5714 // 4. Let entries be the List that is M.[[MapData]].
5715 var entries = M._keys;
5716 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
5717 for (var i = 0; i < entries.length; i++) {
5718 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return true.
5719 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
5720 return true;
5721 }
5722 }
5723 // 6. Return false.
5724 return false;
5725 });
5726
5727 // 23.1.3.8. Map.prototype.keys ( )
5728 CreateMethodProperty(Map.prototype, 'keys', function keys () {
5729 // 1. Let M be the this value.
5730 var M = this;
5731 // 2. Return ? CreateMapIterator(M, "key").
5732 return CreateMapIterator(M, "key");
5733 });
5734
5735 // 23.1.3.9. Map.prototype.set ( key, value )
5736 CreateMethodProperty(Map.prototype, 'set', function set(key, value) {
5737 // 1. Let M be the this value.
5738 var M = this;
5739 // 2. If Type(M) is not Object, throw a TypeError exception.
5740 if (Type(M) !== 'object') {
5741 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
5742 }
5743 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
5744 if (M._es6Map !== true) {
5745 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
5746 }
5747 // 4. Let entries be the List that is M.[[MapData]].
5748 var entries = M._keys;
5749 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
5750 for (var i = 0; i < entries.length; i++) {
5751 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
5752 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
5753 // i. Set p.[[Value]] to value.
5754 M._values[i] = value;
5755 // Return M.
5756 return M;
5757 }
5758 }
5759 // 6. If key is -0, let key be +0.
5760 if (key === - 0) {
5761 key = 0;
5762 }
5763 // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
5764 var p = {};
5765 p['[[Key]]'] = key;
5766 p['[[Value]]'] = value;
5767 // 8. Append p as the last element of entries.
5768 M._keys.push(p['[[Key]]']);
5769 M._values.push(p['[[Value]]']);
5770 ++M._size;
5771 if (!supportsGetters) {
5772 M.size = M._size;
5773 }
5774 // 9. Return M.
5775 return M;
5776 });
5777
5778 // 23.1.3.10. get Map.prototype.size
5779 if (supportsGetters) {
5780 Object.defineProperty(Map.prototype, 'size', {
5781 configurable: true,
5782 enumerable: false,
5783 get: function () {
5784 // 1. Let M be the this value.
5785 var M = this;
5786 // 2. If Type(M) is not Object, throw a TypeError exception.
5787 if (Type(M) !== 'object') {
5788 throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
5789 }
5790 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
5791 if (M._es6Map !== true) {
5792 throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
5793 }
5794 // 4. Let entries be the List that is M.[[MapData]].
5795 var entries = M._keys;
5796 // 5. Let count be 0.
5797 var count = 0;
5798 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
5799 for (var i = 0; i < entries.length; i++) {
5800 // a. If p.[[Key]] is not empty, set count to count+1.
5801 if (M._keys[i] !== undefMarker) {
5802 count = count + 1;
5803 }
5804 }
5805 // 7. Return count.
5806 return count;
5807 },
5808 set: undefined
5809 });
5810 }
5811
5812 // 23.1.3.11. Map.prototype.values ( )
5813 CreateMethodProperty(Map.prototype, 'values', function values () {
5814 // 1. Let M be the this value.
5815 var M = this;
5816 // 2. Return ? CreateMapIterator(M, "value").
5817 return CreateMapIterator(M, 'value');
5818 });
5819
5820 // 23.1.3.12. Map.prototype [ @@iterator ] ( )
5821 // The initial value of the @@iterator property is the same function object as the initial value of the entries property.
5822 CreateMethodProperty(Map.prototype, Symbol.iterator, Map.prototype.entries);
5823
5824 // 23.1.3.13. Map.prototype [ @@toStringTag ]
5825 // The initial value of the @@toStringTag property is the String value "Map".
5826 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
5827
5828 // 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.
5829 if (!('name' in Map)) {
5830 // 19.2.4.2 name
5831 Object.defineProperty(Map, 'name', {
5832 configurable: true,
5833 enumerable: false,
5834 writable: false,
5835 value: 'Map'
5836 });
5837 }
5838
5839 // 23.1.5.1. CreateMapIterator ( map, kind )
5840 function CreateMapIterator(map, kind) {
5841 // 1. If Type(map) is not Object, throw a TypeError exception.
5842 if (Type(map) !== 'object') {
5843 throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
5844 }
5845 // 2. If map does not have a [[MapData]] internal slot, throw a TypeError exception.
5846 if (map._es6Map !== true) {
5847 throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
5848 }
5849 // 3. Let iterator be ObjectCreate(%MapIteratorPrototype%, « [[Map]], [[MapNextIndex]], [[MapIterationKind]] »).
5850 var iterator = Object.create(MapIteratorPrototype);
5851 // 4. Set iterator.[[Map]] to map.
5852 Object.defineProperty(iterator, '[[Map]]', {
5853 configurable: true,
5854 enumerable: false,
5855 writable: true,
5856 value: map
5857 });
5858 // 5. Set iterator.[[MapNextIndex]] to 0.
5859 Object.defineProperty(iterator, '[[MapNextIndex]]', {
5860 configurable: true,
5861 enumerable: false,
5862 writable: true,
5863 value: 0
5864 });
5865 // 6. Set iterator.[[MapIterationKind]] to kind.
5866 Object.defineProperty(iterator, '[[MapIterationKind]]', {
5867 configurable: true,
5868 enumerable: false,
5869 writable: true,
5870 value: kind
5871 });
5872 // 7. Return iterator.
5873 return iterator;
5874 }
5875
5876 // 23.1.5.2. The %MapIteratorPrototype% Object
5877 var MapIteratorPrototype = {};
5878 // Polyfill.io - We use this as a quick way to check if an object is a Map Iterator instance.
5879 Object.defineProperty(MapIteratorPrototype, 'isMapIterator', {
5880 configurable: false,
5881 enumerable: false,
5882 writable: false,
5883 value: true
5884 });
5885
5886 // 23.1.5.2.1. %MapIteratorPrototype%.next ( )
5887 CreateMethodProperty(MapIteratorPrototype, 'next', function next() {
5888 // 1. Let O be the this value.
5889 var O = this;
5890 // 2. If Type(O) is not Object, throw a TypeError exception.
5891 if (Type(O) !== 'object') {
5892 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
5893 }
5894 // 3. If O does not have all of the internal slots of a Map Iterator Instance (23.1.5.3), throw a TypeError exception.
5895 if (!O.isMapIterator) {
5896 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
5897 }
5898 // 4. Let m be O.[[Map]].
5899 var m = O['[[Map]]'];
5900 // 5. Let index be O.[[MapNextIndex]].
5901 var index = O['[[MapNextIndex]]'];
5902 // 6. Let itemKind be O.[[MapIterationKind]].
5903 var itemKind = O['[[MapIterationKind]]'];
5904 // 7. If m is undefined, return CreateIterResultObject(undefined, true).
5905 if (m === undefined) {
5906 return CreateIterResultObject(undefined, true);
5907 }
5908 // 8. Assert: m has a [[MapData]] internal slot.
5909 if (!m._es6Map) {
5910 throw new Error(Object.prototype.toString.call(m) + ' has a [[MapData]] internal slot.');
5911 }
5912 // 9. Let entries be the List that is m.[[MapData]].
5913 var entries = m._keys;
5914 // 10. Let numEntries be the number of elements of entries.
5915 var numEntries = entries.length;
5916 // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
5917 // 12. Repeat, while index is less than numEntries,
5918 while (index < numEntries) {
5919 // a. Let e be the Record {[[Key]], [[Value]]} that is the value of entries[index].
5920 var e = Object.create(null);
5921 e['[[Key]]'] = m._keys[index];
5922 e['[[Value]]'] = m._values[index];
5923 // b. Set index to index+1.
5924 index = index + 1;
5925 // c. Set O.[[MapNextIndex]] to index.
5926 O['[[MapNextIndex]]'] = index;
5927 // d. If e.[[Key]] is not empty, then
5928 if (e['[[Key]]'] !== undefMarker) {
5929 // i. If itemKind is "key", let result be e.[[Key]].
5930 if (itemKind === 'key') {
5931 var result = e['[[Key]]'];
5932 // ii. Else if itemKind is "value", let result be e.[[Value]].
5933 } else if (itemKind === 'value') {
5934 result = e['[[Value]]'];
5935 // iii. Else,
5936 } else {
5937 // 1. Assert: itemKind is "key+value".
5938 if (itemKind !== 'key+value') {
5939 throw new Error();
5940 }
5941 // 2. Let result be CreateArrayFromList(« e.[[Key]], e.[[Value]] »).
5942 result = [
5943 e['[[Key]]'],
5944 e['[[Value]]']
5945 ];
5946 }
5947 // iv. Return CreateIterResultObject(result, false).
5948 return CreateIterResultObject(result, false);
5949 }
5950 }
5951 // 13. Set O.[[Map]] to undefined.
5952 O['[[Map]]'] = undefined;
5953 // 14. Return CreateIterResultObject(undefined, true).
5954 return CreateIterResultObject(undefined, true);
5955 });
5956
5957 // 23.1.5.2.2 %MapIteratorPrototype% [ @@toStringTag ]
5958 // The initial value of the @@toStringTag property is the String value "Map Iterator".
5959 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
5960
5961 CreateMethodProperty(MapIteratorPrototype, Symbol.iterator, function iterator() {
5962 return this;
5963 });
5964
5965 // Export the object
5966 try {
5967 CreateMethodProperty(global, 'Map', Map);
5968 } catch (e) {
5969 // IE8 throws an error here if we set enumerable to false.
5970 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
5971 global['Map'] = Map;
5972 }
5973 }(this));
5974
5975 }
5976
5977 if (!("Set"in this && function() {
5978 try {
5979 var t = new Set([1, 2])
5980 return 0 === Set.length && 2 === t.size && "Symbol"in this && "iterator"in Symbol && "function" == typeof t[Symbol.iterator]
5981 } catch (e) {
5982 return !1
5983 }
5984 }()
5985 )) {
5986
5987 // Set
5988 /* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Symbol */
5989 (function (global) {
5990 var supportsGetters = (function () {
5991 try {
5992 var a = {};
5993 Object.defineProperty(a, 't', {
5994 configurable: true,
5995 enumerable: false,
5996 get: function () {
5997 return true;
5998 },
5999 set: undefined
6000 });
6001 return !!a.t;
6002 } catch (e) {
6003 return false;
6004 }
6005 }());
6006
6007 // 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.
6008 var undefMarker = Symbol('undef');
6009 // 23.2.1.1. Set ( [ iterable ] )
6010 var Set = function Set( /* iterable */
6011 ) {
6012 // 1. If NewTarget is undefined, throw a TypeError exception.
6013 if (!(this instanceof Set)) {
6014 throw new TypeError('Constructor Set requires "new"');
6015 }
6016 // 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%SetPrototype%", « [[SetData]] »).
6017 var set = OrdinaryCreateFromConstructor(this, Set.prototype, {
6018 _values: [],
6019 _size: 0,
6020 _es6Set: true
6021 });
6022
6023 // 3. Set set.[[SetData]] to a new empty List.
6024 // Polyfill.io - This step was done as part of step two.
6025
6026 // 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.
6027 if (!supportsGetters) {
6028 Object.defineProperty(set, 'size', {
6029 configurable: true,
6030 enumerable: false,
6031 writable: true,
6032 value: 0
6033 });
6034 }
6035
6036 // 4. If iterable is not present, let iterable be undefined.
6037 var iterable = arguments.length > 0 ? arguments[0] : undefined;
6038
6039 // 5. If iterable is either undefined or null, return set.
6040 if (iterable === null || iterable === undefined) {
6041 return set;
6042 }
6043
6044 // 6. Let adder be ? Get(set, "add").
6045 var adder = set.add;
6046 // 7. If IsCallable(adder) is false, throw a TypeError exception.
6047 if (!IsCallable(adder)) {
6048 throw new TypeError("Set.prototype.add is not a function");
6049 }
6050
6051 try {
6052 // 8. Let iteratorRecord be ? GetIterator(iterable).
6053 var iteratorRecord = GetIterator(iterable);
6054 // 9. Repeat,
6055 while (true) {
6056 // a. Let next be ? IteratorStep(iteratorRecord).
6057 var next = IteratorStep(iteratorRecord);
6058 // b. If next is false, return set.
6059 if (next === false) {
6060 return set;
6061 }
6062 // c. Let nextValue be ? IteratorValue(next).
6063 var nextValue = IteratorValue(next);
6064 // d. Let status be Call(adder, set, « nextValue.[[Value]] »).
6065 try {
6066 adder.call(set, nextValue);
6067 } catch (e) {
6068 // e. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
6069 return IteratorClose(iteratorRecord, e);
6070 }
6071 }
6072 } catch (e) {
6073 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
6074 if (Array.isArray(iterable) ||
6075 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
6076 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
6077 (!!iterable.callee)) {
6078 var index;
6079 var length = iterable.length;
6080 for (index = 0; index < length; index++) {
6081 adder.call(set, iterable[index]);
6082 }
6083 } else {
6084 throw (e);
6085 }
6086 }
6087 return set;
6088 };
6089
6090 // 23.2.2.1. Set.prototype
6091 // The initial value of Set.prototype is the intrinsic %SetPrototype% object.
6092 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
6093 Object.defineProperty(Set, 'prototype', {
6094 configurable: false,
6095 enumerable: false,
6096 writable: false,
6097 value: {}
6098 });
6099
6100 // 23.2.2.2 get Set [ @@species ]
6101 if (supportsGetters) {
6102 Object.defineProperty(Set, Symbol.species, {
6103 configurable: true,
6104 enumerable: false,
6105 get: function () {
6106 // 1. Return the this value.
6107 return this;
6108 },
6109 set: undefined
6110 });
6111 } else {
6112 CreateMethodProperty(Set, Symbol.species, Set);
6113 }
6114
6115 // 23.2.3.1. Set.prototype.add ( value )
6116 CreateMethodProperty(Set.prototype, 'add', function add(value) {
6117 // 1. Let S be the this value.
6118 var S = this;
6119 // 2. If Type(S) is not Object, throw a TypeError exception.
6120 if (typeof S !== 'object') {
6121 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
6122 }
6123 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
6124 if (S._es6Set !== true) {
6125 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
6126 }
6127 // 4. Let entries be the List that is S.[[SetData]].
6128 var entries = S._values;
6129 // 5. For each e that is an element of entries, do
6130 for (var i = 0; i < entries.length; i++) {
6131 var e = entries[i];
6132 // a. If e is not empty and SameValueZero(e, value) is true, then
6133 if (e !== undefMarker && SameValueZero(e, value)) {
6134 // i. Return S.
6135 return S;
6136 }
6137 }
6138 // 6. If value is -0, let value be +0.
6139 if (1 / value === - Infinity) {
6140 value = 0;
6141 }
6142 // 7. Append value as the last element of entries.
6143 S._values.push(value);
6144
6145 this._size = ++this._size;
6146 if (!supportsGetters) {
6147 this.size = this._size;
6148 }
6149 // 8. Return S.
6150 return S;
6151 });
6152
6153 // 23.2.3.2. Set.prototype.clear ( )
6154 CreateMethodProperty(Set.prototype, 'clear', function clear() {
6155 // 1. Let S be the this value.
6156 var S = this;
6157 // 2. If Type(S) is not Object, throw a TypeError exception.
6158 if (typeof S !== 'object') {
6159 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
6160 }
6161 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
6162 if (S._es6Set !== true) {
6163 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
6164 }
6165 // 4. Let entries be the List that is S.[[SetData]].
6166 var entries = S._values;
6167 // 5. For each e that is an element of entries, do
6168 for (var i = 0; i < entries.length; i++) {
6169 // a. Replace the element of entries whose value is e with an element whose value is empty.
6170 entries[i] = undefMarker;
6171 }
6172 this._size = 0;
6173 if (!supportsGetters) {
6174 this.size = this._size;
6175 }
6176 // 6. Return undefined.
6177 return undefined;
6178 });
6179
6180 // 23.2.3.3. Set.prototype.constructor
6181 CreateMethodProperty(Set.prototype, 'constructor', Set);
6182
6183 // 23.2.3.4. Set.prototype.delete ( value )
6184 CreateMethodProperty(Set.prototype, 'delete', function (value) {
6185 // 1. Let S be the this value.
6186 var S = this;
6187 // 2. If Type(S) is not Object, throw a TypeError exception.
6188 if (typeof S !== 'object') {
6189 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
6190 }
6191 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
6192 if (S._es6Set !== true) {
6193 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
6194 }
6195 // 4. Let entries be the List that is S.[[SetData]].
6196 var entries = S._values;
6197 // 5. For each e that is an element of entries, do
6198 for (var i = 0; i < entries.length; i++) {
6199 var e = entries[i];
6200 // a. If e is not empty and SameValueZero(e, value) is true, then
6201 if (e !== undefMarker && SameValueZero(e, value)) {
6202 // i. Replace the element of entries whose value is e with an element whose value is empty.
6203 entries[i] = undefMarker;
6204
6205 this._size = --this._size;
6206 if (!supportsGetters) {
6207 this.size = this._size;
6208 }
6209 // ii. Return true.
6210 return true;
6211 }
6212 }
6213 // 6. Return false.
6214 return false;
6215 });
6216
6217 // 23.2.3.5. Set.prototype.entries ( )
6218 CreateMethodProperty(Set.prototype, 'entries', function entries() {
6219 // 1. Let S be the this value.
6220 var S = this;
6221 // 2. Return ? CreateSetIterator(S, "key+value").
6222 return CreateSetIterator(S, 'key+value');
6223 });
6224
6225 // 23.2.3.6. Set.prototype.forEach ( callbackfn [ , thisArg ] )
6226 CreateMethodProperty(Set.prototype, 'forEach', function forEach(callbackFn /*[ , thisArg ]*/
6227 ) {
6228 // 1. Let S be the this value.
6229 var S = this;
6230 // 2. If Type(S) is not Object, throw a TypeError exception.
6231 if (typeof S !== 'object') {
6232 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
6233 }
6234 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
6235 if (S._es6Set !== true) {
6236 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
6237 }
6238 // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
6239 if (!IsCallable(callbackFn)) {
6240 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
6241 }
6242 // 5. If thisArg is present, let T be thisArg; else let T be undefined.
6243 if (arguments[1]) {
6244 var T = arguments[1];
6245 }
6246 // 6. Let entries be the List that is S.[[SetData]].
6247 var entries = S._values;
6248 // 7. For each e that is an element of entries, in original insertion order, do
6249 for (var i = 0; i < entries.length; i++) {
6250 var e = entries[i];
6251 // a. If e is not empty, then
6252 if (e !== undefMarker) {
6253 // i. Perform ? Call(callbackfn, T, « e, e, S »).
6254 callbackFn.call(T, e, e, S);
6255 }
6256 }
6257 // 8. Return undefined.
6258 return undefined;
6259 });
6260
6261 // 23.2.3.7. Set.prototype.has ( value )
6262 CreateMethodProperty(Set.prototype, 'has', function has(value) {
6263 // 1. Let S be the this value.
6264 var S = this;
6265 // 2. If Type(S) is not Object, throw a TypeError exception.
6266 if (typeof S !== 'object') {
6267 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
6268 }
6269 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
6270 if (S._es6Set !== true) {
6271 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
6272 }
6273 // 4. Let entries be the List that is S.[[SetData]].
6274 var entries = S._values;
6275 // 5. For each e that is an element of entries, do
6276 for (var i = 0; i < entries.length; i++) {
6277 var e = entries[i];
6278 // a. If e is not empty and SameValueZero(e, value) is true, return true.
6279 if (e !== undefMarker && SameValueZero(e, value)) {
6280 return true;
6281 }
6282 }
6283 // 6. Return false.
6284 return false;
6285 });
6286
6287 // Polyfill.io - We need to define Set.prototype.values before Set.prototype.keys because keys is a reference to values.
6288 // 23.2.3.10. Set.prototype.values()
6289 var values = function values() {
6290 // 1. Let S be the this value.
6291 var S = this;
6292 // 2. Return ? CreateSetIterator(S, "value").
6293 return CreateSetIterator(S, "value");
6294 };
6295 CreateMethodProperty(Set.prototype, 'values', values);
6296
6297 // 23.2.3.8 Set.prototype.keys ( )
6298 // The initial value of the keys property is the same function object as the initial value of the values property.
6299 CreateMethodProperty(Set.prototype, 'keys', values);
6300
6301 // 23.2.3.9. get Set.prototype.size
6302 if (supportsGetters) {
6303 Object.defineProperty(Set.prototype, 'size', {
6304 configurable: true,
6305 enumerable: false,
6306 get: function () {
6307 // 1. Let S be the this value.
6308 var S = this;
6309 // 2. If Type(S) is not Object, throw a TypeError exception.
6310 if (typeof S !== 'object') {
6311 throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
6312 }
6313 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
6314 if (S._es6Set !== true) {
6315 throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
6316 }
6317 // 4. Let entries be the List that is S.[[SetData]].
6318 var entries = S._values;
6319 // 5. Let count be 0.
6320 var count = 0;
6321 // 6. For each e that is an element of entries, do
6322 for (var i = 0; i < entries.length; i++) {
6323 var e = entries[i];
6324 // a. If e is not empty, set count to count+1.
6325 if (e !== undefMarker) {
6326 count = count + 1;
6327 }
6328 }
6329 // 7. Return count.
6330 return count;
6331 },
6332 set: undefined
6333 });
6334 }
6335
6336 // 23.2.3.11. Set.prototype [ @@iterator ] ( )
6337 // The initial value of the @@iterator property is the same function object as the initial value of the values property.
6338 CreateMethodProperty(Set.prototype, Symbol.iterator, values);
6339
6340 // 23.2.3.12. Set.prototype [ @@toStringTag ]
6341 // The initial value of the @@toStringTag property is the String value "Set".
6342 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
6343
6344 // 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.
6345 if (!('name' in Set)) {
6346 // 19.2.4.2 name
6347 Object.defineProperty(Set, 'name', {
6348 configurable: true,
6349 enumerable: false,
6350 writable: false,
6351 value: 'Set'
6352 });
6353 }
6354
6355 // 23.2.5.1. CreateSetIterator ( set, kind )
6356 function CreateSetIterator(set, kind) {
6357 // 1. If Type(set) is not Object, throw a TypeError exception.
6358 if (typeof set !== 'object') {
6359 throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
6360 }
6361 // 2. If set does not have a [[SetData]] internal slot, throw a TypeError exception.
6362 if (set._es6Set !== true) {
6363 throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
6364 }
6365 // 3. Let iterator be ObjectCreate(%SetIteratorPrototype%, « [[IteratedSet]], [[SetNextIndex]], [[SetIterationKind]] »).
6366 var iterator = Object.create(SetIteratorPrototype);
6367 // 4. Set iterator.[[IteratedSet]] to set.
6368 Object.defineProperty(iterator, '[[IteratedSet]]', {
6369 configurable: true,
6370 enumerable: false,
6371 writable: true,
6372 value: set
6373 });
6374 // 5. Set iterator.[[SetNextIndex]] to 0.
6375 Object.defineProperty(iterator, '[[SetNextIndex]]', {
6376 configurable: true,
6377 enumerable: false,
6378 writable: true,
6379 value: 0
6380 });
6381 // 6. Set iterator.[[SetIterationKind]] to kind.
6382 Object.defineProperty(iterator, '[[SetIterationKind]]', {
6383 configurable: true,
6384 enumerable: false,
6385 writable: true,
6386 value: kind
6387 });
6388 // 7. Return iterator.
6389 return iterator;
6390 }
6391
6392 // 23.2.5.2. The %SetIteratorPrototype% Object
6393 var SetIteratorPrototype = {};
6394 //Polyfill.io - We add this property to help us identify what is a set iterator.
6395 Object.defineProperty(SetIteratorPrototype, 'isSetIterator', {
6396 configurable: false,
6397 enumerable: false,
6398 writable: false,
6399 value: true
6400 });
6401
6402 // 23.2.5.2.1. %SetIteratorPrototype%.next ( )
6403 CreateMethodProperty(SetIteratorPrototype, 'next', function next() {
6404 // 1. Let O be the this value.
6405 var O = this;
6406 // 2. If Type(O) is not Object, throw a TypeError exception.
6407 if (typeof O !== 'object') {
6408 throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
6409 }
6410 // 3. If O does not have all of the internal slots of a Set Iterator Instance (23.2.5.3), throw a TypeError exception.
6411 if (!O.isSetIterator) {
6412 throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
6413 }
6414 // 4. Let s be O.[[IteratedSet]].
6415 var s = O['[[IteratedSet]]'];
6416 // 5. Let index be O.[[SetNextIndex]].
6417 var index = O['[[SetNextIndex]]'];
6418 // 6. Let itemKind be O.[[SetIterationKind]].
6419 var itemKind = O['[[SetIterationKind]]'];
6420 // 7. If s is undefined, return CreateIterResultObject(undefined, true).
6421 if (s === undefined) {
6422 return CreateIterResultObject(undefined, true);
6423 }
6424 // 8. Assert: s has a [[SetData]] internal slot.
6425 if (!s._es6Set) {
6426 throw new Error(Object.prototype.toString.call(s) + ' does not have [[SetData]] internal slot.');
6427 }
6428 // 9. Let entries be the List that is s.[[SetData]].
6429 var entries = s._values;
6430 // 10. Let numEntries be the number of elements of entries.
6431 var numEntries = entries.length;
6432 // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
6433 // 12. Repeat, while index is less than numEntries,
6434 while (index < numEntries) {
6435 // a. Let e be entries[index].
6436 var e = entries[index];
6437 // b. Set index to index+1.
6438 index = index + 1;
6439 // c. Set O.[[SetNextIndex]] to index.
6440 O['[[SetNextIndex]]'] = index;
6441 // d. If e is not empty, then
6442 if (e !== undefMarker) {
6443 // i. If itemKind is "key+value", then
6444 if (itemKind === 'key+value') {
6445 // 1. Return CreateIterResultObject(CreateArrayFromList(« e, e »), false).
6446 return CreateIterResultObject([e, e], false);
6447 }
6448 // ii. Return CreateIterResultObject(e, false).
6449 return CreateIterResultObject(e, false);
6450 }
6451 }
6452 // 13. Set O.[[IteratedSet]] to undefined.
6453 O['[[IteratedSet]]'] = undefined;
6454 // 14. Return CreateIterResultObject(undefined, true).
6455 return CreateIterResultObject(undefined, true);
6456 });
6457
6458 // 23.2.5.2.2. %SetIteratorPrototype% [ @@toStringTag ]
6459 // The initial value of the @@toStringTag property is the String value "Set Iterator".
6460 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
6461
6462 CreateMethodProperty(SetIteratorPrototype, Symbol.iterator, function iterator() {
6463 return this;
6464 });
6465
6466 // Export the object
6467 try {
6468 CreateMethodProperty(global, 'Set', Set);
6469 } catch (e) {
6470 // IE8 throws an error here if we set enumerable to false.
6471 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
6472 global['Set'] = Set;
6473 }
6474
6475 }(this));
6476
6477 }
6478
6479 if (!("from"in Array && function() {
6480 try {
6481 return Array.from({
6482 length: - Infinity
6483 }), !0
6484 } catch (r) {
6485 return !1
6486 }
6487 }()
6488 )) {
6489
6490 // Array.from
6491 /* globals
6492 IsCallable, GetMethod, Symbol, IsConstructor, Construct, ArrayCreate, GetIterator, IteratorClose,
6493 ToString, IteratorStep, IteratorValue, Call, CreateDataPropertyOrThrow, ToObject, ToLength, Get, CreateMethodProperty
6494 */
6495 (function () {
6496 var toString = Object.prototype.toString;
6497 var stringMatch = String.prototype.match;
6498 // A cross-realm friendly way to detect if a value is a String object or literal.
6499 function isString(value) {
6500 if (typeof value === 'string') {
6501 return true;
6502 }
6503 if (typeof value !== 'object') {
6504 return false;
6505 }
6506 return toString.call(value) === '[object String]';
6507 }
6508
6509 // 22.1.2.1. Array.from ( items [ , mapfn [ , thisArg ] ] )
6510 CreateMethodProperty(Array, 'from', function from(items /* [ , mapfn [ , thisArg ] ] */
6511 ) {
6512 // eslint-disable-line no-undef
6513 // 1. Let C be the this value.
6514 var C = this;
6515 // 2. If mapfn is undefined, let mapping be false.
6516 var mapfn = arguments.length > 1 ? arguments[1] : undefined;
6517 if (mapfn === undefined) {
6518 var mapping = false;
6519 // 3. Else,
6520 } else {
6521 // a. If IsCallable(mapfn) is false, throw a TypeError exception.
6522 if (IsCallable(mapfn) === false) {
6523 throw new TypeError(Object.prototype.toString.call(mapfn) + ' is not a function.');
6524 }
6525 // b. If thisArg is present, let T be thisArg; else let T be undefined.
6526 var thisArg = arguments.length > 2 ? arguments[2] : undefined;
6527 if (thisArg !== undefined) {
6528 var T = thisArg;
6529 } else {
6530 T = undefined;
6531 }
6532 // c. Let mapping be true.
6533 mapping = true;
6534
6535 }
6536 // 4. Let usingIterator be ? GetMethod(items, @@iterator).
6537 var usingIterator = GetMethod(items, Symbol.iterator);
6538 // 5. If usingIterator is not undefined, then
6539 if (usingIterator !== undefined) {
6540 // a. If IsConstructor(C) is true, then
6541 if (IsConstructor(C)) {
6542 // i. Let A be ? Construct(C).
6543 var A = Construct(C);
6544 // b. Else,
6545 } else {
6546 // i. Let A be ! ArrayCreate(0).
6547 A = ArrayCreate(0);
6548 }
6549 // c. Let iteratorRecord be ? GetIterator(items, usingIterator).
6550 var iteratorRecord = GetIterator(items, usingIterator);
6551 // d. Let k be 0.
6552 var k = 0;
6553 // e. Repeat,
6554 while (true) {
6555 // i. If k ≥ 2^53-1, then
6556 if (k >= (Math.pow(2, 53) - 1)) {
6557 // 1. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
6558 var error = new TypeError('Iteration count can not be greater than or equal 9007199254740991.');
6559 // 2. Return ? IteratorClose(iteratorRecord, error).
6560 return IteratorClose(iteratorRecord, error);
6561 }
6562 // ii. Let Pk be ! ToString(k).
6563 var Pk = ToString(k);
6564 // iii. Let next be ? IteratorStep(iteratorRecord).
6565 var next = IteratorStep(iteratorRecord);
6566 // iv. If next is false, then
6567 if (next === false) {
6568 // 1. Perform ? Set(A, "length", k, true).
6569 A["length"] = k;
6570 // 2. Return A.
6571 return A;
6572 }
6573 // v. Let nextValue be ? IteratorValue(next).
6574 var nextValue = IteratorValue(next);
6575 // vi. If mapping is true, then
6576 if (mapping) {
6577 try {
6578 // Polyfill.io - The try catch accounts for step 2.
6579 // 1. Let mappedValue be Call(mapfn, T, « nextValue, k »).
6580 var mappedValue = Call(mapfn, T, [nextValue, k]);
6581 // 2. If mappedValue is an abrupt completion, return ? IteratorClose(iteratorRecord, mappedValue).
6582 // 3. Let mappedValue be mappedValue.[[Value]].
6583 } catch (e) {
6584 return IteratorClose(iteratorRecord, e);
6585 }
6586
6587 // vii. Else, let mappedValue be nextValue.
6588 } else {
6589 mappedValue = nextValue;
6590 }
6591 try {
6592 // Polyfill.io - The try catch accounts for step ix.
6593 // viii. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, mappedValue).
6594 CreateDataPropertyOrThrow(A, Pk, mappedValue);
6595 // ix. If defineStatus is an abrupt completion, return ? IteratorClose(iteratorRecord, defineStatus).
6596 } catch (e) {
6597 return IteratorClose(iteratorRecord, e);
6598 }
6599 // x. Increase k by 1.
6600 k = k + 1;
6601 }
6602 }
6603 // 6. NOTE: items is not an Iterable so assume it is an array-like object.
6604 // 7. Let arrayLike be ! ToObject(items).
6605 // Polyfill.io - For Strings we need to split astral symbols into surrogate pairs.
6606 if (isString(items)) {
6607 var arrayLike = stringMatch.call(items, /[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g) || [];
6608 } else {
6609 arrayLike = ToObject(items);
6610 }
6611 // 8. Let len be ? ToLength(? Get(arrayLike, "length")).
6612 var len = ToLength(Get(arrayLike, "length"));
6613 // 9. If IsConstructor(C) is true, then
6614 if (IsConstructor(C)) {
6615 // a. Let A be ? Construct(C, « len »).
6616 A = Construct(C, [len]);
6617 // 10. Else,
6618 } else {
6619 // a. Let A be ? ArrayCreate(len).
6620 A = ArrayCreate(len);
6621 }
6622 // 11. Let k be 0.
6623 k = 0;
6624 // 12. Repeat, while k < len
6625 while (k < len) {
6626 // a. Let Pk be ! ToString(k).
6627 Pk = ToString(k);
6628 // b. Let kValue be ? Get(arrayLike, Pk).
6629 var kValue = Get(arrayLike, Pk);
6630 // c. If mapping is true, then
6631 if (mapping === true) {
6632 // i. Let mappedValue be ? Call(mapfn, T, « kValue, k »).
6633 mappedValue = Call(mapfn, T, [kValue, k]);
6634 // d. Else, let mappedValue be kValue.
6635 } else {
6636 mappedValue = kValue;
6637 }
6638 // e. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
6639 CreateDataPropertyOrThrow(A, Pk, mappedValue);
6640 // f. Increase k by 1.
6641 k = k + 1;
6642 }
6643 // 13. Perform ? Set(A, "length", len, true).
6644 A["length"] = len;
6645 // 14. Return A.
6646 return A;
6647 });
6648 }());
6649
6650 }
6651
6652 if (!("Symbol"in this && "split"in this.Symbol
6653 )) {
6654
6655 // Symbol.split
6656 /* global Symbol */
6657 Object.defineProperty(Symbol, 'split', {
6658 value: Symbol('split')
6659 });
6660
6661 }
6662
6663 if (!("Symbol"in this && "toPrimitive"in this.Symbol
6664 )) {
6665
6666 // Symbol.toPrimitive
6667 /* global Symbol */
6668 Object.defineProperty(Symbol, 'toPrimitive', {
6669 value: Symbol('toPrimitive')
6670 });
6671
6672 }
6673
6674 if (!("Symbol"in this && "toStringTag"in this.Symbol
6675 )) {
6676
6677 // Symbol.toStringTag
6678 /* global Symbol */
6679 Object.defineProperty(Symbol, 'toStringTag', {
6680 value: Symbol('toStringTag')
6681 });
6682
6683 }
6684
6685
6686 // _Iterator
6687 /* global Symbol */
6688 // A modification of https://github.com/medikoo/es6-iterator
6689 // Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
6690
6691 var Iterator = (function () {
6692 // eslint-disable-line no-unused-vars
6693 var clear = function () {
6694 this.length = 0;
6695 return this;
6696 };
6697 var callable = function (fn) {
6698 if (typeof fn !== 'function')
6699 throw new TypeError(fn + " is not a function");
6700 return fn;
6701 };
6702
6703 var Iterator = function (list, context) {
6704 if (!(this instanceof Iterator)) {
6705 return new Iterator(list, context);
6706 }
6707 Object.defineProperties(this, {
6708 __list__: {
6709 writable: true,
6710 value: list
6711 },
6712 __context__: {
6713 writable: true,
6714 value: context
6715 },
6716 __nextIndex__: {
6717 writable: true,
6718 value: 0
6719 }
6720 });
6721 if (!context)
6722 return;
6723 callable(context.on);
6724 context.on('_add', this._onAdd.bind(this));
6725 context.on('_delete', this._onDelete.bind(this));
6726 context.on('_clear', this._onClear.bind(this));
6727 };
6728
6729 Object.defineProperties(Iterator.prototype, Object.assign({
6730 constructor: {
6731 value: Iterator,
6732 configurable: true,
6733 enumerable: false,
6734 writable: true
6735 },
6736 _next: {
6737 value: function () {
6738 var i;
6739 if (!this.__list__)
6740 return;
6741 if (this.__redo__) {
6742 i = this.__redo__.shift();
6743 if (i !== undefined)
6744 return i;
6745 }
6746 if (this.__nextIndex__ < this.__list__.length)
6747 return this.__nextIndex__++;
6748 this._unBind();
6749 },
6750 configurable: true,
6751 enumerable: false,
6752 writable: true
6753 },
6754 next: {
6755 value: function () {
6756 return this._createResult(this._next());
6757 },
6758 configurable: true,
6759 enumerable: false,
6760 writable: true
6761 },
6762 _createResult: {
6763 value: function (i) {
6764 if (i === undefined)
6765 return {
6766 done: true,
6767 value: undefined
6768 };
6769 return {
6770 done: false,
6771 value: this._resolve(i)
6772 };
6773 },
6774 configurable: true,
6775 enumerable: false,
6776 writable: true
6777 },
6778 _resolve: {
6779 value: function (i) {
6780 return this.__list__[i];
6781 },
6782 configurable: true,
6783 enumerable: false,
6784 writable: true
6785 },
6786 _unBind: {
6787 value: function () {
6788 this.__list__ = null;
6789 delete this.__redo__;
6790 if (!this.__context__)
6791 return;
6792 this.__context__.off('_add', this._onAdd.bind(this));
6793 this.__context__.off('_delete', this._onDelete.bind(this));
6794 this.__context__.off('_clear', this._onClear.bind(this));
6795 this.__context__ = null;
6796 },
6797 configurable: true,
6798 enumerable: false,
6799 writable: true
6800 },
6801 toString: {
6802 value: function () {
6803 return '[object Iterator]';
6804 },
6805 configurable: true,
6806 enumerable: false,
6807 writable: true
6808 }
6809 }, {
6810 _onAdd: {
6811 value: function (index) {
6812 if (index >= this.__nextIndex__)
6813 return;
6814 ++this.__nextIndex__;
6815 if (!this.__redo__) {
6816 Object.defineProperty(this, '__redo__', {
6817 value: [index],
6818 configurable: true,
6819 enumerable: false,
6820 writable: false
6821 });
6822 return;
6823 }
6824 this.__redo__.forEach(function (redo, i) {
6825 if (redo >= index)
6826 this.__redo__[i] = ++redo;
6827 }, this);
6828 this.__redo__.push(index);
6829 },
6830 configurable: true,
6831 enumerable: false,
6832 writable: true
6833 },
6834 _onDelete: {
6835 value: function (index) {
6836 var i;
6837 if (index >= this.__nextIndex__)
6838 return;
6839 --this.__nextIndex__;
6840 if (!this.__redo__)
6841 return;
6842 i = this.__redo__.indexOf(index);
6843 if (i !== - 1)
6844 this.__redo__.splice(i, 1);
6845 this.__redo__.forEach(function (redo, i) {
6846 if (redo > index)
6847 this.__redo__[i] = --redo;
6848 }, this);
6849 },
6850 configurable: true,
6851 enumerable: false,
6852 writable: true
6853 },
6854 _onClear: {
6855 value: function () {
6856 if (this.__redo__)
6857 clear.call(this.__redo__);
6858 this.__nextIndex__ = 0;
6859 },
6860 configurable: true,
6861 enumerable: false,
6862 writable: true
6863 }
6864 }));
6865
6866 Object.defineProperty(Iterator.prototype, Symbol.iterator, {
6867 value: function () {
6868 return this;
6869 },
6870 configurable: true,
6871 enumerable: false,
6872 writable: true
6873 });
6874 Object.defineProperty(Iterator.prototype, Symbol.toStringTag, {
6875 value: 'Iterator',
6876 configurable: false,
6877 enumerable: false,
6878 writable: true
6879 });
6880
6881 return Iterator;
6882 }());
6883
6884 // _ArrayIterator
6885 /* global Iterator */
6886 // A modification of https://github.com/medikoo/es6-iterator
6887 // Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
6888
6889 var ArrayIterator = (function() {
6890 // eslint-disable-line no-unused-vars
6891
6892 var ArrayIterator = function(arr, kind) {
6893 if (!(this instanceof ArrayIterator))
6894 return new ArrayIterator(arr, kind);
6895 Iterator.call(this, arr);
6896 if (!kind)
6897 kind = 'value';
6898 else if (String.prototype.includes.call(kind, 'key+value'))
6899 kind = 'key+value';
6900 else if (String.prototype.includes.call(kind, 'key'))
6901 kind = 'key';
6902 else
6903 kind = 'value';
6904 Object.defineProperty(this, '__kind__', {
6905 value: kind,
6906 configurable: false,
6907 enumerable: false,
6908 writable: false
6909 });
6910 };
6911 if (Object.setPrototypeOf)
6912 Object.setPrototypeOf(ArrayIterator, Iterator.prototype);
6913
6914 ArrayIterator.prototype = Object.create(Iterator.prototype, {
6915 constructor: {
6916 value: ArrayIterator,
6917 configurable: true,
6918 enumerable: false,
6919 writable: true
6920 },
6921 _resolve: {
6922 value: function(i) {
6923 if (this.__kind__ === 'value')
6924 return this.__list__[i];
6925 if (this.__kind__ === 'key+value')
6926 return [i, this.__list__[i]];
6927 return i;
6928 },
6929 configurable: true,
6930 enumerable: false,
6931 writable: true
6932 },
6933 toString: {
6934 value: function() {
6935 return '[object Array Iterator]';
6936 },
6937 configurable: true,
6938 enumerable: false,
6939 writable: true
6940 }
6941 });
6942
6943 return ArrayIterator;
6944 }());
6945 if (!("Symbol"in this && "iterator"in this.Symbol&&!!Array.prototype.entries
6946 )) {
6947
6948 // Array.prototype.entries
6949 /* global CreateMethodProperty, ToObject */
6950 // 22.1.3.4. Array.prototype.entries ( )
6951 CreateMethodProperty(Array.prototype, 'entries', function entries() {
6952 // 1. Let O be ? ToObject(this value).
6953 var O = ToObject(this);
6954 // 2. Return CreateArrayIterator(O, "key+value").
6955 // TODO: Add CreateArrayIterator
6956 return new ArrayIterator(O, 'key+value');
6957 });
6958
6959 }
6960
6961 if (!("Symbol"in this && "iterator"in this.Symbol&&!!Array.prototype.keys
6962 )) {
6963
6964 // Array.prototype.keys
6965 /* global CreateMethodProperty, ToObject */
6966 // 22.1.3.14. Array.prototype.keys ( )
6967 CreateMethodProperty(Array.prototype, 'keys', function keys() {
6968 // 1. Let O be ? ToObject(this value).
6969 var O = ToObject(this);
6970 // 2. Return CreateArrayIterator(O, "key").
6971 // TODO: Add CreateArrayIterator.
6972 return new ArrayIterator(O, 'key');
6973 });
6974
6975 }
6976
6977 if (!("values"in Array.prototype
6978 )) {
6979
6980 // Array.prototype.values
6981 /* global CreateMethodProperty, Symbol, ToObject */
6982 // 22.1.3.30/ Array.prototype.values ( )
6983 // Polyfill.io - Firefox, Chrome and Opera have Array.prototype[Symbol.iterator], which is the exact same function as Array.prototype.values.
6984 if ('Symbol' in this && 'iterator' in Symbol && typeof Array.prototype[Symbol.iterator] === 'function') {
6985 CreateMethodProperty(Array.prototype, 'values', Array.prototype[Symbol.iterator]);
6986 } else {
6987 CreateMethodProperty(Array.prototype, 'values', function values () {
6988 // 1. Let O be ? ToObject(this value).
6989 var O = ToObject(this);
6990 // 2. Return CreateArrayIterator(O, "value").
6991 // TODO: Add CreateArrayIterator
6992 return new ArrayIterator(O, 'value');
6993 });
6994 }
6995
6996 }
6997
6998 if (!("Symbol"in this && "iterator"in this.Symbol&&!!Array.prototype[Symbol.iterator]
6999 )) {
7000
7001 // Array.prototype.@@iterator
7002 /* global Symbol, CreateMethodProperty */
7003 // 22.1.3.31. Array.prototype [ @@iterator ] ( )
7004 // The initial value of the @@iterator property is the same function object as the initial value of the Array.prototype.values property.
7005 CreateMethodProperty(Array.prototype, Symbol.iterator, Array.prototype.values);
7006
7007 }
7008
7009
7010 // _StringIterator
7011 // A modification of https://github.com/medikoo/es6-iterator
7012 // Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
7013
7014 /* global Iterator */
7015
7016 var StringIterator = (function() {
7017 // eslint-disable-line no-unused-vars
7018
7019 var StringIterator = function (str) {
7020 if (!(this instanceof StringIterator))
7021 return new StringIterator(str);
7022 str = String(str);
7023 Iterator.call(this, str);
7024 Object.defineProperty(this, '__length__', {
7025 value: str.length,
7026 configurable: false,
7027 enumerable: false,
7028 writable: false
7029 });
7030 };
7031 if (Object.setPrototypeOf)
7032 Object.setPrototypeOf(StringIterator, Iterator);
7033
7034 StringIterator.prototype = Object.create(Iterator.prototype, {
7035 constructor: {
7036 value: StringIterator,
7037 configurable: true,
7038 enumerable: false,
7039 writable: true
7040 },
7041 _next: {
7042 value: function() {
7043 if (!this.__list__)
7044 return;
7045 if (this.__nextIndex__ < this.__length__)
7046 return this.__nextIndex__++;
7047 this._unBind();
7048 },
7049 configurable: true,
7050 enumerable: false,
7051 writable: true
7052 },
7053 _resolve: {
7054 value: function (i) {
7055 var char = this.__list__[i], code;
7056 if (this.__nextIndex__ === this.__length__)
7057 return char;
7058 code = char.charCodeAt(0);
7059 if ((code >= 0xD800) && (code <= 0xDBFF))
7060 return char + this.__list__[this.__nextIndex__++];
7061 return char;
7062 },
7063 configurable: true,
7064 enumerable: false,
7065 writable: true
7066 },
7067 toString: {
7068 value: function() {
7069 return '[object String Iterator]';
7070 },
7071 configurable: true,
7072 enumerable: false,
7073 writable: true
7074 }
7075 });
7076
7077 return StringIterator;
7078 }());
7079 if (!("Symbol"in this && "iterator"in this.Symbol&&!!String.prototype[Symbol.iterator]
7080 )) {
7081
7082 // String.prototype.@@iterator
7083 /* global CreateMethodProperty, RequireObjectCoercible, ToString, StringIterator, Symbol */
7084 // 21.1.3.29. String.prototype [ @@iterator ] ( )
7085 CreateMethodProperty(String.prototype, Symbol.iterator, function () {
7086 // 1. Let O be ? RequireObjectCoercible(this value).
7087 var O = RequireObjectCoercible(this);
7088 // 2. Let S be ? ToString(O).
7089 var S = ToString(O);
7090 // 3. Return CreateStringIterator(S).
7091 // TODO: Add CreateStringIterator.
7092 return new StringIterator(S);
7093 });
7094
7095 }
7096
7097 if (!("Symbol"in this && "unscopables"in this.Symbol
7098 )) {
7099
7100 // Symbol.unscopables
7101 /* global Symbol */
7102 Object.defineProperty(Symbol, 'unscopables', {
7103 value: Symbol('unscopables')
7104 });
7105
7106 }
7107
7108 if (!((function(e) {
7109 try {
7110 if ("WeakMap"in e && 0 === WeakMap.length) {
7111 var t = {}, a = new WeakMap([[t, "test"]])
7112 return "test" === a.get(t)&&!1 === a["delete"](0)
7113 }
7114 return !1
7115 } catch (n) {
7116 return !1
7117 }
7118 })(this)
7119 )) {
7120
7121 // WeakMap
7122 /* globals Symbol, OrdinaryCreateFromConstructor, IsCallable, GetIterator, IteratorStep, IteratorValue, IteratorClose, Get, Call, CreateMethodProperty, Type, SameValue */
7123 (function (global) {
7124 // 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.
7125 var undefMarker = Symbol('undef');
7126 // 23.3.1.1 WeakMap ( [ iterable ] )
7127 var WeakMap = function WeakMap( /* iterable */
7128 ) {
7129 // 1. If NewTarget is undefined, throw a TypeError exception.
7130 if (!(this instanceof WeakMap)) {
7131 throw new TypeError('Constructor WeakMap requires "new"');
7132 }
7133 // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakMapPrototype%", « [[WeakMapData]] »).
7134 var map = OrdinaryCreateFromConstructor(this, WeakMap.prototype, {
7135 _keys: [],
7136 _values: [],
7137 _es6WeakMap: true
7138 });
7139
7140 // 3. Set map.[[WeakMapData]] to a new empty List.
7141 // Polyfill.io - This step was done as part of step two.
7142
7143 // 4. If iterable is not present, let iterable be undefined.
7144 var iterable = arguments.length > 0 ? arguments[0] : undefined;
7145
7146 // 5. If iterable is either undefined or null, return map.
7147 if (iterable === null || iterable === undefined) {
7148 return map;
7149 }
7150
7151 // 6. Let adder be ? Get(map, "set").
7152 var adder = Get(map, "set");
7153
7154 // 7. If IsCallable(adder) is false, throw a TypeError exception.
7155 if (!IsCallable(adder)) {
7156 throw new TypeError("WeakMap.prototype.set is not a function");
7157 }
7158
7159 // 8. Let iteratorRecord be ? GetIterator(iterable).
7160 try {
7161 var iteratorRecord = GetIterator(iterable);
7162 // 9. Repeat,
7163 while (true) {
7164 // a. Let next be ? IteratorStep(iteratorRecord).
7165 var next = IteratorStep(iteratorRecord);
7166 // b. If next is false, return map.
7167 if (next === false) {
7168 return map;
7169 }
7170 // c. Let nextItem be ? IteratorValue(next).
7171 var nextItem = IteratorValue(next);
7172 // d. If Type(nextItem) is not Object, then
7173 if (Type(nextItem) !== 'object') {
7174 // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
7175 try {
7176 throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
7177 } catch (error) {
7178 // ii. Return ? IteratorClose(iteratorRecord, error).
7179 return IteratorClose(iteratorRecord, error);
7180 }
7181 }
7182 try {
7183 // Polyfill.io - The try catch accounts for steps: f, h, and j.
7184
7185 // e. Let k be Get(nextItem, "0").
7186 var k = Get(nextItem, "0");
7187 // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
7188 // g. Let v be Get(nextItem, "1").
7189 var v = Get(nextItem, "1");
7190 // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
7191 // i. Let status be Call(adder, map, « k.[[Value]], v.[[Value]] »).
7192 Call(adder, map, [k, v]);
7193 } catch (e) {
7194 // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
7195 return IteratorClose(iteratorRecord, e);
7196 }
7197 }
7198 } catch (e) {
7199 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
7200 if (Array.isArray(iterable) ||
7201 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
7202 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
7203 (!!iterable.callee)) {
7204 var index;
7205 var length = iterable.length;
7206 for (index = 0; index < length; index++) {
7207 var k = iterable[index][0];
7208 var v = iterable[index][1];
7209 Call(adder, map, [k, v]);
7210 }
7211 }
7212 }
7213 return map;
7214 };
7215
7216 // 23.3.2.1 WeakMap.prototype
7217 // The initial value of WeakMap.prototype is the intrinsic object %WeakMapPrototype%.
7218 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
7219 Object.defineProperty(WeakMap, 'prototype', {
7220 configurable: false,
7221 enumerable: false,
7222 writable: false,
7223 value: {}
7224 });
7225
7226 // 23.3.3.1 WeakMap.prototype.constructor
7227 CreateMethodProperty(WeakMap.prototype, 'constructor', WeakMap);
7228
7229 // 23.3.3.2 WeakMap.prototype.delete ( key )
7230 CreateMethodProperty(WeakMap.prototype, 'delete', function (key) {
7231 // 1. Let M be the this value.
7232 var M = this;
7233 // 2. If Type(M) is not Object, throw a TypeError exception.
7234 if (Type(M) !== 'object') {
7235 throw new TypeError('Method WeakMap.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
7236 }
7237 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
7238 if (M._es6WeakMap !== true) {
7239 throw new TypeError('Method WeakMap.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
7240 }
7241 // 4. Let entries be the List that is M.[[WeakMapData]].
7242 var entries = M._keys;
7243 // 5. If Type(key) is not Object, return false.
7244 if (Type(key) !== 'object') {
7245 return false;
7246 }
7247 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
7248 for (var i = 0; i < entries.length; i++) {
7249 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, then
7250 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
7251 // i. Set p.[[Key]] to empty.
7252 this._keys[i] = undefMarker;
7253 // ii. Set p.[[Value]] to empty.
7254 this._values[i] = undefMarker;
7255 this._size = --this._size;
7256 // iii. Return true.
7257 return true;
7258 }
7259 }
7260 // 7. Return false.
7261 return false;
7262 });
7263
7264 // 23.3.3.3 WeakMap.prototype.get ( key )
7265 CreateMethodProperty(WeakMap.prototype, 'get', function get(key) {
7266 // 1. Let M be the this value.
7267 var M = this;
7268 // 2. If Type(M) is not Object, throw a TypeError exception.
7269 if (Type(M) !== 'object') {
7270 throw new TypeError('Method WeakMap.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
7271 }
7272 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
7273 if (M._es6WeakMap !== true) {
7274 throw new TypeError('Method WeakMap.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
7275 }
7276 // 4. Let entries be the List that is M.[[WeakMapData]].
7277 var entries = M._keys;
7278 // 5. If Type(key) is not Object, return undefined.
7279 if (Type(key) !== 'object') {
7280 return undefined;
7281 }
7282 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
7283 for (var i = 0; i < entries.length; i++) {
7284 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
7285 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
7286 return M._values[i];
7287 }
7288 }
7289 // 7. Return undefined.
7290 return undefined;
7291 });
7292
7293 // 23.3.3.4 WeakMap.prototype.has ( key )
7294 CreateMethodProperty(WeakMap.prototype, 'has', function has(key) {
7295 // 1. Let M be the this value.
7296 var M = this;
7297 // 2. If Type(M) is not Object, throw a TypeError exception.
7298 if (typeof M !== 'object') {
7299 throw new TypeError('Method WeakMap.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
7300 }
7301 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
7302 if (M._es6WeakMap !== true) {
7303 throw new TypeError('Method WeakMap.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
7304 }
7305 // 4. Let entries be the List that is M.[[WeakMapData]].
7306 var entries = M._keys;
7307 // 5. If Type(key) is not Object, return false.
7308 if (Type(key) !== 'object') {
7309 return false;
7310 }
7311 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
7312 for (var i = 0; i < entries.length; i++) {
7313 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return true.
7314 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
7315 return true;
7316 }
7317 }
7318 // 7. Return false.
7319 return false;
7320 });
7321
7322 // 23.3.3.5 WeakMap.prototype.set ( key, value )
7323 CreateMethodProperty(WeakMap.prototype, 'set', function set(key, value) {
7324 // 1. Let M be the this value.
7325 var M = this;
7326 // 2. If Type(M) is not Object, throw a TypeError exception.
7327 if (Type(M) !== 'object') {
7328 throw new TypeError('Method WeakMap.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
7329 }
7330 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
7331 if (M._es6WeakMap !== true) {
7332 throw new TypeError('Method WeakMap.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
7333 }
7334 // 4. Let entries be the List that is M.[[WeakMapData]].
7335 var entries = M._keys;
7336 // 5. If Type(key) is not Object, throw a TypeError exception.
7337 if (Type(key) !== 'object') {
7338 throw new TypeError("Invalid value used as weak map key");
7339 }
7340 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
7341 for (var i = 0; i < entries.length; i++) {
7342 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, then
7343 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
7344 // i. Set p.[[Value]] to value.
7345 M._values[i] = value;
7346 // ii. Return M.
7347 return M;
7348 }
7349 }
7350 // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
7351 var p = {
7352 '[[Key]]': key,
7353 '[[Value]]': value
7354 };
7355 // 8. Append p as the last element of entries.
7356 M._keys.push(p['[[Key]]']);
7357 M._values.push(p['[[Value]]']);
7358 // 9. Return M.
7359 return M;
7360 });
7361
7362 // 23.3.3.6 WeakMap.prototype [ @@toStringTag ]
7363 // The initial value of the @@toStringTag property is the String value "WeakMap".
7364 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
7365
7366 // 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.
7367 if (!('name' in WeakMap)) {
7368 // 19.2.4.2 name
7369 Object.defineProperty(WeakMap, 'name', {
7370 configurable: true,
7371 enumerable: false,
7372 writable: false,
7373 value: 'WeakMap'
7374 });
7375 }
7376
7377 // Export the object
7378 try {
7379 CreateMethodProperty(global, 'WeakMap', WeakMap);
7380 } catch (e) {
7381 // IE8 throws an error here if we set enumerable to false.
7382 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
7383 global['WeakMap'] = WeakMap;
7384 }
7385 }(this));
7386
7387 }
7388
7389 if (!((function(e) {
7390 try {
7391 if ("WeakSet"in e && 0 === WeakSet.length) {
7392 var t = {}, n = new WeakSet([t])
7393 return n.has(t)&&!1 === n["delete"](0)
7394 }
7395 return !1
7396 } catch (r) {
7397 return !1
7398 }
7399 })(this)
7400 )) {
7401
7402 // WeakSet
7403 /* global Call, CreateMethodProperty, Get, GetIterator, IsArray, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
7404 (function (global) {
7405 // 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.
7406 var undefMarker = Symbol('undef');
7407 // 23.4.1.1. WeakSet ( [ iterable ] )
7408 var WeakSet = function WeakSet() {
7409 // 1. If NewTarget is undefined, throw a TypeError exception.
7410 if (!(this instanceof WeakSet)) {
7411 throw new TypeError('Constructor WeakSet requires "new"');
7412 }
7413 // 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakSetPrototype%", « [[WeakSetData]] »).
7414 var set = OrdinaryCreateFromConstructor(this, WeakSet.prototype, {
7415 _values: [],
7416 _size: 0,
7417 _es6WeakSet: true
7418 });
7419
7420 // 3. Set set.[[WeakSetData]] to a new empty List.
7421 // Polyfill.io - This step was done as part of step two.
7422
7423 // 4. If iterable is not present, let iterable be undefined.
7424 var iterable = arguments.length > 0 ? arguments[0] : undefined;
7425 // 5. If iterable is either undefined or null, return set.
7426 if (iterable === null || iterable === undefined) {
7427 return set;
7428 }
7429 // 6. Let adder be ? Get(set, "add").
7430 var adder = Get(set, 'add');
7431 // 7. If IsCallable(adder) is false, throw a TypeError exception.
7432 if (!IsCallable(adder)) {
7433 throw new TypeError("WeakSet.prototype.add is not a function");
7434 }
7435 try {
7436 // 8. Let iteratorRecord be ? GetIterator(iterable).
7437 var iteratorRecord = GetIterator(iterable);
7438 // 9. Repeat,
7439 while (true) {
7440 // a. Let next be ? IteratorStep(iteratorRecord).
7441 var next = IteratorStep(iteratorRecord);
7442 // b. If next is false, return set.
7443 if (next === false) {
7444 return set;
7445 }
7446 // c. Let nextValue be ? IteratorValue(next).
7447 var nextValue = IteratorValue(next);
7448 // d. Let status be Call(adder, set, « nextValue »).
7449 try {
7450 Call(adder, set, [nextValue]);
7451 } catch (e) {
7452 // e. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
7453 return IteratorClose(iteratorRecord, e);
7454 }
7455 }
7456 } catch (e) {
7457 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
7458 if (IsArray(iterable) ||
7459 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
7460 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
7461 (!!iterable.callee)) {
7462 var index;
7463 var length = iterable.length;
7464 for (index = 0; index < length; index++) {
7465 Call(adder, set, [iterable[index]]);
7466 }
7467 }
7468 }
7469 return set;
7470 };
7471
7472 // 23.4.2.1. WeakSet.prototype
7473 // The initial value of WeakSet.prototype is the intrinsic %WeakSetPrototype% object.
7474 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
7475 Object.defineProperty(WeakSet, 'prototype', {
7476 configurable: false,
7477 enumerable: false,
7478 writable: false,
7479 value: {}
7480 });
7481
7482 // 23.4.3.1. WeakSet.prototype.add ( value )
7483 CreateMethodProperty(WeakSet.prototype, 'add', function add(value) {
7484 // 1. Let S be the this value.
7485 var S = this;
7486 // 2. If Type(S) is not Object, throw a TypeError exception.
7487 if (Type(S) !== 'object') {
7488 throw new TypeError('Method WeakSet.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
7489 }
7490 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
7491 if (S._es6WeakSet !== true) {
7492 throw new TypeError('Method WeakSet.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
7493 }
7494 // 4. If Type(value) is not Object, throw a TypeError exception.
7495 if (Type(value) !== 'object') {
7496 throw new TypeError('Invalid value used in weak set');
7497 }
7498 // 5. Let entries be the List that is S.[[WeakSetData]].
7499 var entries = S._values;
7500 // 6. For each e that is an element of entries, do
7501 for (var i = 0; i < entries.length; i++) {
7502 var e = entries[i];
7503 // a. If e is not empty and SameValue(e, value) is true, then
7504 if (e !== undefMarker && SameValueZero(e, value)) {
7505 // i. Return S.
7506 return S;
7507 }
7508 }
7509 // 7. Append value as the last element of entries.
7510 S._values.push(value);
7511 // 8. Return S.
7512 return S;
7513 });
7514
7515 // 23.4.3.2. WeakSet.prototype.constructor
7516 CreateMethodProperty(WeakSet.prototype, 'constructor', WeakSet);
7517
7518 // 23.4.3.3. WeakSet.prototype.delete ( value )
7519 CreateMethodProperty(WeakSet.prototype, 'delete', function (value) {
7520 // 1. Let S be the this value.
7521 var S = this;
7522 // 2. If Type(S) is not Object, throw a TypeError exception.
7523 if (Type(S) !== 'object') {
7524 throw new TypeError('Method WeakSet.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
7525 }
7526 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
7527 if (S._es6WeakSet !== true) {
7528 throw new TypeError('Method WeakSet.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
7529 }
7530 // 4. If Type(value) is not Object, return false.
7531 if (Type(value) !== 'object') {
7532 return false;
7533 }
7534 // 5. Let entries be the List that is S.[[WeakSetData]].
7535 var entries = S._values;
7536 // 6. For each e that is an element of entries, do
7537 for (var i = 0; i < entries.length; i++) {
7538 var e = entries[i];
7539 // a. If e is not empty and SameValue(e, value) is true, then
7540 if (e !== undefMarker && SameValueZero(e, value)) {
7541 // i. Replace the element of entries whose value is e with an element whose value is empty.
7542 entries[i] = undefMarker;
7543 // ii. Return true.
7544 return true;
7545 }
7546 }
7547 // 7. Return false.
7548 return false;
7549 });
7550
7551 // 23.4.3.4. WeakSet.prototype.has ( value )
7552 CreateMethodProperty(WeakSet.prototype, 'has', function has(value) {
7553 // 1. Let S be the this value.
7554 var S = this;
7555 // 2. If Type(S) is not Object, throw a TypeError exception.
7556 if (Type(S) !== 'object') {
7557 throw new TypeError('Method WeakSet.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(S));
7558 }
7559 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
7560 if (S._es6WeakSet !== true) {
7561 throw new TypeError('Method WeakSet.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(S));
7562 }
7563 // 4. Let entries be the List that is S.[[WeakSetData]].
7564 var entries = S._values;
7565 // 5. If Type(value) is not Object, return false.
7566 if (Type(value) !== 'object') {
7567 return false;
7568 }
7569 // 6. For each e that is an element of entries, do
7570 for (var i = 0; i < entries.length; i++) {
7571 var e = entries[i];
7572 // a. If e is not empty and SameValue(e, value) is true, return true.
7573 if (e !== undefMarker && SameValueZero(e, value)) {
7574 return true;
7575 }
7576 }
7577 // 7. Return false.
7578 return false;
7579 });
7580
7581 // 23.4.3.5. WeakSet.prototype [ @@toStringTag ]
7582 // The initial value of the @@toStringTag property is the String value "WeakSet".
7583 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
7584
7585 // 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.
7586 if (!('name' in WeakSet)) {
7587 // 19.2.4.2 name
7588 Object.defineProperty(WeakSet, 'name', {
7589 configurable: true,
7590 enumerable: false,
7591 writable: false,
7592 value: 'WeakSet'
7593 });
7594 }
7595
7596 // Export the object
7597 try {
7598 CreateMethodProperty(global, 'WeakSet', WeakSet);
7599 } catch (e) {
7600 // IE8 throws an error here if we set enumerable to false.
7601 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
7602 global['WeakSet'] = WeakSet;
7603 }
7604
7605 }(this));
7606
7607 }
7608
7609})
7610.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});