· 6 years ago · Aug 19, 2019, 02:20 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", "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", "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", "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", "WeakMap", "WeakSet", "Array.prototype.includes", "es2016", "_ESAbstract.IteratorValue", "Map", "Set", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.forEach", "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", "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", "_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", "Symbol", "Map", "Array.from", "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")
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", "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", "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", "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.codePointAt", "es2015", "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", "_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", "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", "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")
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", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.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")
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.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", "WeakMap", "WeakSet", "_ESAbstract.IsConstructor", "Array.of", "_ESAbstract.GetIterator", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.ToString", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "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", "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", "_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", "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.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.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.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", "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 * - Object.defineProperty, License: CC0 (required by "Map", "es2015", "Array.from", "Number.Epsilon", "Number.MAX_SAFE_INTEGER", "Number.MIN_SAFE_INTEGER", "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", "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.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", "_ESAbstract.CreateDataProperty", "_ESAbstract.CreateDataPropertyOrThrow", "_ESAbstract.CreateIterResultObject", "_Iterator", "Object.setPrototypeOf", "Object.defineProperties", "Object.create", "_ESAbstract.GetIterator")
37 * - _ESAbstract.CreateDataProperty, License: CC0 (required by "_ESAbstract.CreateDataPropertyOrThrow", "Array.from", "es2015", "Array.of", "_ESAbstract.CreateIterResultObject", "Map", "Set")
38 * - _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", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
39 * - _ESAbstract.CreateIterResultObject, License: CC0 (required by "Map", "es2015", "Array.from", "Set")
40 * - _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.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", "Set", "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", "Array.prototype.filter", "Array.prototype.map", "Object.getOwnPropertyNames", "Object.freeze", "Function.prototype.bind", "Object.setPrototypeOf", "Object.getPrototypeOf", "Object.defineProperties", "_Iterator")
41 * - Array.isArray, License: CC0 (required by "Map", "es2015", "Array.from", "Set", "WeakMap")
42 * - Array.prototype.copyWithin, License: MIT (required by "es2015")
43 * - Array.prototype.fill, License: CC0 (required by "es2015")
44 * - Array.prototype.find, License: CC0 (required by "es2015")
45 * - Array.prototype.findIndex, License: CC0 (required by "es2015")
46 * - Array.prototype.forEach, License: CC0 (required by "Symbol", "es2015", "Map", "Array.from", "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", "Object.setPrototypeOf", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values")
47 * - Array.prototype.includes, License: MIT (required by "es2016")
48 * - Function.prototype.bind, License: MIT (required by "_ESAbstract.Construct", "Array.from", "es2015", "Array.of", "Object.getOwnPropertyDescriptor", "Object.assign", "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", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values")
49 * - Math.acosh, License: CC0 (required by "es2015")
50 * - Math.asinh, License: CC0 (required by "es2015")
51 * - Math.atanh, License: CC0 (required by "es2015")
52 * - Math.cbrt, License: CC0 (required by "es2015")
53 * - Math.clz32, License: CC0 (required by "es2015")
54 * - Math.cosh, License: CC0 (required by "es2015")
55 * - Math.expm1, License: CC0 (required by "es2015")
56 * - Math.hypot, License: CC0 (required by "es2015")
57 * - Math.imul, License: CC0 (required by "es2015")
58 * - Math.log10, License: CC0 (required by "es2015")
59 * - Math.log1p, License: CC0 (required by "es2015")
60 * - Math.log2, License: CC0 (required by "es2015")
61 * - Math.sign, License: CC0 (required by "es2015")
62 * - Math.sinh, License: CC0 (required by "es2015")
63 * - Math.tanh, License: CC0 (required by "es2015")
64 * - Math.trunc, License: CC0 (required by "es2015")
65 * - Number.isFinite, License: MIT (required by "es2015")
66 * - Number.isInteger, License: MIT (required by "es2015")
67 * - Number.isNaN, License: MIT (required by "es2015")
68 * - Number.isSafeInteger, License: MIT (required by "es2015")
69 * - Number.parseFloat, License: MIT (required by "es2015")
70 * - Number.parseInt, License: MIT (required by "es2015")
71 * - Number.Epsilon, License: MIT (required by "es2015")
72 * - Number.MAX_SAFE_INTEGER, License: MIT (required by "es2015")
73 * - Number.MIN_SAFE_INTEGER, License: MIT (required by "es2015")
74 * - Object.freeze, License: CC0 (required by "Symbol", "es2015", "Map", "Array.from", "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")
75 * - Object.getOwnPropertyDescriptor, License: CC0 (required by "Object.assign", "es2015", "Symbol", "Map", "Array.from", "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", "Object.setPrototypeOf", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Object.defineProperties", "Object.create", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator")
76 * - Object.getOwnPropertyNames, License: CC0 (required by "Symbol", "es2015", "Map", "Array.from", "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", "Object.setPrototypeOf", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values")
77 * - Object.getPrototypeOf, License: CC0 (required by "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "es2015", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of", "Object.setPrototypeOf", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
78 * - Object.is, License: CC0 (required by "es2015")
79 * - Object.keys, License: MIT (required by "Object.assign", "es2015", "Symbol", "Map", "Array.from", "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", "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")
80 * - Object.assign, License: CC0 (required by "es2015", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
81 * - Object.defineProperties, License: CC0 (required by "Object.create", "Map", "es2015", "Array.from", "Set", "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", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator")
82 * - Object.create, License: CC0 (required by "Map", "es2015", "Array.from", "Set", "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", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "Object.setPrototypeOf")
83 * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "Map", "es2015", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
84 * - _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", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
85 * - _ESAbstract.ArraySpeciesCreate, License: CC0 (required by "Array.prototype.filter", "Symbol", "es2015", "Map", "Array.from", "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.map")
86 * - Array.prototype.filter, License: CC0 (required by "Symbol", "es2015", "Map", "Array.from", "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")
87 * - Array.prototype.map, License: CC0 (required by "Symbol", "es2015", "Map", "Array.from", "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")
88 * - Array.of, License: CC0 (required by "es2015")
89 * - Object.seal, License: MIT (required by "es2015")
90 * - Promise, License: MIT (required by "es2015")
91 * - String.prototype.codePointAt, License: MIT (required by "es2015")
92 * - String.prototype.endsWith, License: CC0 (required by "es2015")
93 * - String.prototype.includes, License: CC0 (required by "es2015", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
94 * - String.prototype.padEnd, License: CC0 (required by "es2016")
95 * - String.prototype.padStart, License: CC0 (required by "es2016")
96 * - String.prototype.repeat, License: CC0 (required by "es2015")
97 * - String.prototype.startsWith, License: CC0 (required by "es2015")
98 * - Symbol, License: MIT (required by "es2015", "Map", "Array.from", "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", "WeakMap", "WeakSet", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values")
99 * - Symbol.hasInstance, License: MIT (required by "es2015")
100 * - Symbol.isConcatSpreadable, License: MIT (required by "es2015")
101 * - Symbol.iterator, License: MIT (required by "es2015", "Array.from", "Array.prototype.@@iterator", "Map", "Set", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values")
102 * - _ESAbstract.GetIterator, License: CC0 (required by "Array.from", "es2015", "Map", "Set", "WeakMap", "WeakSet")
103 * - Symbol.match, License: MIT (required by "es2015")
104 * - Symbol.replace, License: MIT (required by "es2015")
105 * - Symbol.search, License: MIT (required by "es2015")
106 * - Symbol.species, License: MIT (required by "es2015", "Map", "Array.from", "Set")
107 * - Map, License: CC0 (required by "es2015", "Array.from")
108 * - Set, License: CC0 (required by "es2015", "Array.from")
109 * - Array.from, License: CC0 (required by "es2015")
110 * - Symbol.split, License: MIT (required by "es2015")
111 * - Symbol.toPrimitive, License: MIT (required by "es2015")
112 * - Symbol.toStringTag, License: MIT (required by "es2015", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
113 * - _Iterator, License: MIT (required by "_ArrayIterator", "Array.prototype.entries", "es2015", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
114 * - _ArrayIterator, License: MIT (required by "Array.prototype.entries", "es2015", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
115 * - Array.prototype.entries, License: CC0 (required by "es2015")
116 * - Array.prototype.keys, License: CC0 (required by "es2015")
117 * - Array.prototype.values, License: MIT (required by "es2015", "Array.prototype.@@iterator")
118 * - Array.prototype.@@iterator, License: CC0 (required by "es2015")
119 * - Symbol.unscopables, License: MIT (required by "es2015")
120 * - WeakMap, License: MIT (required by "es2015")
121 * - WeakSet, License: MIT (required by "es2015") */
122
123(function(undefined) {
124
125 // _ESAbstract.ArrayCreate
126 // 9.4.2.2. ArrayCreate ( length [ , proto ] )
127 function ArrayCreate(length /* [, proto] */
128 ) {
129 // eslint-disable-line no-unused-vars
130 // 1. Assert: length is an integer Number ≥ 0.
131 // 2. If length is -0, set length to +0.
132 if (1 / length === - Infinity) {
133 length = 0;
134 }
135 // 3. If length>2^32-1, throw a RangeError exception.
136 if (length > (Math.pow(2, 32) - 1)) {
137 throw new RangeError('Invalid array length');
138 }
139 // 4. If proto is not present, set proto to the intrinsic object %ArrayPrototype%.
140 // 5. Let A be a newly created Array exotic object.
141 var A = [];
142 // 6. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.
143 // 7. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1.
144 // 8. Set A.[[Prototype]] to proto.
145 // 9. Set A.[[Extensible]] to true.
146 // 10. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
147 A.length = length;
148 // 11. Return A.
149 return A;
150 }
151
152 // _ESAbstract.Call
153 /* global IsCallable */
154 // 7.3.12. Call ( F, V [ , argumentsList ] )
155 function Call(F, V /* [, argumentsList] */
156 ) {
157 // eslint-disable-line no-unused-vars
158 // 1. If argumentsList is not present, set argumentsList to a new empty List.
159 var argumentsList = arguments.length > 2 ? arguments[2] : [];
160 // 2. If IsCallable(F) is false, throw a TypeError exception.
161 if (IsCallable(F) === false) {
162 throw new TypeError(Object.prototype.toString.call(F) + 'is not a function.');
163 }
164 // 3. Return ? F.[[Call]](V, argumentsList).
165 return F.apply(V, argumentsList);
166 }
167
168 // _ESAbstract.Get
169 // 7.3.1. Get ( O, P )
170 function Get(O, P) {
171 // eslint-disable-line no-unused-vars
172 // 1. Assert: Type(O) is Object.
173 // 2. Assert: IsPropertyKey(P) is true.
174 // 3. Return ? O.[[Get]](P, O).
175 return O[P];
176 }
177
178 // _ESAbstract.HasProperty
179 // 7.3.10. HasProperty ( O, P )
180 function HasProperty(O, P) {
181 // eslint-disable-line no-unused-vars
182 // Assert: Type(O) is Object.
183 // Assert: IsPropertyKey(P) is true.
184 // Return ? O.[[HasProperty]](P).
185 return P in O;
186 }
187
188 // _ESAbstract.IsArray
189 // 7.2.2. IsArray ( argument )
190 function IsArray(argument) {
191 // eslint-disable-line no-unused-vars
192 // 1. If Type(argument) is not Object, return false.
193 // 2. If argument is an Array exotic object, return true.
194 // 3. If argument is a Proxy exotic object, then
195 // a. If argument.[[ProxyHandler]] is null, throw a TypeError exception.
196 // b. Let target be argument.[[ProxyTarget]].
197 // c. Return ? IsArray(target).
198 // 4. Return false.
199
200 // Polyfill.io - We can skip all the above steps and check the string returned from Object.prototype.toString().
201 return Object.prototype.toString.call(argument) === '[object Array]';
202 }
203
204 // _ESAbstract.IsCallable
205 // 7.2.3. IsCallable ( argument )
206 function IsCallable(argument) {
207 // eslint-disable-line no-unused-vars
208 // 1. If Type(argument) is not Object, return false.
209 // 2. If argument has a [[Call]] internal method, return true.
210 // 3. Return false.
211
212 // 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.
213 return typeof argument === 'function';
214 }
215
216 // _ESAbstract.RequireObjectCoercible
217 // 7.2.1. RequireObjectCoercible ( argument )
218 // The abstract operation ToObject converts argument to a value of type Object according to Table 12:
219 // Table 12: ToObject Conversions
220 /*
221 |----------------------------------------------------------------------------------------------------------------------------------------------------|
222 | Argument Type | Result |
223 |----------------------------------------------------------------------------------------------------------------------------------------------------|
224 | Undefined | Throw a TypeError exception. |
225 | Null | Throw a TypeError exception. |
226 | Boolean | Return argument. |
227 | Number | Return argument. |
228 | String | Return argument. |
229 | Symbol | Return argument. |
230 | Object | Return argument. |
231 |----------------------------------------------------------------------------------------------------------------------------------------------------|
232 */
233 function RequireObjectCoercible(argument) {
234 // eslint-disable-line no-unused-vars
235 if (argument === null || argument === undefined) {
236 throw TypeError();
237 }
238 return argument;
239 }
240
241 // _ESAbstract.SameValueNonNumber
242 // 7.2.12. SameValueNonNumber ( x, y )
243 function SameValueNonNumber(x, y) {
244 // eslint-disable-line no-unused-vars
245 // 1. Assert: Type(x) is not Number.
246 // 2. Assert: Type(x) is the same as Type(y).
247 // 3. If Type(x) is Undefined, return true.
248 // 4. If Type(x) is Null, return true.
249 // 5. If Type(x) is String, then
250 // 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.
251 // 6. If Type(x) is Boolean, then
252 // a. If x and y are both true or both false, return true; otherwise, return false.
253 // 7. If Type(x) is Symbol, then
254 // a. If x and y are both the same Symbol value, return true; otherwise, return false.
255 // 8. If x and y are the same Object value, return true. Otherwise, return false.
256
257 // Polyfill.io - We can skip all above steps because the === operator does it all for us.
258 return x === y;
259 }
260
261 // _ESAbstract.ToBoolean
262 // 7.1.2. ToBoolean ( argument )
263 // The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 9:
264 /*
265 --------------------------------------------------------------------------------------------------------------
266 | Argument Type | Result |
267 --------------------------------------------------------------------------------------------------------------
268 | Undefined | Return false. |
269 | Null | Return false. |
270 | Boolean | Return argument. |
271 | Number | If argument is +0, -0, or NaN, return false; otherwise return true. |
272 | String | If argument is the empty String (its length is zero), return false; otherwise return true. |
273 | Symbol | Return true. |
274 | Object | Return true. |
275 --------------------------------------------------------------------------------------------------------------
276 */
277 function ToBoolean(argument) {
278 // eslint-disable-line no-unused-vars
279 return Boolean(argument);
280 }
281
282 // _ESAbstract.ToInteger
283 // 7.1.4. ToInteger ( argument )
284 function ToInteger(argument) {
285 // eslint-disable-line no-unused-vars
286 // 1. Let number be ? ToNumber(argument).
287 var number = Number(argument);
288 // 2. If number is NaN, return +0.
289 if (isNaN(number)) {
290 return 0;
291 }
292 // 3. If number is +0, -0, +∞, or -∞, return number.
293 if (1 / number === Infinity || 1 / number === - Infinity || number === Infinity || number === - Infinity) {
294 return number;
295 }
296 // 4. Return the number value that is the same sign as number and whose magnitude is floor(abs(number)).
297 return ((number < 0) ? - 1 : 1) * Math.floor(Math.abs(number));
298 }
299
300 // _ESAbstract.ToLength
301 /* global ToInteger */
302 // 7.1.15. ToLength ( argument )
303 function ToLength(argument) {
304 // eslint-disable-line no-unused-vars
305 // 1. Let len be ? ToInteger(argument).
306 var len = ToInteger(argument);
307 // 2. If len ≤ +0, return +0.
308 if (len <= 0) {
309 return 0;
310 }
311 // 3. Return min(len, 253-1).
312 return Math.min(len, Math.pow(2, 53) - 1);
313 }
314
315 // _ESAbstract.ToObject
316 // 7.1.13 ToObject ( argument )
317 // The abstract operation ToObject converts argument to a value of type Object according to Table 12:
318 // Table 12: ToObject Conversions
319 /*
320 |----------------------------------------------------------------------------------------------------------------------------------------------------|
321 | Argument Type | Result |
322 |----------------------------------------------------------------------------------------------------------------------------------------------------|
323 | Undefined | Throw a TypeError exception. |
324 | Null | Throw a TypeError exception. |
325 | Boolean | Return a new Boolean object whose [[BooleanData]] internal slot is set to argument. See 19.3 for a description of Boolean objects. |
326 | Number | Return a new Number object whose [[NumberData]] internal slot is set to argument. See 20.1 for a description of Number objects. |
327 | String | Return a new String object whose [[StringData]] internal slot is set to argument. See 21.1 for a description of String objects. |
328 | Symbol | Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 19.4 for a description of Symbol objects. |
329 | Object | Return argument. |
330 |----------------------------------------------------------------------------------------------------------------------------------------------------|
331 */
332 function ToObject(argument) {
333 // eslint-disable-line no-unused-vars
334 if (argument === null || argument === undefined) {
335 throw TypeError();
336 }
337 return Object(argument);
338 }
339
340 // _ESAbstract.GetV
341 /* global ToObject */
342 // 7.3.2 GetV (V, P)
343 function GetV(v, p) {
344 // eslint-disable-line no-unused-vars
345 // 1. Assert: IsPropertyKey(P) is true.
346 // 2. Let O be ? ToObject(V).
347 var o = ToObject(v);
348 // 3. Return ? O.[[Get]](P, V).
349 return o[p];
350 }
351
352 // _ESAbstract.GetMethod
353 /* global GetV, IsCallable */
354 // 7.3.9. GetMethod ( V, P )
355 function GetMethod(V, P) {
356 // eslint-disable-line no-unused-vars
357 // 1. Assert: IsPropertyKey(P) is true.
358 // 2. Let func be ? GetV(V, P).
359 var func = GetV(V, P);
360 // 3. If func is either undefined or null, return undefined.
361 if (func === null || func === undefined) {
362 return undefined;
363 }
364 // 4. If IsCallable(func) is false, throw a TypeError exception.
365 if (IsCallable(func) === false) {
366 throw new TypeError('Method not callable: ' + P);
367 }
368 // 5. Return func.
369 return func;
370 }
371
372 // _ESAbstract.ToUint32
373 // 7.1.6. ToUint32 ( argument )
374 function ToUint32(argument) {
375 // eslint-disable-line no-unused-vars
376 // 1. Let number be ? ToNumber(argument).
377 var number = Number(argument);
378 // 2. If number is NaN, +0, -0, +∞, or -∞, return +0.
379 if (isNaN(number) || 1 / number === Infinity || 1 / number === - Infinity || number === Infinity || number === - Infinity) {
380 return 0;
381 }
382 // 3. Let int be the mathematical value that is the same sign as number and whose magnitude is floor(abs(number)).
383 var int = ((number < 0) ? - 1 : 1) * Math.floor(Math.abs(number));
384 // 4. Let int32bit be int modulo 2^32.
385 var int32bit = int >>> 0;
386 // 5. Return int32bit.
387 return int32bit;
388 }
389
390 // _ESAbstract.Type
391 // "Type(x)" is used as shorthand for "the type of x"...
392 function Type(x) {
393 // eslint-disable-line no-unused-vars
394 switch (typeof x) {
395 case 'undefined':
396 return 'undefined';
397 case 'boolean':
398 return 'boolean';
399 case 'number':
400 return 'number';
401 case 'string':
402 return 'string';
403 case 'symbol':
404 return 'symbol';
405 default:
406 // typeof null is 'object'
407 if (x === null)
408 return 'null';
409 // Polyfill.io - This is here because a Symbol polyfill will have a typeof `object`.
410 if ('Symbol' in this && x instanceof this.Symbol)
411 return 'symbol';
412 return 'object';
413 }
414 }
415
416 // _ESAbstract.GetPrototypeFromConstructor
417 /* global Get, Type */
418 // 9.1.14. GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
419 function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) {
420 // eslint-disable-line no-unused-vars
421 // 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.
422 // 2. Assert: IsCallable(constructor) is true.
423 // 3. Let proto be ? Get(constructor, "prototype").
424 var proto = Get(constructor, "prototype");
425 // 4. If Type(proto) is not Object, then
426 if (Type(proto) !== 'object') {
427 // a. Let realm be ? GetFunctionRealm(constructor).
428 // b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
429 proto = intrinsicDefaultProto;
430 }
431 // 5. Return proto.
432 return proto;
433 }
434
435 // _ESAbstract.IsConstructor
436 /* global Type */
437 // 7.2.4. IsConstructor ( argument )
438 function IsConstructor(argument) {
439 // eslint-disable-line no-unused-vars
440 // 1. If Type(argument) is not Object, return false.
441 if (Type(argument) !== 'object') {
442 return false;
443 }
444 // 2. If argument has a [[Construct]] internal method, return true.
445 // 3. Return false.
446
447 // Polyfill.io - `new argument` is the only way to truly test if a function is a constructor.
448 // We choose to not use`new argument` because the argument could have side effects when called.
449 // Instead we check to see if the argument is a function and if it has a prototype.
450 // Arrow functions do not have a [[Construct]] internal method, nor do they have a prototype.
451 return typeof argument === 'function' && !!argument.prototype;
452 }
453
454 // _ESAbstract.IsRegExp
455 /* global Type, Get, ToBoolean */
456 // 7.2.8. IsRegExp ( argument )
457 function IsRegExp(argument) {
458 // eslint-disable-line no-unused-vars
459 // 1. If Type(argument) is not Object, return false.
460 if (Type(argument) !== 'object') {
461 return false;
462 }
463 // 2. Let matcher be ? Get(argument, @@match).
464 var matcher = 'Symbol' in this && 'match' in this.Symbol ? Get(argument, this.Symbol.match) : undefined;
465 // 3. If matcher is not undefined, return ToBoolean(matcher).
466 if (matcher !== undefined) {
467 return ToBoolean(matcher);
468 }
469 // 4. If argument has a [[RegExpMatcher]] internal slot, return true.
470 try {
471 var lastIndex = argument.lastIndex;
472 argument.lastIndex = 0;
473 RegExp.prototype.exec.call(argument);
474 return true;
475 } catch (e) {} finally {
476 argument.lastIndex = lastIndex;
477 }
478 // 5. Return false.
479 return false;
480 }
481
482 // _ESAbstract.IteratorClose
483 /* global GetMethod, Type, Call */
484 // 7.4.6. IteratorClose ( iteratorRecord, completion )
485 function IteratorClose(iteratorRecord, completion) {
486 // eslint-disable-line no-unused-vars
487 // 1. Assert: Type(iteratorRecord.[[Iterator]]) is Object.
488 if (Type(iteratorRecord['[[Iterator]]']) !== 'object') {
489 throw new Error(Object.prototype.toString.call(iteratorRecord['[[Iterator]]']) + 'is not an Object.');
490 }
491 // 2. Assert: completion is a Completion Record.
492 // Polyfill.io - Ignoring this step as there is no way to check if something is a Completion Record in userland JavaScript.
493
494 // 3. Let iterator be iteratorRecord.[[Iterator]].
495 var iterator = iteratorRecord['[[Iterator]]'];
496 // 4. Let return be ? GetMethod(iterator, "return").
497 // 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).
498 var returnMethod = GetMethod(iterator, "return");
499 // 5. If return is undefined, return Completion(completion).
500 if (returnMethod === undefined) {
501 return completion;
502 }
503 // 6. Let innerResult be Call(return, iterator, « »).
504 try {
505 var innerResult = Call(returnMethod, iterator);
506 } catch (error) {
507 var innerException = error;
508 }
509 // 7. If completion.[[Type]] is throw, return Completion(completion).
510 if (completion) {
511 return completion;
512 }
513 // 8. If innerResult.[[Type]] is throw, return Completion(innerResult).
514 if (innerException) {
515 throw innerException;
516 }
517 // 9. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
518 if (Type(innerResult) !== 'object') {
519 throw new TypeError("Iterator's return method returned a non-object.");
520 }
521 // 10. Return Completion(completion).
522 return completion;
523 }
524
525 // _ESAbstract.IteratorComplete
526 /* global Type, ToBoolean, Get */
527 // 7.4.3 IteratorComplete ( iterResult )
528 function IteratorComplete(iterResult) {
529 // eslint-disable-line no-unused-vars
530 // 1. Assert: Type(iterResult) is Object.
531 if (Type(iterResult) !== 'object') {
532 throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
533 }
534 // 2. Return ToBoolean(? Get(iterResult, "done")).
535 return ToBoolean(Get(iterResult, "done"));
536 }
537
538 // _ESAbstract.IteratorNext
539 /* global Call, Type */
540 // 7.4.2. IteratorNext ( iteratorRecord [ , value ] )
541 function IteratorNext(iteratorRecord /* [, value] */
542 ) {
543 // eslint-disable-line no-unused-vars
544 // 1. If value is not present, then
545 if (arguments.length < 2) {
546 // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « »).
547 var result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']);
548 // 2. Else,
549 } else {
550 // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « value »).
551 result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]);
552 }
553 // 3. If Type(result) is not Object, throw a TypeError exception.
554 if (Type(result) !== 'object') {
555 throw new TypeError('bad iterator');
556 }
557 // 4. Return result.
558 return result;
559 }
560
561 // _ESAbstract.IteratorStep
562 /* global IteratorNext, IteratorComplete */
563 // 7.4.5. IteratorStep ( iteratorRecord )
564 function IteratorStep(iteratorRecord) {
565 // eslint-disable-line no-unused-vars
566 // 1. Let result be ? IteratorNext(iteratorRecord).
567 var result = IteratorNext(iteratorRecord);
568 // 2. Let done be ? IteratorComplete(result).
569 var done = IteratorComplete(result);
570 // 3. If done is true, return false.
571 if (done === true) {
572 return false;
573 }
574 // 4. Return result.
575 return result;
576 }
577
578 // _ESAbstract.IteratorValue
579 /* global Type, Get */
580 // 7.4.4 IteratorValue ( iterResult )
581 function IteratorValue(iterResult) {
582 // eslint-disable-line no-unused-vars
583 // Assert: Type(iterResult) is Object.
584 if (Type(iterResult) !== 'object') {
585 throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
586 }
587 // Return ? Get(iterResult, "value").
588 return Get(iterResult, "value");
589 }
590
591 // _ESAbstract.OrdinaryToPrimitive
592 /* global Get, IsCallable, Call, Type */
593 // 7.1.1.1. OrdinaryToPrimitive ( O, hint )
594 function OrdinaryToPrimitive(O, hint) {
595 // eslint-disable-line no-unused-vars
596 // 1. Assert: Type(O) is Object.
597 // 2. Assert: Type(hint) is String and its value is either "string" or "number".
598 // 3. If hint is "string", then
599 if (hint === 'string') {
600 // a. Let methodNames be « "toString", "valueOf" ».
601 var methodNames = ['toString', 'valueOf'];
602 // 4. Else,
603 } else {
604 // a. Let methodNames be « "valueOf", "toString" ».
605 methodNames = ['valueOf', 'toString'];
606 }
607 // 5. For each name in methodNames in List order, do
608 for (var i = 0; i < methodNames.length; ++i) {
609 var name = methodNames[i];
610 // a. Let method be ? Get(O, name).
611 var method = Get(O, name);
612 // b. If IsCallable(method) is true, then
613 if (IsCallable(method)) {
614 // i. Let result be ? Call(method, O).
615 var result = Call(method, O);
616 // ii. If Type(result) is not Object, return result.
617 if (Type(result) !== 'object') {
618 return result;
619 }
620 }
621 }
622 // 6. Throw a TypeError exception.
623 throw new TypeError('Cannot convert to primitive.');
624 }
625
626 // _ESAbstract.SameValue
627 /* global Type, SameValueNonNumber */
628 // 7.2.10. SameValue ( x, y )
629 function SameValue(x, y) {
630 // eslint-disable-line no-unused-vars
631 // 1. If Type(x) is different from Type(y), return false.
632 if (Type(x) !== Type(y)) {
633 return false;
634 }
635 // 2. If Type(x) is Number, then
636 if (Type(x) === 'number') {
637 // a. If x is NaN and y is NaN, return true.
638 if (isNaN(x) && isNaN(y)) {
639 return true;
640 }
641 // Polyfill.io - 0 === -0 is true, but they are not the same value.
642 // b. If x is +0 and y is -0, return false.
643 // c. If x is -0 and y is +0, return false.
644 if (x === 0 && y === 0 && 1 / x !== 1 / y) {
645 return false;
646 }
647 // d. If x is the same Number value as y, return true.
648 if (x === y) {
649 return true;
650 }
651 // e. Return false.
652 return false;
653 }
654 // 3. Return SameValueNonNumber(x, y).
655 return SameValueNonNumber(x, y);
656 }
657
658 // _ESAbstract.SameValueZero
659 /* global Type, SameValueNonNumber */
660 // 7.2.11. SameValueZero ( x, y )
661 function SameValueZero (x, y) {
662 // eslint-disable-line no-unused-vars
663 // 1. If Type(x) is different from Type(y), return false.
664 if (Type(x) !== Type(y)) {
665 return false;
666 }
667 // 2. If Type(x) is Number, then
668 if (Type(x) === 'number') {
669 // a. If x is NaN and y is NaN, return true.
670 if (isNaN(x) && isNaN(y)) {
671 return true;
672 }
673 // b. If x is +0 and y is -0, return true.
674 if (1 / x === Infinity && 1 / y === - Infinity) {
675 return true;
676 }
677 // c. If x is -0 and y is +0, return true.
678 if (1 / x === - Infinity && 1 / y === Infinity) {
679 return true;
680 }
681 // d. If x is the same Number value as y, return true.
682 if (x === y) {
683 return true;
684 }
685 // e. Return false.
686 return false;
687 }
688 // 3. Return SameValueNonNumber(x, y).
689 return SameValueNonNumber(x, y);
690 }
691
692 // _ESAbstract.ToPrimitive
693 /* global Type, GetMethod, Call, OrdinaryToPrimitive */
694 // 7.1.1. ToPrimitive ( input [ , PreferredType ] )
695 function ToPrimitive(input /* [, PreferredType] */
696 ) {
697 // eslint-disable-line no-unused-vars
698 var PreferredType = arguments.length > 1 ? arguments[1] : undefined;
699 // 1. Assert: input is an ECMAScript language value.
700 // 2. If Type(input) is Object, then
701 if (Type(input) === 'object') {
702 // a. If PreferredType is not present, let hint be "default".
703 if (arguments.length < 2) {
704 var hint = 'default';
705 // b. Else if PreferredType is hint String, let hint be "string".
706 } else if (PreferredType === String) {
707 hint = 'string';
708 // c. Else PreferredType is hint Number, let hint be "number".
709 } else if (PreferredType === Number) {
710 hint = 'number';
711 }
712 // d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
713 var exoticToPrim = typeof this.Symbol === 'function' && typeof this.Symbol.toPrimitive === 'symbol' ? GetMethod(input, this.Symbol.toPrimitive) : undefined;
714 // e. If exoticToPrim is not undefined, then
715 if (exoticToPrim !== undefined) {
716 // i. Let result be ? Call(exoticToPrim, input, « hint »).
717 var result = Call(exoticToPrim, input, [hint]);
718 // ii. If Type(result) is not Object, return result.
719 if (Type(result) !== 'object') {
720 return result;
721 }
722 // iii. Throw a TypeError exception.
723 throw new TypeError('Cannot convert exotic object to primitive.');
724 }
725 // f. If hint is "default", set hint to "number".
726 if (hint === 'default') {
727 hint = 'number';
728 }
729 // g. Return ? OrdinaryToPrimitive(input, hint).
730 return OrdinaryToPrimitive(input, hint);
731 }
732 // 3. Return input
733 return input;
734 }
735
736 // _ESAbstract.ToString
737 /* global Type, ToPrimitive */
738 // 7.1.12. ToString ( argument )
739 // The abstract operation ToString converts argument to a value of type String according to Table 11:
740 // Table 11: ToString Conversions
741 /*
742 |---------------|--------------------------------------------------------|
743 | Argument Type | Result |
744 |---------------|--------------------------------------------------------|
745 | Undefined | Return "undefined". |
746 |---------------|--------------------------------------------------------|
747 | Null | Return "null". |
748 |---------------|--------------------------------------------------------|
749 | Boolean | If argument is true, return "true". |
750 | | If argument is false, return "false". |
751 |---------------|--------------------------------------------------------|
752 | Number | Return NumberToString(argument). |
753 |---------------|--------------------------------------------------------|
754 | String | Return argument. |
755 |---------------|--------------------------------------------------------|
756 | Symbol | Throw a TypeError exception. |
757 |---------------|--------------------------------------------------------|
758 | Object | Apply the following steps: |
759 | | Let primValue be ? ToPrimitive(argument, hint String). |
760 | | Return ? ToString(primValue). |
761 |---------------|--------------------------------------------------------|
762 */
763 function ToString(argument) {
764 // eslint-disable-line no-unused-vars
765 switch (Type(argument)) {
766 case 'symbol':
767 throw new TypeError('Cannot convert a Symbol value to a string');
768 break;
769 case 'object':
770 var primValue = ToPrimitive(argument, 'string');
771 return ToString(primValue);
772 default:
773 return String(argument);
774 }
775 }
776
777 // _ESAbstract.UTF16Decode
778 // 10.1.2. Static Semantics: UTF16Decode( lead, trail )
779 function UTF16Decode(lead, trail) {
780 // eslint-disable-line no-unused-vars
781 // 1. Assert: 0xD800 ≤ lead ≤ 0xDBFF and 0xDC00 ≤ trail ≤ 0xDFFF.
782 // 2. Let cp be (lead - 0xD800) × 0x400 + (trail - 0xDC00) + 0x10000.
783 var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
784 // 3. Return the code point cp.
785 return cp;
786 }
787
788 // Object.defineProperty
789 (function (nativeDefineProperty) {
790
791 var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
792 var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
793 var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
794
795 // Polyfill.io - This does not use CreateMethodProperty because our CreateMethodProperty function uses Object.defineProperty.
796 Object['defineProperty'] = function defineProperty(object, property, descriptor) {
797
798 // Where native support exists, assume it
799 if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
800 return nativeDefineProperty(object, property, descriptor);
801 }
802
803 if (object === null || !(object instanceof Object || typeof object === 'object')) {
804 throw new TypeError('Object.defineProperty called on non-object');
805 }
806
807 if (!(descriptor instanceof Object)) {
808 throw new TypeError('Property description must be an object');
809 }
810
811 var propertyString = String(property);
812 var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
813 var getterType = 'get' in descriptor && typeof descriptor.get;
814 var setterType = 'set' in descriptor && typeof descriptor.set;
815
816 // handle descriptor.get
817 if (getterType) {
818 if (getterType !== 'function') {
819 throw new TypeError('Getter must be a function');
820 }
821 if (!supportsAccessors) {
822 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
823 }
824 if (hasValueOrWritable) {
825 throw new TypeError(ERR_VALUE_ACCESSORS);
826 }
827 Object.__defineGetter__.call(object, propertyString, descriptor.get);
828 } else {
829 object[propertyString] = descriptor.value;
830 }
831
832 // handle descriptor.set
833 if (setterType) {
834 if (setterType !== 'function') {
835 throw new TypeError('Setter must be a function');
836 }
837 if (!supportsAccessors) {
838 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
839 }
840 if (hasValueOrWritable) {
841 throw new TypeError(ERR_VALUE_ACCESSORS);
842 }
843 Object.__defineSetter__.call(object, propertyString, descriptor.set);
844 }
845
846 // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
847 if ('value' in descriptor) {
848 object[propertyString] = descriptor.value;
849 }
850
851 return object;
852 };
853 }(Object.defineProperty));
854
855 // _ESAbstract.CreateDataProperty
856 // 7.3.4. CreateDataProperty ( O, P, V )
857 // NOTE
858 // This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator.
859 // 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.
860 function CreateDataProperty(O, P, V) {
861 // eslint-disable-line no-unused-vars
862 // 1. Assert: Type(O) is Object.
863 // 2. Assert: IsPropertyKey(P) is true.
864 // 3. Let newDesc be the PropertyDescriptor{ [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.
865 var newDesc = {
866 value: V,
867 writable: true,
868 enumerable: true,
869 configurable: true
870 };
871 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
872 try {
873 Object.defineProperty(O, P, newDesc);
874 return true;
875 } catch (e) {
876 return false;
877 }
878 }
879
880 // _ESAbstract.CreateDataPropertyOrThrow
881 /* global CreateDataProperty */
882 // 7.3.6. CreateDataPropertyOrThrow ( O, P, V )
883 function CreateDataPropertyOrThrow(O, P, V) {
884 // eslint-disable-line no-unused-vars
885 // 1. Assert: Type(O) is Object.
886 // 2. Assert: IsPropertyKey(P) is true.
887 // 3. Let success be ? CreateDataProperty(O, P, V).
888 var success = CreateDataProperty(O, P, V);
889 // 4. If success is false, throw a TypeError exception.
890 if (!success) {
891 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) + '`');
892 }
893 // 5. Return success.
894 return success;
895 }
896
897 // _ESAbstract.CreateIterResultObject
898 /* global Type, CreateDataProperty */
899 // 7.4.7. CreateIterResultObject ( value, done )
900 function CreateIterResultObject(value, done) {
901 // eslint-disable-line no-unused-vars
902 // 1. Assert: Type(done) is Boolean.
903 if (Type(done) !== 'boolean') {
904 throw new Error();
905 }
906 // 2. Let obj be ObjectCreate(%ObjectPrototype%).
907 var obj = {};
908 // 3. Perform CreateDataProperty(obj, "value", value).
909 CreateDataProperty(obj, "value", value);
910 // 4. Perform CreateDataProperty(obj, "done", done).
911 CreateDataProperty(obj, "done", done);
912 // 5. Return obj.
913 return obj;
914 }
915
916 // _ESAbstract.CreateMethodProperty
917 // 7.3.5. CreateMethodProperty ( O, P, V )
918 function CreateMethodProperty(O, P, V) {
919 // eslint-disable-line no-unused-vars
920 // 1. Assert: Type(O) is Object.
921 // 2. Assert: IsPropertyKey(P) is true.
922 // 3. Let newDesc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}.
923 var newDesc = {
924 value: V,
925 writable: true,
926 enumerable: false,
927 configurable: true
928 };
929 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
930 Object.defineProperty(O, P, newDesc);
931 }
932
933 // Array.isArray
934 /* global CreateMethodProperty, IsArray */
935 // 22.1.2.2. Array.isArray ( arg )
936 CreateMethodProperty(Array, 'isArray', function isArray(arg) {
937 // 1. Return ? IsArray(arg).
938 return IsArray(arg);
939 });
940
941 // Array.prototype.copyWithin
942 /* global CreateMethodProperty, HasProperty, ToInteger */
943 // 22.1.3.3 Array.prototype.copyWithin ( target, start [ , end ] )
944 CreateMethodProperty(Array.prototype, 'copyWithin', function copyWithin(target, start /* [ , end ] */
945 ) {
946 'use strict';
947 var end = arguments[2];
948
949 // 22.1.3.3.1 Let O be ? ToObject(this value).
950 if (this === null || this === undefined) {
951 throw new TypeError('Cannot call method on ' + this);
952 }
953
954 var o = Object(this);
955
956 // 22.1.3.3.2 Let len be ? ToLength(? Get(O, "length")).
957 var len = ToInteger(o.length);
958 if (len <= 0) {
959 len = 0;
960 }
961 if (len === Infinity) {
962 len = Math.pow(2, 53) - 1;
963 } else {
964 len = Math.min(len, Math.pow(2, 53) - 1);
965 }
966 len = Math.max(len, 0);
967
968 // 22.1.3.3.3 Let relativeTarget be ? ToInteger(target).
969 var relativeTarget = ToInteger(target);
970
971 // 22.1.3.3.4 If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let to be min(relativeTarget, len).
972 var to;
973 if (relativeTarget < 0) {
974 to = Math.max(len + relativeTarget, 0);
975 } else {
976 to = Math.min(relativeTarget, len);
977 }
978
979 // 22.1.3.3.5 Let relativeStart be ? ToInteger(start).
980 var relativeStart = ToInteger(start);
981
982 // 22.1.3.3.6 If relativeStart < 0, let from be max((len + relativeStart), 0); else let from be min(relativeStart, len).
983 var from;
984 if (relativeStart < 0) {
985 from = Math.max(len + relativeStart, 0);
986 } else {
987 from = Math.min(relativeStart, len);
988 }
989
990 // 22.1.3.3.7 If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
991 var relativeEnd;
992 if (end === undefined) {
993 relativeEnd = len;
994 } else {
995 relativeEnd = ToInteger(end);
996 }
997
998 // 22.1.3.3.8 If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
999 var final;
1000 if (relativeEnd < 0) {
1001 final = Math.max(len + relativeEnd, 0);
1002 } else {
1003 final = Math.min(relativeEnd, len);
1004 }
1005
1006 // 22.1.3.3.9 Let count be min(final-from, len-to).
1007 var count = Math.min(final - from, len - to);
1008
1009 // 22.1.3.3.10 If from<to and to<from+count, then
1010 var direction;
1011 if (from < to && to < from + count) {
1012 // 22.1.3.3.10.a Let direction be -1.
1013 direction = - 1;
1014
1015 // 22.1.3.3.10.b Let from be from + count - 1.
1016 from = from + count - 1;
1017
1018 // 22.1.3.3.10.c Let to be to + count - 1.
1019 to = to + count - 1;
1020 } else {
1021 // 22.1.3.3.11 Else,
1022 // 22.1.3.3.11.a Let direction be 1.
1023 direction = 1;
1024 }
1025
1026 // 22.1.3.3.12 Repeat, while count > 0
1027 while (count > 0) {
1028 // 22.1.3.3.12.a Let fromKey be ! ToString(from).
1029 var fromKey = String(from);
1030 // 22.1.3.3.12.b Let toKey be ! ToString(to).
1031 var toKey = String(to);
1032 // 22.1.3.3.12.c Let fromPresent be ? HasProperty(O, fromKey).
1033 var fromPresent = HasProperty(o, fromKey);
1034 // 22.1.3.3.12.d If fromPresent is true, then
1035 if (fromPresent) {
1036 // 22.1.3.3.12.d.i Let fromVal be ? Get(O, fromKey).
1037 var fromVal = o[fromKey];
1038 // 22.1.3.3.12.d.ii Perform ? Set(O, toKey, fromVal, true).
1039 o[toKey] = fromVal;
1040 } else {
1041 // 22.1.3.3.12.e Else fromPresent is false,
1042 // 22.1.3.3.12.e.i Perform ? DeletePropertyOrThrow(O, toKey).
1043 delete o[toKey];
1044 }
1045 // 22.1.3.3.12.f Let from be from + direction.
1046 from = from + direction;
1047 // 22.1.3.3.12.g Let to be to + direction.
1048 to = to + direction;
1049 // 22.1.3.3.12.h Let count be count - 1.
1050 count = count - 1;
1051 }
1052 // 22.1.3.3.13 Return O.
1053 return o;
1054 });
1055
1056 // Array.prototype.fill
1057 /* global CreateMethodProperty, Get, ToInteger, ToLength, ToObject, ToString */
1058 // 22.1.3.6. Array.prototype.fill ( value [ , start [ , end ] ] )
1059 CreateMethodProperty(Array.prototype, 'fill', function fill(value /* [ , start [ , end ] ] */
1060 ) {
1061 var start = arguments[1];
1062 var end = arguments[2];
1063 // 1. Let O be ? ToObject(this value).
1064 var O = ToObject(this);
1065 // 2. Let len be ? ToLength(? Get(O, "length")).
1066 var len = ToLength(Get(O, "length"));
1067 // 3. Let relativeStart be ? ToInteger(start).
1068 var relativeStart = ToInteger(start);
1069 // 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be min(relativeStart, len)
1070 var k = relativeStart < 0 ? Math.max((len + relativeStart), 0) : Math.min(relativeStart, len);
1071 // 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
1072 var relativeEnd = end === undefined ? len : ToInteger(end);
1073 // 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
1074 var final = relativeEnd < 0 ? Math.max((len + relativeEnd), 0) : Math.min(relativeEnd, len);
1075 // 7. Repeat, while k < final
1076 while (k < final) {
1077 // a. Let Pk be ! ToString(k).
1078 var Pk = ToString(k);
1079 // b. Perform ? Set(O, Pk, value, true).
1080 O[Pk] = value;
1081 // c. Increase k by 1.
1082 k = k + 1;
1083 }
1084 // 8. Return O.
1085 return O;
1086 });
1087
1088 // Array.prototype.find
1089 /* global Call, CreateMethodProperty, Get, IsCallable, ToBoolean, ToLength, ToObject, ToString */
1090 // 22.1.3.8 Array.prototype.find ( predicate [ , thisArg ] )
1091 CreateMethodProperty(Array.prototype, 'find', function find( predicate /* [ , thisArg ] */
1092 ) {
1093 // 1. Let O be ? ToObject(this value).
1094 var O = ToObject(this);
1095 // 2. Let len be ? ToLength(? Get(O, "length")).
1096 var len = ToLength(Get(O, "length"));
1097 // 3. If IsCallable(predicate) is false, throw a TypeError exception.
1098 if (IsCallable(predicate) === false) {
1099 throw new TypeError(predicate + ' is not a function');
1100 }
1101 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
1102 var T = arguments.length > 1 ? arguments[1] : undefined;
1103 // 5. Let k be 0.
1104 var k = 0;
1105 // 6. Repeat, while k < len
1106 while (k < len) {
1107 // a. Let Pk be ! ToString(k).
1108 var Pk = ToString(k);
1109 // b. Let kValue be ? Get(O, Pk).
1110 var kValue = Get(O, Pk);
1111 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
1112 var testResult = ToBoolean(Call(predicate, T, [kValue, k, O ]));
1113 // d. If testResult is true, return kValue.
1114 if (testResult) {
1115 return kValue;
1116 }
1117 // e. Increase k by 1.
1118 var k = k + 1;
1119 }
1120 // 7. Return undefined.
1121 return undefined;
1122 });
1123
1124 // Array.prototype.findIndex
1125 /* global Call, CreateMethodProperty, Get, IsCallable, ToBoolean, ToLength, ToObject, ToString */
1126 // 22.1.3.9. Array.prototype.findIndex ( predicate [ , thisArg ] )
1127 CreateMethodProperty(Array.prototype, 'findIndex', function findIndex(predicate /* [ , thisArg ] */
1128 ) {
1129 // 1. Let O be ? ToObject(this value).
1130 var O = ToObject(this);
1131 // 2. Let len be ? ToLength(? Get(O, "length")).
1132 var len = ToLength(Get(O, "length"));
1133 // 3. If IsCallable(predicate) is false, throw a TypeError exception.
1134 if (IsCallable(predicate) === false) {
1135 throw new TypeError(predicate + ' is not a function');
1136 }
1137 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
1138 var T = arguments.length > 1 ? arguments[1] : undefined;
1139 // 5. Let k be 0.
1140 var k = 0;
1141 // 6. Repeat, while k < len
1142 while (k < len) {
1143 // a. Let Pk be ! ToString(k).
1144 var Pk = ToString(k);
1145 // b. Let kValue be ? Get(O, Pk).
1146 var kValue = Get(O, Pk);
1147 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
1148 var testResult = ToBoolean(Call(predicate, T, [kValue, k, O]));
1149 // d. If testResult is true, return k.
1150 if (testResult) {
1151 return k;
1152 }
1153 // e. Increase k by 1.
1154 k = k + 1;
1155 }
1156 // 7. Return -1.
1157 return - 1;
1158 });
1159
1160 // Array.prototype.forEach
1161 /* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
1162 // 22.1.3.10. Array.prototype.forEach ( callbackfn [ , thisArg ] )
1163 CreateMethodProperty(Array.prototype, 'forEach', function forEach(callbackfn /* [ , thisArg ] */
1164 ) {
1165 // 1. Let O be ? ToObject(this value).
1166 var O = ToObject(this);
1167 // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
1168 // We will use arrayLike in place of O when we are iterating through the list.
1169 var arraylike = O instanceof String ? O.split('') : O;
1170 // 2. Let len be ? ToLength(? Get(O, "length")).
1171 var len = ToLength(Get(O, "length"));
1172 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
1173 if (IsCallable(callbackfn) === false) {
1174 throw new TypeError(callbackfn + ' is not a function');
1175 }
1176 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
1177 var T = arguments.length > 1 ? arguments[1] : undefined;
1178 // 5. Let k be 0.
1179 var k = 0;
1180 // 6. Repeat, while k < len
1181 while (k < len) {
1182 // a. Let Pk be ! ToString(k).
1183 var Pk = ToString(k);
1184 // b. Let kPresent be ? HasProperty(O, Pk).
1185 var kPresent = HasProperty(arraylike, Pk);
1186 // c. If kPresent is true, then
1187 if (kPresent) {
1188 // i. Let kValue be ? Get(O, Pk).
1189 var kValue = Get(arraylike, Pk);
1190 // ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
1191 Call(callbackfn, T, [kValue, k, O]);
1192 }
1193 // d. Increase k by 1.
1194 k = k + 1;
1195 }
1196 // 7. Return undefined.
1197 return undefined;
1198 });
1199
1200 // Array.prototype.includes
1201 /* global CreateMethodProperty, Get, SameValueZero, ToInteger, ToLength, ToObject, ToString */
1202 // 22.1.3.11. Array.prototype.includes ( searchElement [ , fromIndex ] )
1203 CreateMethodProperty(Array.prototype, 'includes', function includes(searchElement /* [ , fromIndex ] */
1204 ) {
1205 'use strict';
1206 // 1. Let O be ? ToObject(this value).
1207 var O = ToObject(this);
1208 // 2. Let len be ? ToLength(? Get(O, "length")).
1209 var len = ToLength(Get(O, "length"));
1210 // 3. If len is 0, return false.
1211 if (len === 0) {
1212 return false;
1213 }
1214 // 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.)
1215 var n = ToInteger(arguments[1]);
1216 // 5. If n ≥ 0, then
1217 if (n >= 0) {
1218 // a. Let k be n.
1219 var k = n;
1220 // 6. Else n < 0,
1221 } else {
1222 // a. Let k be len + n.
1223 k = len + n;
1224 // b. If k < 0, let k be 0.
1225 if (k < 0) {
1226 k = 0;
1227 }
1228 }
1229 // 7. Repeat, while k < len
1230 while (k < len) {
1231 // a. Let elementK be the result of ? Get(O, ! ToString(k)).
1232 var elementK = Get(O, ToString(k));
1233 // b. If SameValueZero(searchElement, elementK) is true, return true.
1234 if (SameValueZero(searchElement, elementK)) {
1235 return true;
1236 }
1237 // c. Increase k by 1.
1238 k = k + 1;
1239 }
1240 // 8. Return false.
1241 return false;
1242 });
1243
1244 // Function.prototype.bind
1245 /* global CreateMethodProperty, IsCallable */
1246 // 19.2.3.2. Function.prototype.bind ( thisArg, ...args )
1247 // https://github.com/es-shims/es5-shim/blob/d6d7ff1b131c7ba14c798cafc598bb6780d37d3b/es5-shim.js#L182
1248 CreateMethodProperty(Function.prototype, 'bind', function bind(that) {
1249 // .length is 1
1250 // add necessary es5-shim utilities
1251 var $Array = Array;
1252 var $Object = Object;
1253 var ArrayPrototype = $Array.prototype;
1254 var Empty = function Empty() {};
1255 var array_slice = ArrayPrototype.slice;
1256 var array_concat = ArrayPrototype.concat;
1257 var array_push = ArrayPrototype.push;
1258 var max = Math.max;
1259 // /add necessary es5-shim utilities
1260
1261 // 1. Let Target be the this value.
1262 var target = this;
1263 // 2. If IsCallable(Target) is false, throw a TypeError exception.
1264 if (!IsCallable(target)) {
1265 throw new TypeError('Function.prototype.bind called on incompatible ' + target);
1266 }
1267 // 3. Let A be a new (possibly empty) internal list of all of the
1268 // argument values provided after thisArg (arg1, arg2 etc), in order.
1269 // XXX slicedArgs will stand in for "A" if used
1270 var args = array_slice.call(arguments, 1); // for normal call
1271 // 4. Let F be a new native ECMAScript object.
1272 // 11. Set the [[Prototype]] internal property of F to the standard
1273 // built-in Function prototype object as specified in 15.3.3.1.
1274 // 12. Set the [[Call]] internal property of F as described in
1275 // 15.3.4.5.1.
1276 // 13. Set the [[Construct]] internal property of F as described in
1277 // 15.3.4.5.2.
1278 // 14. Set the [[HasInstance]] internal property of F as described in
1279 // 15.3.4.5.3.
1280 var bound;
1281 var binder = function () {
1282
1283 if (this instanceof bound) {
1284 // 15.3.4.5.2 [[Construct]]
1285 // When the [[Construct]] internal method of a function object,
1286 // F that was created using the bind function is called with a
1287 // list of arguments ExtraArgs, the following steps are taken:
1288 // 1. Let target be the value of F's [[TargetFunction]]
1289 // internal property.
1290 // 2. If target has no [[Construct]] internal method, a
1291 // TypeError exception is thrown.
1292 // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
1293 // property.
1294 // 4. Let args be a new list containing the same values as the
1295 // list boundArgs in the same order followed by the same
1296 // values as the list ExtraArgs in the same order.
1297 // 5. Return the result of calling the [[Construct]] internal
1298 // method of target providing args as the arguments.
1299
1300 var result = target.apply(
1301 this,
1302 array_concat.call(args, array_slice.call(arguments))
1303 );
1304 if ($Object(result) === result) {
1305 return result;
1306 }
1307 return this;
1308
1309 } else {
1310 // 15.3.4.5.1 [[Call]]
1311 // When the [[Call]] internal method of a function object, F,
1312 // which was created using the bind function is called with a
1313 // this value and a list of arguments ExtraArgs, the following
1314 // steps are taken:
1315 // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
1316 // property.
1317 // 2. Let boundThis be the value of F's [[BoundThis]] internal
1318 // property.
1319 // 3. Let target be the value of F's [[TargetFunction]] internal
1320 // property.
1321 // 4. Let args be a new list containing the same values as the
1322 // list boundArgs in the same order followed by the same
1323 // values as the list ExtraArgs in the same order.
1324 // 5. Return the result of calling the [[Call]] internal method
1325 // of target providing boundThis as the this value and
1326 // providing args as the arguments.
1327
1328 // equiv: target.call(this, ...boundArgs, ...args)
1329 return target.apply(
1330 that,
1331 array_concat.call(args, array_slice.call(arguments))
1332 );
1333
1334 }
1335
1336 };
1337
1338 // 15. If the [[Class]] internal property of Target is "Function", then
1339 // a. Let L be the length property of Target minus the length of A.
1340 // b. Set the length own property of F to either 0 or L, whichever is
1341 // larger.
1342 // 16. Else set the length own property of F to 0.
1343
1344 var boundLength = max(0, target.length - args.length);
1345
1346 // 17. Set the attributes of the length own property of F to the values
1347 // specified in 15.3.5.1.
1348 var boundArgs = [];
1349 for (var i = 0; i < boundLength; i++) {
1350 array_push.call(boundArgs, '$' + i);
1351 }
1352
1353 // XXX Build a dynamic function with desired amount of arguments is the only
1354 // way to set the length property of a function.
1355 // In environments where Content Security Policies enabled (Chrome extensions,
1356 // for ex.) all use of eval or Function costructor throws an exception.
1357 // However in all of these environments Function.prototype.bind exists
1358 // and so this code will never be executed.
1359 bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
1360
1361 if (target.prototype) {
1362 Empty.prototype = target.prototype;
1363 bound.prototype = new Empty();
1364 // Clean up dangling references.
1365 Empty.prototype = null;
1366 }
1367
1368 // TODO
1369 // 18. Set the [[Extensible]] internal property of F to true.
1370
1371 // TODO
1372 // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
1373 // 20. Call the [[DefineOwnProperty]] internal method of F with
1374 // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
1375 // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
1376 // false.
1377 // 21. Call the [[DefineOwnProperty]] internal method of F with
1378 // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
1379 // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
1380 // and false.
1381
1382 // TODO
1383 // NOTE Function objects created using Function.prototype.bind do not
1384 // have a prototype property or the [[Code]], [[FormalParameters]], and
1385 // [[Scope]] internal properties.
1386 // XXX can't delete prototype in pure-js.
1387
1388 // 22. Return F.
1389 return bound;
1390 });
1391
1392 // Math.acosh
1393 /* global CreateMethodProperty */
1394 // 20.2.2.3. Math.acosh ( x )
1395 CreateMethodProperty(Math, 'acosh', function acosh(x) {
1396 // If x is NaN, the result is NaN.
1397 if (isNaN(x)) {
1398 return NaN;
1399 }
1400 // If x is less than 1, the result is NaN.
1401 if (x < 1) {
1402 return NaN;
1403 }
1404 // If x is 1, the result is +0.
1405 if (x === 1) {
1406 return 0;
1407 }
1408 // If x is +∞, the result is +∞.
1409 if (x === Infinity) {
1410 return Infinity;
1411 }
1412 return Math.log(x + Math.sqrt(x * x - 1));
1413 });
1414
1415 // Math.asinh
1416 /* global CreateMethodProperty */
1417 // 20.2.2.5. Math.asinh ( x )
1418 CreateMethodProperty(Math, 'asinh', function asinh(x) {
1419 // If x is NaN, the result is NaN.
1420 if (isNaN(x)) {
1421 return NaN;
1422 }
1423 // If x is +0, the result is +0.
1424 if (x === 0 && 1 / x === Infinity) {
1425 return 0;
1426 }
1427 // If x is -0, the result is -0.
1428 if (x === 0 && 1 / x === - Infinity) {
1429 return - 0;
1430 }
1431 // If x is +∞, the result is +∞.
1432 if (x === Infinity) {
1433 return Infinity;
1434 }
1435 // If x is -∞, the result is -∞.
1436 if (x === - Infinity) {
1437 return - Infinity;
1438 }
1439 return Math.log(x + Math.sqrt(x * x + 1));
1440 });
1441
1442 // Math.atanh
1443 /* global CreateMethodProperty */
1444 // 20.2.2.7. Math.atanh ( x )
1445 CreateMethodProperty(Math, 'atanh', function atanh(x) {
1446 // If x is NaN, the result is NaN.
1447 if (isNaN(x)) {
1448 return NaN;
1449 }
1450 // If x is less than -1, the result is NaN.
1451 if (x < - 1) {
1452 return NaN;
1453 }
1454 // If x is greater than 1, the result is NaN.
1455 if (x > 1) {
1456 return NaN;
1457 }
1458 // If x is -1, the result is -∞.
1459 if (x === - 1) {
1460 return - Infinity;
1461 }
1462 // If x is +1, the result is +∞.
1463 if (x === 1) {
1464 return Infinity;
1465 }
1466 // If x is +0, the result is +0.
1467 if (x === 0 && 1 / x === Infinity) {
1468 return 0;
1469 }
1470 // If x is -0, the result is -0.
1471 if (x === 0 && 1 / x === - Infinity) {
1472 return - 0;
1473 }
1474 return Math.log((1 + x) / (1 - x)) / 2;
1475 });
1476
1477 // Math.cbrt
1478 /* global CreateMethodProperty */
1479 // 20.2.2.9. Math.cbrt ( x )
1480 CreateMethodProperty(Math, 'cbrt', function cbrt(x) {
1481 // If x is NaN, the result is NaN.
1482 if (isNaN(x)) {
1483 return NaN;
1484 }
1485 // If x is +0, the result is +0.
1486 if (x === 0 && 1 / x === Infinity) {
1487 return 0;
1488 }
1489 // If x is -0, the result is -0.
1490 if (x === 0 && 1 / x === - Infinity) {
1491 return - 0;
1492 }
1493 // If x is +∞, the result is +∞.
1494 if (x === Infinity) {
1495 return Infinity;
1496 }
1497 // If x is -∞, the result is -∞.
1498 if (x === - Infinity) {
1499 return - Infinity;
1500 }
1501 var y = Math.pow(Math.abs(x), 1 / 3);
1502 return x < 0 ? - y : y;
1503 });
1504
1505 // Math.clz32
1506 /* global CreateMethodProperty, ToUint32 */
1507 // 20.2.2.11. Math.clz32 ( x )
1508 CreateMethodProperty(Math, 'clz32', function clz32(x) {
1509 // 1. Let n be ToUint32(x).
1510 var n = ToUint32(x);
1511 // 2. Let p be the number of leading zero bits in the 32-bit binary representation of n.
1512 var p = n ? 32 - n.toString(2).length : 32;
1513 // 3. Return p.
1514 return p;
1515 });
1516
1517 // Math.cosh
1518 /* global CreateMethodProperty */
1519 // 20.2.2.1. 3Math.cosh ( x )
1520 CreateMethodProperty(Math, 'cosh', function cosh(x) {
1521 // If x is NaN, the result is NaN.
1522 if (isNaN(x)) {
1523 return NaN;
1524 }
1525 // If x is +0, the result is 1.
1526 if (x === 0 && 1 / x === Infinity) {
1527 return 1;
1528 }
1529 // If x is -0, the result is 1.
1530 if (x === 0 && 1 / x === - Infinity) {
1531 return 1;
1532 }
1533 // If x is +∞, the result is +∞.
1534 if (x === Infinity) {
1535 return Infinity;
1536 }
1537 // If x is -∞, the result is +∞.
1538 if (x === - Infinity) {
1539 return Infinity;
1540 }
1541 x = Math.abs(x);
1542 if (x > 709) {
1543 var y = Math.exp(0.5 * x);
1544 return y / 2 * y;
1545 }
1546 var y = Math.exp(x);
1547 return (y + 1 / y) / 2;
1548 });
1549
1550 // Math.expm1
1551 /* global CreateMethodProperty */
1552 // 20.2.2.15. Math.expm1 ( x )
1553 CreateMethodProperty(Math, 'expm1', function expm1(x) {
1554 // If x is NaN, the result is NaN.
1555 if (isNaN(x)) {
1556 return NaN;
1557 }
1558 // If x is +0, the result is +0.
1559 if (x === 0 && 1 / x === Infinity) {
1560 return 0;
1561 }
1562 // If x is -0, the result is -0.
1563 if (x === 0 && 1 / x === - Infinity) {
1564 return - 0;
1565 }
1566 // If x is +∞, the result is +∞.
1567 if (x === Infinity) {
1568 return Infinity;
1569 }
1570 // If x is -∞, the result is -1.
1571 if (x === - Infinity) {
1572 return - 1;
1573 }
1574
1575 if (x > - 1e-6 && x < 1e-6) {
1576 return x + x * x / 2;
1577 } else {
1578 return Math.exp(x) - 1;
1579 }
1580 });
1581
1582 // Math.hypot
1583 /* global CreateMethodProperty */
1584 // 20.2.2.18. Math.hypot ( value1, value2, ...values )
1585 CreateMethodProperty(Math, 'hypot', function hypot(value1, value2) {
1586 // eslint-disable-line no-unused-vars
1587 // If no arguments are passed, the result is +0.
1588 if (arguments.length === 0) {
1589 return 0;
1590 }
1591 var y = 0;
1592 var max = 0;
1593 for (var i = 0; i < arguments.length; ++i) {
1594 // If any argument is +∞, the result is +∞.
1595 if (arguments[i] === Infinity) {
1596 return Infinity;
1597 }
1598
1599 // If any argument is -∞, the result is +∞.
1600 if (arguments[i] === - Infinity) {
1601 return Infinity;
1602 }
1603
1604 // If no argument is +∞ or -∞, and any argument is NaN, the result is NaN.
1605 // If all arguments are either +0 or -0, the result is +0.
1606 // Polyfill.io - The two conditions above are handled in the math.
1607
1608 var arg = Math.abs(Number(arguments[i]));
1609 if (arg > max) {
1610 y = y * Math.pow(max / arg, 2);
1611 max = arg;
1612 }
1613 if (arg !== 0 || max !== 0) {
1614 y = y + Math.pow(arg / max, 2);
1615 }
1616 }
1617
1618 return max * Math.sqrt(y);
1619 });
1620
1621 // Math.imul
1622 /* global CreateMethodProperty, ToUint32 */
1623 // 20.2.2.19. Math.imul ( x, y )
1624 CreateMethodProperty(Math, 'imul', function imul(x, y) {
1625 // 1. Let a be ToUint32(x).
1626 var a = ToUint32(x);
1627 // 2. Let b be ToUint32(y).
1628 var b = ToUint32(y);
1629 var UINT16 = 0xffff;
1630 var aHigh = a >>> 16 & UINT16;
1631 var aLow = UINT16 & a;
1632 var bHigh = b >>> 16 & UINT16;
1633 var bLow = UINT16 & b;
1634 // the shift by 0 fixes the sign on the high part
1635 // the final |0 converts the unsigned value into a signed value
1636 return aLow * bLow + (aHigh * bLow + aLow * bHigh << 16 >>> 0) | 0;
1637 });
1638 // Math.log10
1639 /* global CreateMethodProperty */
1640 // 20.2.2.22. Math.log10 ( x )
1641 CreateMethodProperty(Math, 'log10', function log10(x) {
1642 return Math.log(x) / Math.LN10;
1643 });
1644
1645 // Math.log1p
1646 /* global CreateMethodProperty */
1647 // 20.2.2.21. Math.log1p ( x )
1648 CreateMethodProperty(Math, 'log1p', function log1p(x) {
1649 x = Number(x);
1650 if ( - 1 < x && x < 1) {
1651 // Polyfill.io - For numbers in the range −1 < x < 1
1652 // Because we are using log, the precision of the result will be identical to log(1).
1653 // To fix this we avoid using log and use the Taylor Series expansion of log.
1654 // This series converges when |x| < 1. As we can not sum to infinity,
1655 // we instead sum the first 300 parts of the series to give a close approximation.
1656 // |x|<1, log(1+x) = x - x^2/2 + x^3/3 - ... + (-1)^(n-1)*x^n/n + ...
1657 var y = x;
1658 for (var i = 2; i <= 300; i++) {
1659 y += Math.pow(( - 1), (i - 1)) * Math.pow(x, i) / i;
1660 }
1661 return y;
1662 }
1663
1664 return Math.log(1 + x);
1665 });
1666 // Math.log2
1667 /* global CreateMethodProperty */
1668 // 20.2.2.23. Math.log2 ( x )
1669 CreateMethodProperty(Math, 'log2', function log2(x) {
1670 return Math.log(x) / Math.LN2;
1671 });
1672
1673 // Math.sign
1674 /* global CreateMethodProperty */
1675 // 20.2.2.29. Math.sign ( x )
1676 CreateMethodProperty(Math, 'sign', function sign(x) {
1677 var x = Number(x);
1678 // If x is NaN, the result is NaN.
1679 if (isNaN(x)) {
1680 return NaN;
1681 }
1682 // If x is -0, the result is -0.
1683 if (1 / x === - Infinity) {
1684 return - 0;
1685 }
1686 // If x is +0, the result is +0.
1687 if (1 / x === Infinity) {
1688 return 0;
1689 }
1690 // If x is negative and not -0, the result is -1.
1691 if (x < 0) {
1692 return - 1;
1693 }
1694 // If x is positive and not +0, the result is +1.
1695 if (x > 0) {
1696 return 1;
1697 }
1698 });
1699
1700 // Math.sinh
1701 /* global CreateMethodProperty */
1702 // 20.2.2.31. Math.sinh ( x )
1703 CreateMethodProperty(Math, 'sinh', function sinh(x) {
1704 var s = (x < 0) ? - 1 : 1;
1705 var absx = Math.abs(x);
1706 if (absx < 22) {
1707 if (absx < Math.pow(2, - 28)) {
1708 return x;
1709 }
1710 var t = Math.exp(absx) - 1;
1711 if (absx < 1) {
1712 return (s * (2 * t - t * t / (t + 1))) / 2;
1713 }
1714 return (s * (t + t / (t + 1))) / 2;
1715 }
1716 if (absx < 709.7822265625) {
1717 return (s * Math.exp(absx)) / 2;
1718 }
1719 var w = Math.exp(0.5 * absx);
1720 var t = (s * w) / 2;
1721 return t * w;
1722 });
1723
1724 // Math.tanh
1725 /* global CreateMethodProperty */
1726 // 20.2.2.34. Math.tanh ( x )
1727 CreateMethodProperty(Math, 'tanh', function tanh(x) {
1728 var y;
1729
1730 return x === Infinity ? 1 : x === - Infinity ? - 1 : (y = Math.exp(2 * x), (y - 1) / (y + 1));
1731 });
1732
1733 // Math.trunc
1734 /* global CreateMethodProperty */
1735 CreateMethodProperty(Math, 'trunc', function trunc(x) {
1736 return x < 0 ? Math.ceil(x) : Math.floor(x);
1737 });
1738
1739 // Number.isFinite
1740 /* global CreateMethodProperty, Type */
1741 (function () {
1742 var that = this;
1743 // 20.1.2.2. Number.isFinite ( number )
1744 CreateMethodProperty(Number, 'isFinite', function isFinite(number) {
1745 // 1. If Type(number) is not Number, return false.
1746 if (Type(number) !== 'number') {
1747 return false;
1748 }
1749 // 2. If number is NaN, +∞, or -∞, return false.
1750 // 3. Otherwise, return true.
1751 // Polyfill.io - We use isFinite as it implements steps 2 and 3.
1752 return that.isFinite(number);
1753 });
1754 }());
1755
1756 // Number.isInteger
1757 /* global CreateMethodProperty, ToInteger, Type */
1758 // 20.1.2.3. Number.isInteger ( number )
1759 CreateMethodProperty(Number, 'isInteger', function isInteger(number) {
1760 // 1. If Type(number) is not Number, return false.
1761 if (Type(number) !== 'number') {
1762 return false;
1763 }
1764 // 2. If number is NaN, +∞, or -∞, return false.
1765 if (isNaN(number) || number === Infinity || number === - Infinity) {
1766 return false;
1767 }
1768 // 3. Let integer be ToInteger(number).
1769 var integer = ToInteger(number);
1770 // 4. If integer is not equal to number, return false.
1771 if (integer !== number) {
1772 return false;
1773 }
1774 // 5. Otherwise, return true.
1775 return true;
1776 });
1777
1778 // Number.isNaN
1779 /* global CreateMethodProperty, Type */
1780 (function () {
1781 var that = this;
1782 // 20.1.2.4. Number.isNaN ( number )
1783 CreateMethodProperty(Number, 'isNaN', function isNaN(number) {
1784 // 1. If Type(number) is not Number, return false.
1785 if (Type(number) !== 'number') {
1786 return false;
1787 }
1788 // 2. If number is NaN, return true.
1789 if (that.isNaN(number)) {
1790 return true;
1791 }
1792 // 3. Otherwise, return false.
1793 return false;
1794 });
1795 }());
1796
1797 // Number.isSafeInteger
1798 /* global CreateMethodProperty, Type, ToInteger */
1799 // 20.1.2.5. Number.isSafeInteger ( number )
1800 CreateMethodProperty(Number, 'isSafeInteger', function isSafeInteger(number) {
1801 // 1. If Type(number) is not Number, return false.
1802 if (Type(number) !== 'number') {
1803 return false;
1804 }
1805 // 2. If number is NaN, +∞, or -∞, return false.
1806 if (isNaN(number) || number === Infinity || number === - Infinity) {
1807 return false;
1808 }
1809 // 3. Let integer be ToInteger(number).
1810 var integer = ToInteger(number);
1811 // 4. If integer is not equal to number, return false.
1812 if (integer !== number) {
1813 return false;
1814 }
1815 // 5. If abs(integer) ≤ 2^53-1, return true.
1816 if (Math.abs(integer) <= (Math.pow(2, 53) - 1)) {
1817 return true;
1818 }
1819 // 6. Otherwise, return false.
1820 return false;
1821 });
1822
1823 // Number.parseFloat
1824 /* global CreateMethodProperty */
1825 // 20.1.2.12. Number.parseFloat ( string )
1826 // 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.
1827 CreateMethodProperty(Number, 'parseFloat', parseFloat);
1828
1829 // Number.parseInt
1830 /* global CreateMethodProperty */
1831 // 20.1.2.13. Number.parseInt ( string, radix )
1832 // 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.
1833 CreateMethodProperty(Number, 'parseInt', parseInt);
1834
1835 // Number.Epsilon
1836 // 20.1.2.1. Number.EPSILON
1837 // 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.
1838 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
1839 Object.defineProperty(Number, 'EPSILON', {
1840 enumerable: false,
1841 configurable: false,
1842 writable: false,
1843 value: Math.pow(2, - 52)
1844 });
1845
1846 // Number.MAX_SAFE_INTEGER
1847 // 20.1.2.6. Number.MAX_SAFE_INTEGER
1848 // The value of Number.MAX_SAFE_INTEGER is 9007199254740991 (2^53-1).
1849 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
1850 Object.defineProperty(Number, 'MAX_SAFE_INTEGER', {
1851 enumerable: false,
1852 configurable: false,
1853 writable: false,
1854 value: Math.pow(2, 53) - 1
1855 });
1856
1857 // Number.MIN_SAFE_INTEGER
1858 // 20.1.2.8. Number.MIN_SAFE_INTEGER
1859 // The value of Number.MIN_SAFE_INTEGER is -9007199254740991 (-(253-1)).
1860 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
1861 Object.defineProperty(Number, 'MIN_SAFE_INTEGER', {
1862 enumerable: false,
1863 configurable: false,
1864 writable: false,
1865 value: - (Math.pow(2, 53) - 1)
1866 });
1867
1868 // Object.freeze
1869 /* global CreateMethodProperty */
1870 // 19.1.2.6. Object.freeze ( O )
1871 CreateMethodProperty(Object, 'freeze', function freeze(O) {
1872 // This feature cannot be implemented fully as a polyfill.
1873 // We choose to silently fail which allows "securable" code
1874 // to "gracefully" degrade to working but insecure code.
1875 return O;
1876 });
1877
1878 // Object.getOwnPropertyDescriptor
1879 /* global CreateMethodProperty */
1880 (function () {
1881 var call = Function.prototype.call;
1882 var prototypeOfObject = Object.prototype;
1883 var owns = call.bind(prototypeOfObject.hasOwnProperty);
1884
1885 var lookupGetter;
1886 var lookupSetter;
1887 var supportsAccessors;
1888 if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
1889 lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
1890 lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
1891 }
1892 function doesGetOwnPropertyDescriptorWork(object) {
1893 try {
1894 object.sentinel = 0;
1895 return Object.getOwnPropertyDescriptor(
1896 object,
1897 "sentinel"
1898 ).value === 0;
1899 } catch (exception) {
1900 // returns falsy
1901 }
1902 }
1903 // check whether getOwnPropertyDescriptor works if it's given. Otherwise,
1904 // shim partially.
1905 if (Object.defineProperty) {
1906 var getOwnPropertyDescriptorWorksOnObject =
1907 doesGetOwnPropertyDescriptorWork({});
1908 var getOwnPropertyDescriptorWorksOnDom = typeof document == "undefined" ||
1909 doesGetOwnPropertyDescriptorWork(document.createElement("div"));
1910 if (!getOwnPropertyDescriptorWorksOnDom ||
1911 !getOwnPropertyDescriptorWorksOnObject
1912 ) {
1913 var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
1914 }
1915 }
1916
1917 if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
1918 var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
1919
1920 CreateMethodProperty(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(object, property) {
1921 if ((typeof object != "object" && typeof object != "function") || object === null) {
1922 throw new TypeError(ERR_NON_OBJECT + object);
1923 }
1924
1925 // make a valiant attempt to use the real getOwnPropertyDescriptor
1926 // for I8's DOM elements.
1927 if (getOwnPropertyDescriptorFallback) {
1928 try {
1929 return getOwnPropertyDescriptorFallback.call(Object, object, property);
1930 } catch (exception) {
1931 // try the shim if the real one doesn't work
1932 }
1933 }
1934
1935 // If object does not owns property return undefined immediately.
1936 if (!owns(object, property)) {
1937 return;
1938 }
1939
1940 // If object has a property then it's for sure both `enumerable` and
1941 // `configurable`.
1942 var descriptor = {
1943 enumerable: true,
1944 configurable: true
1945 };
1946
1947 // If JS engine supports accessor properties then property may be a
1948 // getter or setter.
1949 if (supportsAccessors) {
1950 // Unfortunately `__lookupGetter__` will return a getter even
1951 // if object has own non getter property along with a same named
1952 // inherited getter. To avoid misbehavior we temporary remove
1953 // `__proto__` so that `__lookupGetter__` will return getter only
1954 // if it's owned by an object.
1955 var prototype = object.__proto__;
1956 object.__proto__ = prototypeOfObject;
1957
1958 var getter = lookupGetter(object, property);
1959 var setter = lookupSetter(object, property);
1960
1961 // Once we have getter and setter we can put values back.
1962 object.__proto__ = prototype;
1963
1964 if (getter || setter) {
1965 if (getter) {
1966 descriptor.get = getter;
1967 }
1968 if (setter) {
1969 descriptor.set = setter;
1970 }
1971 // If it was accessor property we're done and return here
1972 // in order to avoid adding `value` to the descriptor.
1973 return descriptor;
1974 }
1975 }
1976
1977 // If we got this far we know that object has an own property that is
1978 // not an accessor so we set it as a value and return descriptor.
1979 descriptor.value = object[property];
1980 descriptor.writable = true;
1981 return descriptor;
1982 });
1983 }
1984 }());
1985
1986 // Object.getOwnPropertyNames
1987 /* global CreateMethodProperty */
1988
1989 var toString = ({}).toString;
1990 var split = ''.split;
1991
1992 CreateMethodProperty(Object, 'getOwnPropertyNames', function getOwnPropertyNames(object) {
1993 var buffer = [];
1994 var key;
1995
1996 // Non-enumerable properties cannot be discovered but can be checked for by name.
1997 // Define those used internally by JS to allow an incomplete solution
1998 var commonProps = ['length', "name", "arguments", "caller", "prototype", "observe", "unobserve"];
1999
2000 if (typeof object === 'undefined' || object === null) {
2001 throw new TypeError('Cannot convert undefined or null to object');
2002 }
2003
2004 // Polyfill.io fallback for non-array-like strings which exist in some ES3 user-agents (IE 8)
2005 object = toString.call(object) == '[object String]' ? split.call(object, '') : Object(object);
2006
2007 // Enumerable properties only
2008 for (key in object) {
2009 if (Object.prototype.hasOwnProperty.call(object, key)) {
2010 buffer.push(key);
2011 }
2012 }
2013
2014 // Check for and add the common non-enumerable properties
2015 for (var i = 0, s = commonProps.length; i < s; i++) {
2016 if (commonProps[i] in object)
2017 buffer.push(commonProps[i]);
2018 }
2019
2020 return buffer;
2021 });
2022
2023 // Object.getPrototypeOf
2024 /* global CreateMethodProperty */
2025 // Based on: https://github.com/es-shims/es5-shim/blob/master/es5-sham.js
2026
2027 // https://github.com/es-shims/es5-shim/issues#issue/2
2028 // http://ejohn.org/blog/objectgetprototypeof/
2029 // recommended by fschaefer on github
2030 //
2031 // sure, and webreflection says ^_^
2032 // ... this will nerever possibly return null
2033 // ... Opera Mini breaks here with infinite loops
2034 CreateMethodProperty(Object, 'getPrototypeOf', function getPrototypeOf(object) {
2035 if (object !== Object(object)) {
2036 throw new TypeError('Object.getPrototypeOf called on non-object');
2037 }
2038 var proto = object.__proto__;
2039 if (proto || proto === null) {
2040 return proto;
2041 } else if (typeof object.constructor == 'function' && object instanceof object.constructor) {
2042 return object.constructor.prototype;
2043 } else if (object instanceof Object) {
2044 return Object.prototype;
2045 } else {
2046 // Correctly return null for Objects created with `Object.create(null)`
2047 // (shammed or native) or `{ __proto__: null}`. Also returns null for
2048 // cross-realm objects on browsers that lack `__proto__` support (like
2049 // IE <11), but that's the best we can do.
2050 return null;
2051 }
2052 });
2053
2054 // Object.is
2055 /* global CreateMethodProperty, SameValue */
2056 // 19.1.2.12. Object.is ( value1, value2 )
2057 CreateMethodProperty(Object, 'is', function is(value1, value2) {
2058 // 1. Return SameValue(value1, value2).
2059 return SameValue(value1, value2);
2060 });
2061
2062 // Object.keys
2063 /* global CreateMethodProperty */
2064 CreateMethodProperty(Object, "keys", (function() {
2065 'use strict';
2066
2067 // modified from https://github.com/es-shims/object-keys
2068
2069 var has = Object.prototype.hasOwnProperty;
2070 var toStr = Object.prototype.toString;
2071 var isEnumerable = Object.prototype.propertyIsEnumerable;
2072 var hasDontEnumBug = !isEnumerable.call({
2073 toString: null
2074 }, 'toString');
2075 var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
2076 var dontEnums = [
2077 'toString',
2078 'toLocaleString',
2079 'valueOf',
2080 'hasOwnProperty',
2081 'isPrototypeOf',
2082 'propertyIsEnumerable',
2083 'constructor'
2084 ];
2085 var equalsConstructorPrototype = function (o) {
2086 var ctor = o.constructor;
2087 return ctor && ctor.prototype === o;
2088 };
2089 var excludedKeys = {
2090 $console: true,
2091 $external: true,
2092 $frame: true,
2093 $frameElement: true,
2094 $frames: true,
2095 $innerHeight: true,
2096 $innerWidth: true,
2097 $outerHeight: true,
2098 $outerWidth: true,
2099 $pageXOffset: true,
2100 $pageYOffset: true,
2101 $parent: true,
2102 $scrollLeft: true,
2103 $scrollTop: true,
2104 $scrollX: true,
2105 $scrollY: true,
2106 $self: true,
2107 $webkitIndexedDB: true,
2108 $webkitStorageInfo: true,
2109 $window: true
2110 };
2111 var hasAutomationEqualityBug = (function () {
2112 /* global window */
2113 if (typeof window === 'undefined') {
2114 return false;
2115 }
2116 for (var k in window) {
2117 try {
2118 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
2119 try {
2120 equalsConstructorPrototype(window[k]);
2121 } catch (e) {
2122 return true;
2123 }
2124 }
2125 } catch (e) {
2126 return true;
2127 }
2128 }
2129 return false;
2130 }());
2131 var equalsConstructorPrototypeIfNotBuggy = function (o) {
2132 /* global window */
2133 if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
2134 return equalsConstructorPrototype(o);
2135 }
2136 try {
2137 return equalsConstructorPrototype(o);
2138 } catch (e) {
2139 return false;
2140 }
2141 };
2142
2143 function isArgumentsObject(value) {
2144 var str = toStr.call(value);
2145 var isArgs = str === '[object Arguments]';
2146 if (!isArgs) {
2147 isArgs = str !== '[object Array]' &&
2148 value !== null &&
2149 typeof value === 'object' &&
2150 typeof value.length === 'number' &&
2151 value.length >= 0 &&
2152 toStr.call(value.callee) === '[object Function]';
2153 }
2154 return isArgs;
2155 }
2156
2157 return function keys(object) {
2158 var isFunction = toStr.call(object) === '[object Function]';
2159 var isArguments = isArgumentsObject(object);
2160 var isString = toStr.call(object) === '[object String]';
2161 var theKeys = [];
2162
2163 if (object === undefined || object === null) {
2164 throw new TypeError('Cannot convert undefined or null to object');
2165 }
2166
2167 var skipProto = hasProtoEnumBug && isFunction;
2168 if (isString && object.length > 0 && !has.call(object, 0)) {
2169 for (var i = 0; i < object.length; ++i) {
2170 theKeys.push(String(i));
2171 }
2172 }
2173
2174 if (isArguments && object.length > 0) {
2175 for (var j = 0; j < object.length; ++j) {
2176 theKeys.push(String(j));
2177 }
2178 } else {
2179 for (var name in object) {
2180 if (!(skipProto && name === 'prototype') && has.call(object, name)) {
2181 theKeys.push(String(name));
2182 }
2183 }
2184 }
2185
2186 if (hasDontEnumBug) {
2187 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
2188
2189 for (var k = 0; k < dontEnums.length; ++k) {
2190 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
2191 theKeys.push(dontEnums[k]);
2192 }
2193 }
2194 }
2195 return theKeys;
2196 };
2197 }()));
2198
2199 // Object.assign
2200 /* global CreateMethodProperty, Get, ToObject */
2201 // 19.1.2.1 Object.assign ( target, ...sources )
2202 CreateMethodProperty(Object, 'assign', function assign(target, source) {
2203 // eslint-disable-line no-unused-vars
2204 // 1. Let to be ? ToObject(target).
2205 var to = ToObject(target);
2206
2207 // 2. If only one argument was passed, return to.
2208 if (arguments.length === 1) {
2209 return to;
2210 }
2211
2212 // 3. Let sources be the List of argument values starting with the second argument
2213 var sources = Array.prototype.slice.call(arguments, 1);
2214
2215 // 4. For each element nextSource of sources, in ascending index order, do
2216 var index1;
2217 var index2;
2218 var keys;
2219 var from;
2220 for (index1 = 0; index1 < sources.length; index1++) {
2221 var nextSource = sources[index1];
2222 // a. If nextSource is undefined or null, let keys be a new empty List.
2223 if (nextSource === undefined || nextSource === null) {
2224 keys = [];
2225 // b. Else,
2226 } else {
2227 // i. Let from be ! ToObject(nextSource).
2228 from = ToObject(nextSource);
2229 // ii. Let keys be ? from.[[OwnPropertyKeys]]().
2230 /*
2231 This step in our polyfill is not complying with the specification.
2232 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
2233 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
2234 */
2235 keys = Object.keys(from);
2236 }
2237
2238 // c. For each element nextKey of keys in List order, do
2239 for (index2 = 0; index2 < keys.length; index2++) {
2240 var nextKey = keys[index2];
2241 var enumerable;
2242 try {
2243 // i. Let desc be ? from.[[GetOwnProperty]](nextKey).
2244 var desc = Object.getOwnPropertyDescriptor(from, nextKey);
2245 // ii. If desc is not undefined and desc.[[Enumerable]] is true, then
2246 enumerable = desc !== undefined && desc.enumerable === true;
2247 } catch (e) {
2248 // Polyfill.io - We use Object.prototype.propertyIsEnumerable as a fallback
2249 // because `Object.getOwnPropertyDescriptor(window.location, 'hash')` causes Internet Explorer 11 to crash.
2250 enumerable = Object.prototype.propertyIsEnumerable.call(from, nextKey);
2251 }
2252 if (enumerable) {
2253 // 1. Let propValue be ? Get(from, nextKey).
2254 var propValue = Get(from, nextKey);
2255 // 2. Perform ? Set(to, nextKey, propValue, true).
2256 to[nextKey] = propValue;
2257 }
2258 }
2259 }
2260 // 5. Return to.
2261 return to;
2262 });
2263
2264 // Object.defineProperties
2265 /* global CreateMethodProperty, Get, ToObject, Type */
2266 // 19.1.2.3. Object.defineProperties ( O, Properties )
2267 CreateMethodProperty(Object, 'defineProperties', function defineProperties(O, Properties) {
2268 // 1. If Type(O) is not Object, throw a TypeError exception.
2269 if (Type(O) !== 'object') {
2270 throw new TypeError('Object.defineProperties called on non-object');
2271 }
2272 // 2. Let props be ? ToObject(Properties).
2273 var props = ToObject(Properties);
2274 // 3. Let keys be ? props.[[OwnPropertyKeys]]().
2275 /*
2276 Polyfill.io - This step in our polyfill is not complying with the specification.
2277 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
2278 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
2279 */
2280 var keys = Object.keys(props);
2281 // 4. Let descriptors be a new empty List.
2282 var descriptors = [];
2283 // 5. For each element nextKey of keys in List order, do
2284 for (var i = 0; i < keys.length; i++) {
2285 var nextKey = keys[i];
2286 // a. Let propDesc be ? props.[[GetOwnProperty]](nextKey).
2287 var propDesc = Object.getOwnPropertyDescriptor(props, nextKey);
2288 // b. If propDesc is not undefined and propDesc.[[Enumerable]] is true, then
2289 if (propDesc !== undefined && propDesc.enumerable) {
2290 // i. Let descObj be ? Get(props, nextKey).
2291 var descObj = Get(props, nextKey);
2292 // ii. Let desc be ? ToPropertyDescriptor(descObj).
2293 // Polyfill.io - We skip this step because Object.defineProperty deals with it.
2294 // TODO: Implement this step?
2295 var desc = descObj;
2296 // iii. Append the pair (a two element List) consisting of nextKey and desc to the end of descriptors.
2297 descriptors.push([nextKey, desc]);
2298 }
2299 }
2300 // 6. For each pair from descriptors in list order, do
2301 for (var i = 0; i < descriptors.length; i++) {
2302 // a. Let P be the first element of pair.
2303 var P = descriptors[i][0];
2304 // b. Let desc be the second element of pair.
2305 var desc = descriptors[i][1];
2306 // c. Perform ? DefinePropertyOrThrow(O, P, desc).
2307 Object.defineProperty(O, P, desc);
2308 }
2309 // 7. Return O.
2310 return O;
2311 });
2312
2313 // Object.create
2314 /* global CreateMethodProperty, Type */
2315 CreateMethodProperty(Object, 'create', function create(O, properties) {
2316 // 1. If Type(O) is neither Object nor Null, throw a TypeError exception.
2317 if (Type(O) !== 'object' && Type(O) !== 'null') {
2318 throw new TypeError('Object prototype may only be an Object or null');
2319 }
2320 // 2. Let obj be ObjectCreate(O).
2321 var obj = new Function('e', 'function Object() {}Object.prototype=e;return new Object')(O);
2322
2323 obj.constructor.prototype = O;
2324
2325 // 3. If Properties is not undefined, then
2326 if (1 in arguments) {
2327 // a. Return ? ObjectDefineProperties(obj, Properties).
2328 return Object.defineProperties(obj, properties);
2329 }
2330
2331 return obj;
2332 });
2333
2334 // _ESAbstract.OrdinaryCreateFromConstructor
2335 /* global GetPrototypeFromConstructor */
2336 // 9.1.13. OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
2337 function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) {
2338 // eslint-disable-line no-unused-vars
2339 var internalSlotsList = arguments[2] || {};
2340 // 1. Assert: intrinsicDefaultProto is a String value that is this specification's name of an intrinsic object.
2341 // The corresponding object must be an intrinsic that is intended to be used as the[[Prototype]] value of an object.
2342
2343 // 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
2344 var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto);
2345
2346 // 3. Return ObjectCreate(proto, internalSlotsList).
2347 // 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.
2348 var obj = Object.create(proto);
2349 for (var name in internalSlotsList) {
2350 if (Object.prototype.hasOwnProperty.call(internalSlotsList, name)) {
2351 Object.defineProperty(obj, name, {
2352 configurable: true,
2353 enumerable: false,
2354 writable: true,
2355 value: internalSlotsList[name]
2356 });
2357 }
2358 }
2359 return obj;
2360 }
2361
2362 // _ESAbstract.Construct
2363 /* global IsConstructor, OrdinaryCreateFromConstructor, Call */
2364 // 7.3.13. Construct ( F [ , argumentsList [ , newTarget ]] )
2365 function Construct(F /* [ , argumentsList [ , newTarget ]] */
2366 ) {
2367 // eslint-disable-line no-unused-vars
2368 // 1. If newTarget is not present, set newTarget to F.
2369 var newTarget = arguments.length > 2 ? arguments[2] : F;
2370
2371 // 2. If argumentsList is not present, set argumentsList to a new empty List.
2372 var argumentsList = arguments.length > 1 ? arguments[1] : [];
2373
2374 // 3. Assert: IsConstructor(F) is true.
2375 if (!IsConstructor(F)) {
2376 throw new TypeError('F must be a constructor.');
2377 }
2378
2379 // 4. Assert: IsConstructor(newTarget) is true.
2380 if (!IsConstructor(newTarget)) {
2381 throw new TypeError('newTarget must be a constructor.');
2382 }
2383
2384 // 5. Return ? F.[[Construct]](argumentsList, newTarget).
2385 // Polyfill.io - If newTarget is the same as F, it is equivalent to new F(...argumentsList).
2386 if (newTarget === F) {
2387 return new (Function.prototype.bind.apply(F, [null].concat(argumentsList)))();
2388 } else {
2389 // Polyfill.io - This is mimicking section 9.2.2 step 5.a.
2390 var obj = OrdinaryCreateFromConstructor(newTarget, Object.prototype);
2391 return Call(F, obj, argumentsList);
2392 }
2393 }
2394
2395 // _ESAbstract.ArraySpeciesCreate
2396 /* global IsArray, ArrayCreate, Get, Type, IsConstructor, Construct */
2397 // 9.4.2.3. ArraySpeciesCreate ( originalArray, length )
2398 function ArraySpeciesCreate(originalArray, length) {
2399 // eslint-disable-line no-unused-vars
2400 // 1. Assert: length is an integer Number ≥ 0.
2401 // 2. If length is -0, set length to +0.
2402 if (1 / length === - Infinity) {
2403 length = 0;
2404 }
2405
2406 // 3. Let isArray be ? IsArray(originalArray).
2407 var isArray = IsArray(originalArray);
2408
2409 // 4. If isArray is false, return ? ArrayCreate(length).
2410 if (isArray === false) {
2411 return ArrayCreate(length);
2412 }
2413
2414 // 5. Let C be ? Get(originalArray, "constructor").
2415 var C = Get(originalArray, 'constructor');
2416
2417 // Polyfill.io - We skip this section as not sure how to make a cross-realm normal Array, a same-realm Array.
2418 // 6. If IsConstructor(C) is true, then
2419 // if (IsConstructor(C)) {
2420 // a. Let thisRealm be the current Realm Record.
2421 // b. Let realmC be ? GetFunctionRealm(C).
2422 // c. If thisRealm and realmC are not the same Realm Record, then
2423 // i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined.
2424 // }
2425 // 7. If Type(C) is Object, then
2426 if (Type(C) === 'object') {
2427 // a. Set C to ? Get(C, @@species).
2428 C = 'Symbol' in this && 'species' in this.Symbol ? Get(C, this.Symbol.species) : undefined;
2429 // b. If C is null, set C to undefined.
2430 if (C === null) {
2431 C = undefined;
2432 }
2433 }
2434 // 8. If C is undefined, return ? ArrayCreate(length).
2435 if (C === undefined) {
2436 return ArrayCreate(length);
2437 }
2438 // 9. If IsConstructor(C) is false, throw a TypeError exception.
2439 if (!IsConstructor(C)) {
2440 throw new TypeError('C must be a constructor');
2441 }
2442 // 10. Return ? Construct(C, « length »).
2443 return Construct(C, [length]);
2444 }
2445
2446 // Array.prototype.filter
2447 /* global CreateMethodProperty, ToObject, ToLength, Get, IsCallable, ArraySpeciesCreate, ToString, HasProperty, ToBoolean, Call, CreateDataPropertyOrThrow */
2448 // 22.1.3.7. Array.prototype.filter ( callbackfn [ , thisArg ] )
2449 CreateMethodProperty(Array.prototype, 'filter', function filter(callbackfn /* [ , thisArg ] */
2450 ) {
2451 // 1. Let O be ? ToObject(this value).
2452 var O = ToObject(this);
2453 // 2. Let len be ? ToLength(? Get(O, "length")).
2454 var len = ToLength(Get(O, "length"));
2455 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
2456 if (IsCallable(callbackfn) === false) {
2457 throw new TypeError(callbackfn + ' is not a function');
2458 }
2459 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
2460 var T = arguments.length > 1 ? arguments[1] : undefined;
2461 // 5. Let A be ? ArraySpeciesCreate(O, 0).
2462 var A = ArraySpeciesCreate(O, 0);
2463 // 6. Let k be 0.
2464 var k = 0;
2465 // 7. Let to be 0.
2466 var to = 0;
2467 // 8. Repeat, while k < len
2468 while (k < len) {
2469 // a. Let Pk be ! ToString(k).
2470 var Pk = ToString(k);
2471 // b. Let kPresent be ? HasProperty(O, Pk).
2472 var kPresent = HasProperty(O, Pk);
2473 // c. If kPresent is true, then
2474 if (kPresent) {
2475 // i. Let kValue be ? Get(O, Pk).
2476 var kValue = Get(O, Pk);
2477 // ii. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
2478 var selected = ToBoolean(Call(callbackfn, T, [kValue, k, O]));
2479 // iii. If selected is true, then
2480 if (selected) {
2481 // 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue)
2482 CreateDataPropertyOrThrow(A, ToString(to), kValue);
2483 // 2. Increase to by 1.
2484 to = to + 1;
2485 }
2486
2487 }
2488 // d. Increase k by 1.
2489 k = k + 1;
2490 }
2491 // 9. Return A.
2492 return A;
2493 });
2494
2495 // Array.prototype.map
2496 /* global ArraySpeciesCreate, Call, CreateDataPropertyOrThrow, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
2497 /* global CreateMethodProperty, ToObject, ToLength, Get, ArraySpeciesCreate, ToString, HasProperty, Call, CreateDataPropertyOrThrow */
2498 // 22.1.3.16. Array.prototype.map ( callbackfn [ , thisArg ] )
2499 CreateMethodProperty(Array.prototype, 'map', function map(callbackfn /* [ , thisArg ] */
2500 ) {
2501 // 1. Let O be ? ToObject(this value).
2502 var O = ToObject(this);
2503 // 2. Let len be ? ToLength(? Get(O, "length")).
2504 var len = ToLength(Get(O, "length"));
2505 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
2506 if (IsCallable(callbackfn) === false) {
2507 throw new TypeError(callbackfn + ' is not a function');
2508 }
2509 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
2510 var T = arguments.length > 1 ? arguments[1] : undefined;
2511 // 5. Let A be ? ArraySpeciesCreate(O, len).
2512 var A = ArraySpeciesCreate(O, len);
2513 // 6. Let k be 0.
2514 var k = 0;
2515 // 7. Repeat, while k < len
2516 while (k < len) {
2517 // a. Let Pk be ! ToString(k).
2518 var Pk = ToString(k);
2519 // b. Let kPresent be ? HasProperty(O, Pk).
2520 var kPresent = HasProperty(O, Pk);
2521 // c. If kPresent is true, then
2522 if (kPresent) {
2523 // i. Let kValue be ? Get(O, Pk).
2524 var kValue = Get(O, Pk);
2525 // ii. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
2526 var mappedValue = Call(callbackfn, T, [kValue, k, O]);
2527 // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
2528 CreateDataPropertyOrThrow(A, Pk, mappedValue);
2529 }
2530 // d. Increase k by 1.
2531 k = k + 1;
2532 }
2533 // 8. Return A.
2534 return A;
2535 });
2536
2537 // Array.of
2538 /* global ArrayCreate, Construct, CreateDataPropertyOrThrow, CreateMethodProperty, IsConstructor, ToString */
2539 // 22.1.2.3. Array.of ( ...items )
2540 CreateMethodProperty(Array, 'of', function of() {
2541 // 1. Let len be the actual number of arguments passed to this function.
2542 var len = arguments.length;
2543 // 2. Let items be the List of arguments passed to this function.
2544 var items = arguments;
2545 // 3. Let C be the this value.
2546 var C = this;
2547 // 4. If IsConstructor(C) is true, then
2548 if (IsConstructor(C)) {
2549 // a. Let A be ? Construct(C, « len »).
2550 var A = Construct(C, [len]);
2551 // 5. Else,
2552 } else {
2553 // a. Let A be ? ArrayCreate(len).
2554 var A = ArrayCreate(len);
2555 }
2556 // 6. Let k be 0.
2557 var k = 0;
2558 // 7. Repeat, while k < len
2559 while (k < len) {
2560 // a. Let kValue be items[k].
2561 var kValue = items[k];
2562 // b. Let Pk be ! ToString(k).
2563 var Pk = ToString(k);
2564 // c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue).
2565 CreateDataPropertyOrThrow(A, Pk, kValue);
2566 // d. Increase k by 1.
2567 var k = k + 1;
2568
2569 }
2570 // 8. Perform ? Set(A, "length", len, true)
2571 A["length"] = len;
2572 // 9. Return A.
2573 return A;
2574 });
2575
2576 // Object.seal
2577 /* global CreateMethodProperty, Type */
2578 // 19.1.2.19 Object.seal ( O )
2579 (function(originalObjectSeal) {
2580 CreateMethodProperty(Object, 'seal', function seal(O) {
2581 // 1. If Type(O) is not Object, return O.
2582 if (Type(O) === 'object') {
2583 return O;
2584 }
2585 // 2. Let status be ? SetIntegrityLevel(O, "sealed").
2586 // 3. If status is false, throw a TypeError exception.
2587 // 4. Return O.
2588 return originalObjectSeal ? originalObjectSeal(O) : O;
2589 });
2590 }(Object.seal));
2591
2592
2593 // Promise
2594 !function(n) {
2595 function t(r) {
2596 if (e[r])
2597 return e[r].exports;
2598 var o = e[r] = {
2599 i: r,
2600 l: !1,
2601 exports: {}
2602 };
2603 return n[r].call(o.exports, o, o.exports, t), o.l=!0, o.exports
2604 }
2605 var e = {};
2606 t.m = n, t.c = e, t.i = function(n) {
2607 return n
2608 }, t.d = function(n, e, r) {
2609 t.o(n, e) || Object.defineProperty(n, e, {
2610 configurable: !1,
2611 enumerable: !0,
2612 get: r
2613 })
2614 }, t.n = function(n) {
2615 var e = n && n.__esModule ? function() {
2616 return n["default"]
2617 }
2618 : function() {
2619 return n
2620 };
2621 return t.d(e, "a", e), e
2622 }, t.o = function(n, t) {
2623 return Object.prototype.hasOwnProperty.call(n, t)
2624 }, t.p = "", t(t.s = 100)
2625 }({
2626 100: /*!***********************!*\
2627 !*** ./src/global.js ***!
2628 \***********************/
2629 function(n, t, e) {
2630 (function(n) {
2631 var t = e( /*! ./yaku */
2632 5);
2633 try {
2634 n.Promise = t, window.Promise = t
2635 } catch (r) {}
2636 }).call(t, e( /*! ./../~/webpack/buildin/global.js */
2637 2))
2638 },
2639 2: /*!***********************************!*\
2640 !*** (webpack)/buildin/global.js ***!
2641 \***********************************/
2642 function(n, t) {
2643 var e;
2644 e = function() {
2645 return this
2646 }();
2647 try {
2648 e = e || Function("return this")() || (0, eval)("this")
2649 } catch (r) {
2650 "object" == typeof window && (e = window)
2651 }
2652 n.exports = e
2653 },
2654 5: /*!*********************!*\
2655 !*** ./src/yaku.js ***!
2656 \*********************/
2657 function(n, t, e) {
2658 (function(t) {
2659 !function() {
2660 "use strict";
2661 function e() {
2662 return rn[q][B] || D
2663 }
2664 function r(n) {
2665 return n && "object" == typeof n
2666 }
2667 function o(n) {
2668 return "function" == typeof n
2669 }
2670 function i(n, t) {
2671 return n instanceof t
2672 }
2673 function u(n) {
2674 return i(n, M)
2675 }
2676 function c(n, t, e) {
2677 if (!t(n))
2678 throw h(e)
2679 }
2680 function f() {
2681 try {
2682 return R.apply(S, arguments)
2683 } catch (n) {
2684 return nn.e = n, nn
2685 }
2686 }
2687 function s(n, t) {
2688 return R = n, S = t, f
2689 }
2690 function a(n, t) {
2691 function e() {
2692 for (var e = 0; e < o;)
2693 t(r[e], r[e + 1]), r[e++] = P, r[e++] = P;
2694 o = 0, r.length > n && (r.length = n)
2695 }
2696 var r = A(n), o = 0;
2697 return function(n, t) {
2698 r[o++] = n, r[o++] = t, 2 === o && rn.nextTick(e)
2699 }
2700 }
2701 function l(n, t) {
2702 var e, r, u, c, f = 0;
2703 if (!n)
2704 throw h(Q);
2705 var a = n[rn[q][z]];
2706 if (o(a))
2707 r = a.call(n);
2708 else {
2709 if (!o(n.next)) {
2710 if (i(n, A)) {
2711 for (e = n.length; f < e;)
2712 t(n[f], f++);
2713 return f
2714 }
2715 throw h(Q)
2716 }
2717 r = n
2718 }
2719 for (; !(u = r.next()).done;)
2720 if ((c = s(t)(u.value, f++)) === nn)
2721 throw o(r[G]) && r[G](), c.e;
2722 return f
2723 }
2724 function h(n) {
2725 return new TypeError(n)
2726 }
2727 function v(n) {
2728 return (n ? "" : V) + (new M).stack
2729 }
2730 function _(n, t) {
2731 var e = "on" + n.toLowerCase(), r = O[e];
2732 H && H.listeners(n).length ? n === Z ? H.emit(n, t._v, t) : H.emit(n, t) : r ? r({
2733 reason: t._v,
2734 promise: t
2735 }) : rn[n](t._v, t)
2736 }
2737 function p(n) {
2738 return n && n._s
2739 }
2740 function d(n) {
2741 if (p(n))
2742 return new n(tn);
2743 var t, e, r;
2744 return t = new n(function(n, o) {
2745 if (t)
2746 throw h();
2747 e = n, r = o
2748 }), c(e, o), c(r, o), t
2749 }
2750 function w(n, t) {
2751 var e=!1;
2752 return function(r) {
2753 e || (e=!0, L && (n[N] = v(!0)), t === Y ? k(n, r) : x(n, t, r))
2754 }
2755 }
2756 function y(n, t, e, r) {
2757 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
2758 }
2759 function m(n) {
2760 if (n._umark)
2761 return !0;
2762 n._umark=!0;
2763 for (var t, e = 0, r = n._c; e < r;)
2764 if (t = n[e++], t._onRejected || m(t))
2765 return !0
2766 }
2767 function j(n, t) {
2768 function e(n) {
2769 return r.push(n.replace(/^\s+|\s+$/g, ""))
2770 }
2771 var r = [];
2772 return L && (t[N] && e(t[N]), function o(n) {
2773 n && K in n && (o(n._next), e(n[K] + ""), o(n._p))
2774 }(t)), (n && n.stack ? n.stack : n) + ("\n" + r.join("\n")).replace(en, "")
2775 }
2776 function g(n, t) {
2777 return n(t)
2778 }
2779 function x(n, t, e) {
2780 var r = 0, o = n._c;
2781 if (n._s === $)
2782 for (n._s = t, n._v = e, t === U && (L && u(e) && (e.longStack = j(e, n)), un(n)); r < o;)
2783 on(n, n[r++]);
2784 return n
2785 }
2786 function k(n, t) {
2787 if (t === n && t)
2788 return x(n, U, h(W)), n;
2789 if (t !== C && (o(t) || r(t))) {
2790 var e = s(b)(t);
2791 if (e === nn)
2792 return x(n, U, e.e), n;
2793 o(e) ? (L && p(t) && (n._next = t), p(t) ? T(n, t, e) : rn.nextTick(function() {
2794 T(n, t, e)
2795 })) : x(n, Y, t)
2796 } else
2797 x(n, Y, t);
2798 return n
2799 }
2800 function b(n) {
2801 return n.then
2802 }
2803 function T(n, t, e) {
2804 var r = s(e, t)(function(e) {
2805 t && (t = C, k(n, e))
2806 }, function(e) {
2807 t && (t = C, x(n, U, e))
2808 });
2809 r === nn && t && (x(n, U, r.e), t = C)
2810 }
2811 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 = {
2812 e: C
2813 }, tn = function() {}, en = /^.+\/node_modules\/yaku\/.+\n?/gm, rn = function(n) {
2814 var t, e = this;
2815 if (!r(e) || e._s !== P)
2816 throw h("Invalid this");
2817 if (e._s = $, L && (e[K] = v()), n !== tn) {
2818 if (!o(n))
2819 throw h(Q);
2820 t = s(n)(w(e, Y), w(e, U)), t === nn && x(e, U, t.e)
2821 }
2822 };
2823 rn["default"] = rn, function(n, t) {
2824 for (var e in t)
2825 n[e] = t[e]
2826 }(rn.prototype, {
2827 then: function(n, t) {
2828 if (this._s === undefined)
2829 throw h();
2830 return y(this, d(rn.speciesConstructor(this, rn)), n, t)
2831 },
2832 "catch": function(n) {
2833 return this.then(P, n)
2834 },
2835 "finally": function(n) {
2836 return this.then(function(t) {
2837 return rn.resolve(n()).then(function() {
2838 return t
2839 })
2840 }, function(t) {
2841 return rn.resolve(n()).then(function() {
2842 throw t
2843 })
2844 })
2845 },
2846 _c: 0,
2847 _p: C
2848 }), rn.resolve = function(n) {
2849 return p(n) ? n : k(d(this), n)
2850 }, rn.reject = function(n) {
2851 return x(d(this), U, n)
2852 }, rn.race = function(n) {
2853 var t = this, e = d(t), r = function(n) {
2854 x(e, Y, n)
2855 }, o = function(n) {
2856 x(e, U, n)
2857 }, i = s(l)(n, function(n) {
2858 t.resolve(n).then(r, o)
2859 });
2860 return i === nn ? t.reject(i.e) : e
2861 }, rn.all = function(n) {
2862 function t(n) {
2863 x(o, U, n)
2864 }
2865 var e, r = this, o = d(r), i = [];
2866 return (e = s(l)(n, function(n, u) {
2867 r.resolve(n).then(function(n) {
2868 i[u] = n, --e || x(o, Y, i)
2869 }, t)
2870 })) === nn ? r.reject(e.e) : (e || x(o, Y, []), o)
2871 }, rn.Symbol = O[q] || {}, s(function() {
2872 Object.defineProperty(rn, e(), {
2873 get: function() {
2874 return this
2875 }
2876 })
2877 })(), rn.speciesConstructor = function(n, t) {
2878 var r = n.constructor;
2879 return r ? r[e()] || t : t
2880 }, rn.unhandledRejection = function(n, t) {
2881 I && I.error("Uncaught (in promise)", L ? t.longStack : j(n, t))
2882 }, rn.rejectionHandled = tn, rn.enableLongStackTrace = function() {
2883 L=!0
2884 }, rn.nextTick = F ? function(n) {
2885 E ? new E(function(n) {
2886 n()
2887 }).then(n) : setTimeout(n)
2888 } : H.nextTick, rn._s = 1;
2889 var on = a(999, function(n, t) {
2890 var e, r;
2891 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)
2892 }), un = a(9, function(n) {
2893 m(n) || (n[J] = 1, _(Z, n))
2894 });
2895 try {
2896 n.exports = rn
2897 } catch (cn) {
2898 O.Yaku = rn
2899 }
2900 }()
2901 }).call(t, e( /*! ./../~/webpack/buildin/global.js */
2902 2))
2903 }
2904 });
2905 // String.prototype.codePointAt
2906 /* global CreateMethodProperty, RequireObjectCoercible, ToInteger, ToString, UTF16Decode */
2907 // 21.1.3.3. String.prototype.codePointAt ( pos )
2908 CreateMethodProperty(String.prototype, 'codePointAt', function codePointAt(pos) {
2909 // 1. Let O be ? RequireObjectCoercible(this value).
2910 var O = RequireObjectCoercible(this);
2911 // 2. Let S be ? ToString(O).
2912 var S = ToString(O);
2913 // 3. Let position be ? ToInteger(pos).
2914 var position = ToInteger(pos);
2915 // 4. Let size be the length of S.
2916 var size = S.length;
2917 // 5. If position < 0 or position ≥ size, return undefined.
2918 if (position < 0 || position >= size) {
2919 return undefined;
2920 }
2921 // 6. Let first be the numeric value of the code unit at index position within the String S.
2922 var first = String.prototype.charCodeAt.call(S, position);
2923 // 7. If first < 0xD800 or first > 0xDBFF or position+1 = size, return first.
2924 if (first < 0xD800 || first > 0xDBFF || position + 1 === size) {
2925 return first;
2926 }
2927 // 8. Let second be the numeric value of the code unit at index position+1 within the String S.
2928 var second = String.prototype.charCodeAt.call(S, position + 1);
2929 // 9. If second < 0xDC00 or second > 0xDFFF, return first.
2930 if (second < 0xDC00 || second > 0xDFFF) {
2931 return first;
2932 }
2933 // 10. Return UTF16Decode(first, second).
2934 // 21.1.3.3.10 Return UTF16Decode(first, second).
2935 return UTF16Decode(first, second);
2936 });
2937
2938 // String.prototype.endsWith
2939 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
2940 // 21.1.3.6. String.prototype.endsWith ( searchString [ , endPosition ] )
2941 CreateMethodProperty(String.prototype, 'endsWith', function endsWith(searchString /* [ , endPosition ] */
2942 ) {
2943 'use strict';
2944 var endPosition = arguments.length > 1 ? arguments[1] : undefined;
2945 // 1. Let O be ? RequireObjectCoercible(this value).
2946 var O = RequireObjectCoercible(this);
2947 // 2. Let S be ? ToString(O).
2948 var S = ToString(O);
2949 // 3. Let isRegExp be ? IsRegExp(searchString).
2950 var isRegExp = IsRegExp(searchString);
2951 // 4. If isRegExp is true, throw a TypeError exception.
2952 if (isRegExp) {
2953 throw new TypeError('First argument to String.prototype.endsWith must not be a regular expression');
2954 }
2955 // 5. Let searchStr be ? ToString(searchString).
2956 var searchStr = ToString(searchString);
2957 // 6. Let len be the length of S.
2958 var len = S.length;
2959 // 7. If endPosition is undefined, let pos be len, else let pos be ? ToInteger(endPosition).
2960 var pos = endPosition === undefined ? len : ToInteger(endPosition);
2961 // 8. Let end be min(max(pos, 0), len).
2962 var end = Math.min(Math.max(pos, 0), len);
2963 // 9. Let searchLength be the length of searchStr.
2964 var searchLength = searchStr.length;
2965 // 10. Let start be end - searchLength.
2966 var start = end - searchLength;
2967 // 11. If start is less than 0, return false.
2968 if (start < 0) {
2969 return false;
2970 }
2971 // 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.
2972 if (S.substr(start, searchLength) === searchStr) {
2973 return true;
2974 }
2975 // 13. Otherwise, return false.
2976 return false;
2977 });
2978
2979 // String.prototype.includes
2980 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
2981 // 21.1.3.7. String.prototype.includes ( searchString [ , position ] )
2982 CreateMethodProperty(String.prototype, 'includes', function includes(searchString /* [ , position ] */
2983 ) {
2984 'use strict';
2985 var position = arguments.length > 1 ? arguments[1] : undefined;
2986 // 1. Let O be ? RequireObjectCoercible(this value).
2987 var O = RequireObjectCoercible(this);
2988 // 2. Let S be ? ToString(O).
2989 var S = ToString(O);
2990 // 3. Let isRegExp be ? IsRegExp(searchString).
2991 var isRegExp = IsRegExp(searchString);
2992 // 4. If isRegExp is true, throw a TypeError exception.
2993 if (isRegExp) {
2994 throw new TypeError('First argument to String.prototype.includes must not be a regular expression');
2995 }
2996 // 5. Let searchStr be ? ToString(searchString).
2997 var searchStr = ToString(searchString);
2998 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
2999 var pos = ToInteger(position);
3000 // 7. Let len be the length of S.
3001 var len = S.length;
3002 // 8. Let start be min(max(pos, 0), len).
3003 var start = Math.min(Math.max(pos, 0), len);
3004 // 9. Let searchLen be the length of searchStr.
3005 // var searchLength = searchStr.length;
3006 // 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.
3007 return String.prototype.indexOf.call(S, searchStr, start) !== - 1;
3008 });
3009
3010 // String.prototype.padEnd
3011 /* global CreateMethodProperty, RequireObjectCoercible, ToLength, ToString */
3012 // 21.1.3.13. String.prototype.padEnd( maxLength [ , fillString ] )
3013 CreateMethodProperty(String.prototype, 'padEnd', function padEnd(maxLength /* [ , fillString ] */
3014 ) {
3015 'use strict';
3016 var fillString = arguments.length > 1 ? arguments[1] : undefined;
3017 // 1. Let O be ? RequireObjectCoercible(this value).
3018 var O = RequireObjectCoercible(this);
3019 // 2. Let S be ? ToString(O).
3020 var S = ToString(O);
3021 // 3. Let intMaxLength be ? ToLength(maxLength).
3022 var intMaxLength = ToLength(maxLength);
3023 // 4. Let stringLength be the length of S.
3024 var stringLength = S.length;
3025 // 5. If intMaxLength is not greater than stringLength, return S.
3026 if (intMaxLength <= stringLength) {
3027 return S;
3028 }
3029 // 6. If fillString is undefined, let filler be the String value consisting solely of the code unit 0x0020 (SPACE).
3030 if (fillString === undefined) {
3031 var filler = ' ';
3032 // 7. Else, let filler be ? ToString(fillString).
3033 } else {
3034 var filler = ToString(fillString);
3035 }
3036 // 8. If filler is the empty String, return S.
3037 if (filler === '') {
3038 return S;
3039 }
3040 // 9. Let fillLen be intMaxLength - stringLength.
3041 var fillLen = intMaxLength - stringLength;
3042 // 10. Let truncatedStringFiller be the String value consisting of repeated concatenations of filler truncated to length fillLen.
3043 var truncatedStringFiller = '';
3044 for (var i = 0; i < fillLen; i++) {
3045 truncatedStringFiller += filler;
3046 }
3047 truncatedStringFiller = truncatedStringFiller.substr(0, fillLen);
3048 // 11. Return the string-concatenation of S and truncatedStringFiller.
3049 return S + truncatedStringFiller;
3050 });
3051
3052 // String.prototype.padStart
3053 /* global CreateMethodProperty, RequireObjectCoercible, ToLength, ToString */
3054 // 21.1.3.14. String.prototype.padStart( maxLength [ , fillString ] )
3055 CreateMethodProperty(String.prototype, 'padStart', function padStart(maxLength /* [ , fillString ] */
3056 ) {
3057 'use strict';
3058 var fillString = arguments.length > 1 ? arguments[1] : undefined;
3059 // 1. Let O be ? RequireObjectCoercible(this value).
3060 var O = RequireObjectCoercible(this);
3061 // 2. Let S be ? ToString(O).
3062 var S = ToString(O);
3063 // 3. Let intMaxLength be ? ToLength(maxLength).
3064 var intMaxLength = ToLength(maxLength);
3065 // 4. Let stringLength be the length of S.
3066 var stringLength = S.length;
3067 // 5. If intMaxLength is not greater than stringLength, return S.
3068 if (intMaxLength <= stringLength) {
3069 return S;
3070 }
3071 // 6. If fillString is undefined, let filler be the String value consisting solely of the code unit 0x0020 (SPACE).
3072 if (fillString === undefined) {
3073 var filler = ' ';
3074 // 7. Else, let filler be ? ToString(fillString).
3075 } else {
3076 var filler = ToString(fillString);
3077 }
3078 // 8. If filler is the empty String, return S.
3079 if (filler === '') {
3080 return S;
3081 }
3082 // 9. Let fillLen be intMaxLength - stringLength.
3083 var fillLen = intMaxLength - stringLength;
3084 // 10. Let truncatedStringFiller be the String value consisting of repeated concatenations of filler truncated to length fillLen.
3085 var truncatedStringFiller = '';
3086 for (var i = 0; i < fillLen; i++) {
3087 truncatedStringFiller += filler;
3088 }
3089 truncatedStringFiller = truncatedStringFiller.substr(0, fillLen);
3090 // 11. Return the string-concatenation of truncatedStringFiller and S.
3091 return truncatedStringFiller + S;
3092 });
3093
3094 // String.prototype.repeat
3095 /* global CreateMethodProperty, RequireObjectCoercible, ToInteger, ToString */
3096 // 21.1.3.15String.prototype.repeat ( count )
3097 CreateMethodProperty(String.prototype, 'repeat', function repeat(count) {
3098 'use strict';
3099 // 1. Let O be ? RequireObjectCoercible(this value).
3100 var O = RequireObjectCoercible(this);
3101 // 2. Let S be ? ToString(O).
3102 var S = ToString(O);
3103 // 3. Let n be ? ToInteger(count).
3104 var n = ToInteger(count);
3105 // 4. If n < 0, throw a RangeError exception.
3106 if (n < 0) {
3107 throw new RangeError('Invalid count value');
3108 }
3109 // 5. If n is +∞, throw a RangeError exception.
3110 if (n === Infinity) {
3111 throw new RangeError('Invalid count value');
3112 }
3113 // 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.
3114 var T = n === 0 ? '' : new Array(n + 1).join(S);
3115 // 7. Return T.
3116 return T;
3117 });
3118
3119 // String.prototype.startsWith
3120 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
3121 // 21.1.3.20. String.prototype.startsWith ( searchString [ , position ] )
3122 CreateMethodProperty(String.prototype, 'startsWith', function startsWith(searchString /* [ , position ] */
3123 ) {
3124 'use strict';
3125 var position = arguments.length > 1 ? arguments[1] : undefined;
3126 // 1. Let O be ? RequireObjectCoercible(this value).
3127 var O = RequireObjectCoercible(this);
3128 // 2. Let S be ? ToString(O).
3129 var S = ToString(O);
3130 // 3. Let isRegExp be ? IsRegExp(searchString).
3131 var isRegExp = IsRegExp(searchString);
3132 // 4. If isRegExp is true, throw a TypeError exception.
3133 if (isRegExp) {
3134 throw new TypeError('First argument to String.prototype.startsWith must not be a regular expression');
3135 }
3136 // 5. Let searchStr be ? ToString(searchString).
3137 var searchStr = ToString(searchString);
3138 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
3139 var pos = ToInteger(position);
3140 // 7. Let len be the length of S.
3141 var len = S.length;
3142 // 8. Let start be min(max(pos, 0), len).
3143 var start = Math.min(Math.max(pos, 0), len);
3144 // 9. Let searchLength be the length of searchStr.
3145 var searchLength = searchStr.length;
3146 // 10. If searchLength+start is greater than len, return false.
3147 if (searchLength + start > len) {
3148 return false;
3149 }
3150 // 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.
3151 if (S.substr(start).indexOf(searchString) === 0) {
3152 return true;
3153 }
3154 // 12. Otherwise, return false.
3155 return false;
3156 });
3157
3158 // Symbol
3159 // A modification of https://github.com/WebReflection/get-own-property-symbols
3160 // (C) Andrea Giammarchi - MIT Licensed
3161
3162 (function (Object, GOPS, global) {
3163 'use strict'; //so that ({}).toString.call(null) returns the correct [object Null] rather than [object Window]
3164
3165 var setDescriptor;
3166 var id = 0;
3167 var random = '' + Math.random();
3168 var prefix = '__\x01symbol:';
3169 var prefixLength = prefix.length;
3170 var internalSymbol = '__\x01symbol@@' + random;
3171 var DP = 'defineProperty';
3172 var DPies = 'defineProperties';
3173 var GOPN = 'getOwnPropertyNames';
3174 var GOPD = 'getOwnPropertyDescriptor';
3175 var PIE = 'propertyIsEnumerable';
3176 var ObjectProto = Object.prototype;
3177 var hOP = ObjectProto.hasOwnProperty;
3178 var pIE = ObjectProto[PIE];
3179 var toString = ObjectProto.toString;
3180 var concat = Array.prototype.concat;
3181 var cachedWindowNames = Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
3182 var nGOPN = Object[GOPN];
3183 var gOPN = function getOwnPropertyNames (obj) {
3184 if (toString.call(obj) === '[object Window]') {
3185 try {
3186 return nGOPN(obj);
3187 } catch (e) {
3188 // IE bug where layout engine calls userland gOPN for cross-domain `window` objects
3189 return concat.call([], cachedWindowNames);
3190 }
3191 }
3192 return nGOPN(obj);
3193 };
3194 var gOPD = Object[GOPD];
3195 var create = Object.create;
3196 var keys = Object.keys;
3197 var freeze = Object.freeze || Object;
3198 var defineProperty = Object[DP];
3199 var $defineProperties = Object[DPies];
3200 var descriptor = gOPD(Object, GOPN);
3201 var addInternalIfNeeded = function (o, uid, enumerable) {
3202 if (!hOP.call(o, internalSymbol)) {
3203 try {
3204 defineProperty(o, internalSymbol, {
3205 enumerable: false,
3206 configurable: false,
3207 writable: false,
3208 value: {}
3209 });
3210 } catch (e) {
3211 o[internalSymbol] = {};
3212 }
3213 }
3214 o[internalSymbol]['@@' + uid] = enumerable;
3215 };
3216 var createWithSymbols = function (proto, descriptors) {
3217 var self = create(proto);
3218 gOPN(descriptors).forEach(function (key) {
3219 if (propertyIsEnumerable.call(descriptors, key)) {
3220 $defineProperty(self, key, descriptors[key]);
3221 }
3222 });
3223 return self;
3224 };
3225 var copyAsNonEnumerable = function (descriptor) {
3226 var newDescriptor = create(descriptor);
3227 newDescriptor.enumerable = false;
3228 return newDescriptor;
3229 };
3230 var get = function get() {};
3231 var onlyNonSymbols = function (name) {
3232 return name != internalSymbol &&
3233 !hOP.call(source, name);
3234 };
3235 var onlySymbols = function (name) {
3236 return name != internalSymbol &&
3237 hOP.call(source, name);
3238 };
3239 var propertyIsEnumerable = function propertyIsEnumerable(key) {
3240 var uid = '' + key;
3241 return onlySymbols(uid) ? (
3242 hOP.call(this, uid) &&
3243 this[internalSymbol]['@@' + uid]
3244 ) : pIE.call(this, key);
3245 };
3246 var setAndGetSymbol = function (uid) {
3247 var descriptor = {
3248 enumerable: false,
3249 configurable: true,
3250 get: get,
3251 set: function (value) {
3252 setDescriptor(this, uid, {
3253 enumerable: false,
3254 configurable: true,
3255 writable: true,
3256 value: value
3257 });
3258 addInternalIfNeeded(this, uid, true);
3259 }
3260 };
3261 try {
3262 defineProperty(ObjectProto, uid, descriptor);
3263 } catch (e) {
3264 ObjectProto[uid] = descriptor.value;
3265 }
3266 return freeze(source[uid] = defineProperty(
3267 Object(uid),
3268 'constructor',
3269 sourceConstructor
3270 ));
3271 };
3272 var Symbol = function Symbol() {
3273 var description = arguments[0];
3274 if (this instanceof Symbol) {
3275 throw new TypeError('Symbol is not a constructor');
3276 }
3277 return setAndGetSymbol(
3278 prefix.concat(description || '', random, ++id)
3279 );
3280 };
3281 var source = create(null);
3282 var sourceConstructor = {
3283 value: Symbol
3284 };
3285 var sourceMap = function (uid) {
3286 return source[uid];
3287 };
3288 var $defineProperty = function defineProp(o, key, descriptor) {
3289 var uid = '' + key;
3290 if (onlySymbols(uid)) {
3291 setDescriptor(o, uid, descriptor.enumerable ?
3292 copyAsNonEnumerable(descriptor) : descriptor);
3293 addInternalIfNeeded(o, uid, !!descriptor.enumerable);
3294 } else {
3295 defineProperty(o, key, descriptor);
3296 }
3297 return o;
3298 };
3299
3300 var onlyInternalSymbols = function (obj) {
3301 return function (name) {
3302 return hOP.call(obj, internalSymbol) && hOP.call(obj[internalSymbol], '@@' + name);
3303 };
3304 };
3305 var $getOwnPropertySymbols = function getOwnPropertySymbols(o) {
3306 return gOPN(o).filter(o === ObjectProto ? onlyInternalSymbols(o) : onlySymbols).map(sourceMap);
3307 };
3308
3309 descriptor.value = $defineProperty;
3310 defineProperty(Object, DP, descriptor);
3311
3312 descriptor.value = $getOwnPropertySymbols;
3313 defineProperty(Object, GOPS, descriptor);
3314
3315 descriptor.value = function getOwnPropertyNames(o) {
3316 return gOPN(o).filter(onlyNonSymbols);
3317 };
3318 defineProperty(Object, GOPN, descriptor);
3319
3320 descriptor.value = function defineProperties(o, descriptors) {
3321 var symbols = $getOwnPropertySymbols(descriptors);
3322 if (symbols.length) {
3323 keys(descriptors).concat(symbols).forEach(function (uid) {
3324 if (propertyIsEnumerable.call(descriptors, uid)) {
3325 $defineProperty(o, uid, descriptors[uid]);
3326 }
3327 });
3328 } else {
3329 $defineProperties(o, descriptors);
3330 }
3331 return o;
3332 };
3333 defineProperty(Object, DPies, descriptor);
3334
3335 descriptor.value = propertyIsEnumerable;
3336 defineProperty(ObjectProto, PIE, descriptor);
3337
3338 descriptor.value = Symbol;
3339 defineProperty(global, 'Symbol', descriptor);
3340
3341 // defining `Symbol.for(key)`
3342 descriptor.value = function (key) {
3343 var uid = prefix.concat(prefix, key, random);
3344 return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid);
3345 };
3346 defineProperty(Symbol, 'for', descriptor);
3347
3348 // defining `Symbol.keyFor(symbol)`
3349 descriptor.value = function (symbol) {
3350 if (onlyNonSymbols(symbol))
3351 throw new TypeError(symbol + ' is not a symbol');
3352 return hOP.call(source, symbol) ?
3353 symbol.slice(prefixLength * 2, - random.length) :
3354 void 0
3355 ;
3356 };
3357 defineProperty(Symbol, 'keyFor', descriptor);
3358
3359 descriptor.value = function getOwnPropertyDescriptor(o, key) {
3360 var descriptor = gOPD(o, key);
3361 if (descriptor && onlySymbols(key)) {
3362 descriptor.enumerable = propertyIsEnumerable.call(o, key);
3363 }
3364 return descriptor;
3365 };
3366 defineProperty(Object, GOPD, descriptor);
3367
3368 descriptor.value = function (proto, descriptors) {
3369 return arguments.length === 1 || typeof descriptors === "undefined" ?
3370 create(proto) :
3371 createWithSymbols(proto, descriptors);
3372 };
3373 defineProperty(Object, 'create', descriptor);
3374
3375 var strictModeSupported = (function() {
3376 'use strict';
3377 return this;
3378 }).call(null) === null;
3379 if (strictModeSupported) {
3380 descriptor.value = function () {
3381 var str = toString.call(this);
3382 return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
3383 };
3384 } else {
3385 descriptor.value = function () {
3386 // https://github.com/Financial-Times/polyfill-library/issues/164#issuecomment-486965300
3387 // Polyfill.io this code is here for the situation where a browser does not
3388 // support strict mode and is executing `Object.prototype.toString.call(null)`.
3389 // This code ensures that we return the correct result in that situation however,
3390 // this code also introduces a bug where it will return the incorrect result for
3391 // `Object.prototype.toString.call(window)`. We can't have the correct result for
3392 // both `window` and `null`, so we have opted for `null` as we believe this is the more
3393 // common situation.
3394 if (this === window) {
3395 return '[object Null]';
3396 }
3397
3398 var str = toString.call(this);
3399 return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
3400 };
3401 }
3402 defineProperty(ObjectProto, 'toString', descriptor);
3403
3404 setDescriptor = function (o, key, descriptor) {
3405 var protoDescriptor = gOPD(ObjectProto, key);
3406 delete ObjectProto[key];
3407 defineProperty(o, key, descriptor);
3408 if (o !== ObjectProto) {
3409 defineProperty(ObjectProto, key, protoDescriptor);
3410 }
3411 };
3412
3413 }(Object, 'getOwnPropertySymbols', this));
3414
3415 // Symbol.hasInstance
3416 /* global Symbol */
3417 Object.defineProperty(Symbol, 'hasInstance', {
3418 value: Symbol('hasInstance')
3419 });
3420
3421 // Symbol.isConcatSpreadable
3422 /* global Symbol */
3423 Object.defineProperty(Symbol, 'isConcatSpreadable', {
3424 value: Symbol('isConcatSpreadable')
3425 });
3426
3427 // Symbol.iterator
3428 /* global Symbol */
3429 Object.defineProperty(Symbol, 'iterator', {
3430 value: Symbol('iterator')
3431 });
3432
3433 // _ESAbstract.GetIterator
3434 /* global GetMethod, Symbol, Call, Type, GetV */
3435 // 7.4.1. GetIterator ( obj [ , method ] )
3436 // The abstract operation GetIterator with argument obj and optional argument method performs the following steps:
3437 function GetIterator(obj /*, method */
3438 ) {
3439 // eslint-disable-line no-unused-vars
3440 // 1. If method is not present, then
3441 // a. Set method to ? GetMethod(obj, @@iterator).
3442 var method = arguments.length > 1 ? arguments[1] : GetMethod(obj, Symbol.iterator);
3443 // 2. Let iterator be ? Call(method, obj).
3444 var iterator = Call(method, obj);
3445 // 3. If Type(iterator) is not Object, throw a TypeError exception.
3446 if (Type(iterator) !== 'object') {
3447 throw new TypeError('bad iterator');
3448 }
3449 // 4. Let nextMethod be ? GetV(iterator, "next").
3450 var nextMethod = GetV(iterator, "next");
3451 // 5. Let iteratorRecord be Record {[[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false}.
3452 var iteratorRecord = Object.create(null);
3453 iteratorRecord['[[Iterator]]'] = iterator;
3454 iteratorRecord['[[NextMethod]]'] = nextMethod;
3455 iteratorRecord['[[Done]]'] = false;
3456 // 6. Return iteratorRecord.
3457 return iteratorRecord;
3458 }
3459
3460 // Symbol.match
3461 /* global Symbol */
3462 Object.defineProperty(Symbol, 'match', {
3463 value: Symbol('match')
3464 });
3465
3466 // Symbol.replace
3467 /* global Symbol */
3468 Object.defineProperty(Symbol, 'replace', {
3469 value: Symbol('replace')
3470 });
3471
3472 // Symbol.search
3473 /* global Symbol */
3474 Object.defineProperty(Symbol, 'search', {
3475 value: Symbol('search')
3476 });
3477
3478 // Symbol.species
3479 /* global Symbol */
3480 Object.defineProperty(Symbol, 'species', {
3481 value: Symbol('species')
3482 });
3483
3484 // Map
3485 /* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
3486 (function (global) {
3487 var supportsGetters = (function () {
3488 try {
3489 var a = {};
3490 Object.defineProperty(a, 't', {
3491 configurable: true,
3492 enumerable: false,
3493 get: function () {
3494 return true;
3495 },
3496 set: undefined
3497 });
3498 return !!a.t;
3499 } catch (e) {
3500 return false;
3501 }
3502 }());
3503
3504 // 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.
3505 var undefMarker = Symbol('undef');
3506 // 23.1.1.1 Map ( [ iterable ] )
3507 var Map = function Map( /* iterable */
3508 ) {
3509 // 1. If NewTarget is undefined, throw a TypeError exception.
3510 if (!(this instanceof Map)) {
3511 throw new TypeError('Constructor Map requires "new"');
3512 }
3513 // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%MapPrototype%", « [[MapData]] »).
3514 var map = OrdinaryCreateFromConstructor(this, Map.prototype, {
3515 _keys: [],
3516 _values: [],
3517 _size: 0,
3518 _es6Map: true
3519 });
3520
3521 // 3. Set map.[[MapData]] to a new empty List.
3522 // Polyfill.io - This step was done as part of step two.
3523
3524 // 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.
3525 if (!supportsGetters) {
3526 Object.defineProperty(map, 'size', {
3527 configurable: true,
3528 enumerable: false,
3529 writable: true,
3530 value: 0
3531 });
3532 }
3533
3534 // 4. If iterable is not present, let iterable be undefined.
3535 var iterable = arguments.length > 0 ? arguments[0] : undefined;
3536
3537 // 5. If iterable is either undefined or null, return map.
3538 if (iterable === null || iterable === undefined) {
3539 return map;
3540 }
3541
3542 // 6. Let adder be ? Get(map, "set").
3543 var adder = map.set;
3544
3545 // 7. If IsCallable(adder) is false, throw a TypeError exception.
3546 if (!IsCallable(adder)) {
3547 throw new TypeError("Map.prototype.set is not a function");
3548 }
3549
3550 // 8. Let iteratorRecord be ? GetIterator(iterable).
3551 try {
3552 var iteratorRecord = GetIterator(iterable);
3553 // 9. Repeat,
3554 while (true) {
3555 // a. Let next be ? IteratorStep(iteratorRecord).
3556 var next = IteratorStep(iteratorRecord);
3557 // b. If next is false, return map.
3558 if (next === false) {
3559 return map;
3560 }
3561 // c. Let nextItem be ? IteratorValue(next).
3562 var nextItem = IteratorValue(next);
3563 // d. If Type(nextItem) is not Object, then
3564 if (Type(nextItem) !== 'object') {
3565 // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
3566 try {
3567 throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
3568 } catch (error) {
3569 // ii. Return ? IteratorClose(iteratorRecord, error).
3570 return IteratorClose(iteratorRecord, error);
3571 }
3572 }
3573 try {
3574 // Polyfill.io - The try catch accounts for steps: f, h, and j.
3575
3576 // e. Let k be Get(nextItem, "0").
3577 var k = nextItem[0];
3578 // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
3579 // g. Let v be Get(nextItem, "1").
3580 var v = nextItem[1];
3581 // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
3582 // i. Let status be Call(adder, map, « k.[[Value]], v.[[Value]] »).
3583 adder.call(map, k, v);
3584 } catch (e) {
3585 // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
3586 return IteratorClose(iteratorRecord, e);
3587 }
3588 }
3589 } catch (e) {
3590 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
3591 if (Array.isArray(iterable) ||
3592 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
3593 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
3594 (!!iterable.callee)) {
3595 var index;
3596 var length = iterable.length;
3597 for (index = 0; index < length; index++) {
3598 adder.call(map, iterable[index][0], iterable[index][1]);
3599 }
3600 }
3601 }
3602 return map;
3603 };
3604
3605 // 23.1.2.1. Map.prototype
3606 // The initial value of Map.prototype is the intrinsic object %MapPrototype%.
3607 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
3608 Object.defineProperty(Map, 'prototype', {
3609 configurable: false,
3610 enumerable: false,
3611 writable: false,
3612 value: {}
3613 });
3614
3615 // 23.1.2.2 get Map [ @@species ]
3616 if (supportsGetters) {
3617 Object.defineProperty(Map, Symbol.species, {
3618 configurable: true,
3619 enumerable: false,
3620 get: function () {
3621 // 1. Return the this value.
3622 return this;
3623 },
3624 set: undefined
3625 });
3626 } else {
3627 CreateMethodProperty(Map, Symbol.species, Map);
3628 }
3629
3630 // 23.1.3.1 Map.prototype.clear ( )
3631 CreateMethodProperty(Map.prototype, 'clear', function clear() {
3632 // 1. Let M be the this value.
3633 var M = this;
3634 // 2. If Type(M) is not Object, throw a TypeError exception.
3635 if (Type(M) !== 'object') {
3636 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
3637 }
3638 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
3639 if (M._es6Map !== true) {
3640 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
3641 }
3642 // 4. Let entries be the List that is M.[[MapData]].
3643 var entries = M._keys;
3644 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
3645 for (var i = 0; i < entries.length; i++) {
3646 // 5.a. Set p.[[Key]] to empty.
3647 M._keys[i] = undefMarker;
3648 // 5.b. Set p.[[Value]] to empty.
3649 M._values[i] = undefMarker;
3650 }
3651 this._size = 0;
3652 if (!supportsGetters) {
3653 this.size = this._size;
3654 }
3655 // 6. Return undefined.
3656 return undefined;
3657 });
3658
3659 // 23.1.3.2. Map.prototype.constructor
3660 CreateMethodProperty(Map.prototype, 'constructor', Map);
3661
3662 // 23.1.3.3. Map.prototype.delete ( key )
3663 CreateMethodProperty(Map.prototype, 'delete', function (key) {
3664 // 1. Let M be the this value.
3665 var M = this;
3666 // 2. If Type(M) is not Object, throw a TypeError exception.
3667 if (Type(M) !== 'object') {
3668 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
3669 }
3670 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
3671 if (M._es6Map !== true) {
3672 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
3673 }
3674 // 4. Let entries be the List that is M.[[MapData]].
3675 var entries = M._keys;
3676 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
3677 for (var i = 0; i < entries.length; i++) {
3678 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
3679 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
3680 // i. Set p.[[Key]] to empty.
3681 this._keys[i] = undefMarker;
3682 // ii. Set p.[[Value]] to empty.
3683 this._values[i] = undefMarker;
3684 this._size = --this._size;
3685 if (!supportsGetters) {
3686 this.size = this._size;
3687 }
3688 // iii. Return true.
3689 return true;
3690 }
3691 }
3692 // 6. Return false.
3693 return false;
3694 });
3695
3696 // 23.1.3.4. Map.prototype.entries ( )
3697 CreateMethodProperty(Map.prototype, 'entries', function entries () {
3698 // 1. Let M be the this value.
3699 var M = this;
3700 // 2. Return ? CreateMapIterator(M, "key+value").
3701 return CreateMapIterator(M, 'key+value');
3702 });
3703
3704 // 23.1.3.5. Map.prototype.forEach ( callbackfn [ , thisArg ] )
3705 CreateMethodProperty(Map.prototype, 'forEach', function (callbackFn) {
3706 // 1. Let M be the this value.
3707 var M = this;
3708 // 2. If Type(M) is not Object, throw a TypeError exception.
3709 if (Type(M) !== 'object') {
3710 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
3711 }
3712 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
3713 if (M._es6Map !== true) {
3714 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
3715 }
3716 // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
3717 if (!IsCallable(callbackFn)) {
3718 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
3719 }
3720 // 5. If thisArg is present, let T be thisArg; else let T be undefined.
3721 if (arguments[1]) {
3722 var T = arguments[1];
3723 }
3724 // 6. Let entries be the List that is M.[[MapData]].
3725 var entries = M._keys;
3726 // 7. For each Record {[[Key]], [[Value]]} e that is an element of entries, in original key insertion order, do
3727 for (var i = 0; i < entries.length; i++) {
3728 // a. If e.[[Key]] is not empty, then
3729 if (M._keys[i] !== undefMarker && M._values[i] !== undefMarker ) {
3730 // i. Perform ? Call(callbackfn, T, « e.[[Value]], e.[[Key]], M »).
3731 callbackFn.call(T, M._values[i], M._keys[i], M);
3732 }
3733 }
3734 // 8. Return undefined.
3735 return undefined;
3736 });
3737
3738 // 23.1.3.6. Map.prototype.get ( key )
3739 CreateMethodProperty(Map.prototype, 'get', function get(key) {
3740 // 1. Let M be the this value.
3741 var M = this;
3742 // 2. If Type(M) is not Object, throw a TypeError exception.
3743 if (Type(M) !== 'object') {
3744 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
3745 }
3746 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
3747 if (M._es6Map !== true) {
3748 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
3749 }
3750 // 4. Let entries be the List that is M.[[MapData]].
3751 var entries = M._keys;
3752 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
3753 for (var i = 0; i < entries.length; i++) {
3754 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return p.[[Value]].
3755 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
3756 return M._values[i];
3757 }
3758 }
3759 // 6. Return undefined.
3760 return undefined;
3761 });
3762
3763 // 23.1.3.7. Map.prototype.has ( key )
3764 CreateMethodProperty(Map.prototype, 'has', function has (key) {
3765 // 1. Let M be the this value.
3766 var M = this;
3767 // 2. If Type(M) is not Object, throw a TypeError exception.
3768 if (typeof M !== 'object') {
3769 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
3770 }
3771 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
3772 if (M._es6Map !== true) {
3773 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
3774 }
3775 // 4. Let entries be the List that is M.[[MapData]].
3776 var entries = M._keys;
3777 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
3778 for (var i = 0; i < entries.length; i++) {
3779 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return true.
3780 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
3781 return true;
3782 }
3783 }
3784 // 6. Return false.
3785 return false;
3786 });
3787
3788 // 23.1.3.8. Map.prototype.keys ( )
3789 CreateMethodProperty(Map.prototype, 'keys', function keys () {
3790 // 1. Let M be the this value.
3791 var M = this;
3792 // 2. Return ? CreateMapIterator(M, "key").
3793 return CreateMapIterator(M, "key");
3794 });
3795
3796 // 23.1.3.9. Map.prototype.set ( key, value )
3797 CreateMethodProperty(Map.prototype, 'set', function set(key, value) {
3798 // 1. Let M be the this value.
3799 var M = this;
3800 // 2. If Type(M) is not Object, throw a TypeError exception.
3801 if (Type(M) !== 'object') {
3802 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
3803 }
3804 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
3805 if (M._es6Map !== true) {
3806 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
3807 }
3808 // 4. Let entries be the List that is M.[[MapData]].
3809 var entries = M._keys;
3810 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
3811 for (var i = 0; i < entries.length; i++) {
3812 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
3813 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
3814 // i. Set p.[[Value]] to value.
3815 M._values[i] = value;
3816 // Return M.
3817 return M;
3818 }
3819 }
3820 // 6. If key is -0, let key be +0.
3821 if (key === - 0) {
3822 key = 0;
3823 }
3824 // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
3825 var p = {};
3826 p['[[Key]]'] = key;
3827 p['[[Value]]'] = value;
3828 // 8. Append p as the last element of entries.
3829 M._keys.push(p['[[Key]]']);
3830 M._values.push(p['[[Value]]']);
3831 ++M._size;
3832 if (!supportsGetters) {
3833 M.size = M._size;
3834 }
3835 // 9. Return M.
3836 return M;
3837 });
3838
3839 // 23.1.3.10. get Map.prototype.size
3840 if (supportsGetters) {
3841 Object.defineProperty(Map.prototype, 'size', {
3842 configurable: true,
3843 enumerable: false,
3844 get: function () {
3845 // 1. Let M be the this value.
3846 var M = this;
3847 // 2. If Type(M) is not Object, throw a TypeError exception.
3848 if (Type(M) !== 'object') {
3849 throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
3850 }
3851 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
3852 if (M._es6Map !== true) {
3853 throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
3854 }
3855 // 4. Let entries be the List that is M.[[MapData]].
3856 var entries = M._keys;
3857 // 5. Let count be 0.
3858 var count = 0;
3859 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
3860 for (var i = 0; i < entries.length; i++) {
3861 // a. If p.[[Key]] is not empty, set count to count+1.
3862 if (M._keys[i] !== undefMarker) {
3863 count = count + 1;
3864 }
3865 }
3866 // 7. Return count.
3867 return count;
3868 },
3869 set: undefined
3870 });
3871 }
3872
3873 // 23.1.3.11. Map.prototype.values ( )
3874 CreateMethodProperty(Map.prototype, 'values', function values () {
3875 // 1. Let M be the this value.
3876 var M = this;
3877 // 2. Return ? CreateMapIterator(M, "value").
3878 return CreateMapIterator(M, 'value');
3879 });
3880
3881 // 23.1.3.12. Map.prototype [ @@iterator ] ( )
3882 // The initial value of the @@iterator property is the same function object as the initial value of the entries property.
3883 CreateMethodProperty(Map.prototype, Symbol.iterator, Map.prototype.entries);
3884
3885 // 23.1.3.13. Map.prototype [ @@toStringTag ]
3886 // The initial value of the @@toStringTag property is the String value "Map".
3887 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
3888
3889 // 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.
3890 if (!('name' in Map)) {
3891 // 19.2.4.2 name
3892 Object.defineProperty(Map, 'name', {
3893 configurable: true,
3894 enumerable: false,
3895 writable: false,
3896 value: 'Map'
3897 });
3898 }
3899
3900 // 23.1.5.1. CreateMapIterator ( map, kind )
3901 function CreateMapIterator(map, kind) {
3902 // 1. If Type(map) is not Object, throw a TypeError exception.
3903 if (Type(map) !== 'object') {
3904 throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
3905 }
3906 // 2. If map does not have a [[MapData]] internal slot, throw a TypeError exception.
3907 if (map._es6Map !== true) {
3908 throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
3909 }
3910 // 3. Let iterator be ObjectCreate(%MapIteratorPrototype%, « [[Map]], [[MapNextIndex]], [[MapIterationKind]] »).
3911 var iterator = Object.create(MapIteratorPrototype);
3912 // 4. Set iterator.[[Map]] to map.
3913 Object.defineProperty(iterator, '[[Map]]', {
3914 configurable: true,
3915 enumerable: false,
3916 writable: true,
3917 value: map
3918 });
3919 // 5. Set iterator.[[MapNextIndex]] to 0.
3920 Object.defineProperty(iterator, '[[MapNextIndex]]', {
3921 configurable: true,
3922 enumerable: false,
3923 writable: true,
3924 value: 0
3925 });
3926 // 6. Set iterator.[[MapIterationKind]] to kind.
3927 Object.defineProperty(iterator, '[[MapIterationKind]]', {
3928 configurable: true,
3929 enumerable: false,
3930 writable: true,
3931 value: kind
3932 });
3933 // 7. Return iterator.
3934 return iterator;
3935 }
3936
3937 // 23.1.5.2. The %MapIteratorPrototype% Object
3938 var MapIteratorPrototype = {};
3939 // Polyfill.io - We use this as a quick way to check if an object is a Map Iterator instance.
3940 Object.defineProperty(MapIteratorPrototype, 'isMapIterator', {
3941 configurable: false,
3942 enumerable: false,
3943 writable: false,
3944 value: true
3945 });
3946
3947 // 23.1.5.2.1. %MapIteratorPrototype%.next ( )
3948 CreateMethodProperty(MapIteratorPrototype, 'next', function next() {
3949 // 1. Let O be the this value.
3950 var O = this;
3951 // 2. If Type(O) is not Object, throw a TypeError exception.
3952 if (Type(O) !== 'object') {
3953 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
3954 }
3955 // 3. If O does not have all of the internal slots of a Map Iterator Instance (23.1.5.3), throw a TypeError exception.
3956 if (!O.isMapIterator) {
3957 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
3958 }
3959 // 4. Let m be O.[[Map]].
3960 var m = O['[[Map]]'];
3961 // 5. Let index be O.[[MapNextIndex]].
3962 var index = O['[[MapNextIndex]]'];
3963 // 6. Let itemKind be O.[[MapIterationKind]].
3964 var itemKind = O['[[MapIterationKind]]'];
3965 // 7. If m is undefined, return CreateIterResultObject(undefined, true).
3966 if (m === undefined) {
3967 return CreateIterResultObject(undefined, true);
3968 }
3969 // 8. Assert: m has a [[MapData]] internal slot.
3970 if (!m._es6Map) {
3971 throw new Error(Object.prototype.toString.call(m) + ' has a [[MapData]] internal slot.');
3972 }
3973 // 9. Let entries be the List that is m.[[MapData]].
3974 var entries = m._keys;
3975 // 10. Let numEntries be the number of elements of entries.
3976 var numEntries = entries.length;
3977 // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
3978 // 12. Repeat, while index is less than numEntries,
3979 while (index < numEntries) {
3980 // a. Let e be the Record {[[Key]], [[Value]]} that is the value of entries[index].
3981 var e = Object.create(null);
3982 e['[[Key]]'] = m._keys[index];
3983 e['[[Value]]'] = m._values[index];
3984 // b. Set index to index+1.
3985 index = index + 1;
3986 // c. Set O.[[MapNextIndex]] to index.
3987 O['[[MapNextIndex]]'] = index;
3988 // d. If e.[[Key]] is not empty, then
3989 if (e['[[Key]]'] !== undefMarker) {
3990 // i. If itemKind is "key", let result be e.[[Key]].
3991 if (itemKind === 'key') {
3992 var result = e['[[Key]]'];
3993 // ii. Else if itemKind is "value", let result be e.[[Value]].
3994 } else if (itemKind === 'value') {
3995 result = e['[[Value]]'];
3996 // iii. Else,
3997 } else {
3998 // 1. Assert: itemKind is "key+value".
3999 if (itemKind !== 'key+value') {
4000 throw new Error();
4001 }
4002 // 2. Let result be CreateArrayFromList(« e.[[Key]], e.[[Value]] »).
4003 result = [
4004 e['[[Key]]'],
4005 e['[[Value]]']
4006 ];
4007 }
4008 // iv. Return CreateIterResultObject(result, false).
4009 return CreateIterResultObject(result, false);
4010 }
4011 }
4012 // 13. Set O.[[Map]] to undefined.
4013 O['[[Map]]'] = undefined;
4014 // 14. Return CreateIterResultObject(undefined, true).
4015 return CreateIterResultObject(undefined, true);
4016 });
4017
4018 // 23.1.5.2.2 %MapIteratorPrototype% [ @@toStringTag ]
4019 // The initial value of the @@toStringTag property is the String value "Map Iterator".
4020 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
4021
4022 CreateMethodProperty(MapIteratorPrototype, Symbol.iterator, function iterator() {
4023 return this;
4024 });
4025
4026 // Export the object
4027 try {
4028 CreateMethodProperty(global, 'Map', Map);
4029 } catch (e) {
4030 // IE8 throws an error here if we set enumerable to false.
4031 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
4032 global['Map'] = Map;
4033 }
4034 }(this));
4035
4036 // Set
4037 /* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Symbol */
4038 (function (global) {
4039 var supportsGetters = (function () {
4040 try {
4041 var a = {};
4042 Object.defineProperty(a, 't', {
4043 configurable: true,
4044 enumerable: false,
4045 get: function () {
4046 return true;
4047 },
4048 set: undefined
4049 });
4050 return !!a.t;
4051 } catch (e) {
4052 return false;
4053 }
4054 }());
4055
4056 // 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.
4057 var undefMarker = Symbol('undef');
4058 // 23.2.1.1. Set ( [ iterable ] )
4059 var Set = function Set( /* iterable */
4060 ) {
4061 // 1. If NewTarget is undefined, throw a TypeError exception.
4062 if (!(this instanceof Set)) {
4063 throw new TypeError('Constructor Set requires "new"');
4064 }
4065 // 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%SetPrototype%", « [[SetData]] »).
4066 var set = OrdinaryCreateFromConstructor(this, Set.prototype, {
4067 _values: [],
4068 _size: 0,
4069 _es6Set: true
4070 });
4071
4072 // 3. Set set.[[SetData]] to a new empty List.
4073 // Polyfill.io - This step was done as part of step two.
4074
4075 // 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.
4076 if (!supportsGetters) {
4077 Object.defineProperty(set, 'size', {
4078 configurable: true,
4079 enumerable: false,
4080 writable: true,
4081 value: 0
4082 });
4083 }
4084
4085 // 4. If iterable is not present, let iterable be undefined.
4086 var iterable = arguments.length > 0 ? arguments[0] : undefined;
4087
4088 // 5. If iterable is either undefined or null, return set.
4089 if (iterable === null || iterable === undefined) {
4090 return set;
4091 }
4092
4093 // 6. Let adder be ? Get(set, "add").
4094 var adder = set.add;
4095 // 7. If IsCallable(adder) is false, throw a TypeError exception.
4096 if (!IsCallable(adder)) {
4097 throw new TypeError("Set.prototype.add is not a function");
4098 }
4099
4100 try {
4101 // 8. Let iteratorRecord be ? GetIterator(iterable).
4102 var iteratorRecord = GetIterator(iterable);
4103 // 9. Repeat,
4104 while (true) {
4105 // a. Let next be ? IteratorStep(iteratorRecord).
4106 var next = IteratorStep(iteratorRecord);
4107 // b. If next is false, return set.
4108 if (next === false) {
4109 return set;
4110 }
4111 // c. Let nextValue be ? IteratorValue(next).
4112 var nextValue = IteratorValue(next);
4113 // d. Let status be Call(adder, set, « nextValue.[[Value]] »).
4114 try {
4115 adder.call(set, nextValue);
4116 } catch (e) {
4117 // e. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
4118 return IteratorClose(iteratorRecord, e);
4119 }
4120 }
4121 } catch (e) {
4122 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
4123 if (Array.isArray(iterable) ||
4124 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
4125 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
4126 (!!iterable.callee)) {
4127 var index;
4128 var length = iterable.length;
4129 for (index = 0; index < length; index++) {
4130 adder.call(set, iterable[index]);
4131 }
4132 } else {
4133 throw (e);
4134 }
4135 }
4136 return set;
4137 };
4138
4139 // 23.2.2.1. Set.prototype
4140 // The initial value of Set.prototype is the intrinsic %SetPrototype% object.
4141 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
4142 Object.defineProperty(Set, 'prototype', {
4143 configurable: false,
4144 enumerable: false,
4145 writable: false,
4146 value: {}
4147 });
4148
4149 // 23.2.2.2 get Set [ @@species ]
4150 if (supportsGetters) {
4151 Object.defineProperty(Set, Symbol.species, {
4152 configurable: true,
4153 enumerable: false,
4154 get: function () {
4155 // 1. Return the this value.
4156 return this;
4157 },
4158 set: undefined
4159 });
4160 } else {
4161 CreateMethodProperty(Set, Symbol.species, Set);
4162 }
4163
4164 // 23.2.3.1. Set.prototype.add ( value )
4165 CreateMethodProperty(Set.prototype, 'add', function add(value) {
4166 // 1. Let S be the this value.
4167 var S = this;
4168 // 2. If Type(S) is not Object, throw a TypeError exception.
4169 if (typeof S !== 'object') {
4170 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
4171 }
4172 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
4173 if (S._es6Set !== true) {
4174 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
4175 }
4176 // 4. Let entries be the List that is S.[[SetData]].
4177 var entries = S._values;
4178 // 5. For each e that is an element of entries, do
4179 for (var i = 0; i < entries.length; i++) {
4180 var e = entries[i];
4181 // a. If e is not empty and SameValueZero(e, value) is true, then
4182 if (e !== undefMarker && SameValueZero(e, value)) {
4183 // i. Return S.
4184 return S;
4185 }
4186 }
4187 // 6. If value is -0, let value be +0.
4188 if (1 / value === - Infinity) {
4189 value = 0;
4190 }
4191 // 7. Append value as the last element of entries.
4192 S._values.push(value);
4193
4194 this._size = ++this._size;
4195 if (!supportsGetters) {
4196 this.size = this._size;
4197 }
4198 // 8. Return S.
4199 return S;
4200 });
4201
4202 // 23.2.3.2. Set.prototype.clear ( )
4203 CreateMethodProperty(Set.prototype, 'clear', function clear() {
4204 // 1. Let S be the this value.
4205 var S = this;
4206 // 2. If Type(S) is not Object, throw a TypeError exception.
4207 if (typeof S !== 'object') {
4208 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
4209 }
4210 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
4211 if (S._es6Set !== true) {
4212 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
4213 }
4214 // 4. Let entries be the List that is S.[[SetData]].
4215 var entries = S._values;
4216 // 5. For each e that is an element of entries, do
4217 for (var i = 0; i < entries.length; i++) {
4218 // a. Replace the element of entries whose value is e with an element whose value is empty.
4219 entries[i] = undefMarker;
4220 }
4221 this._size = 0;
4222 if (!supportsGetters) {
4223 this.size = this._size;
4224 }
4225 // 6. Return undefined.
4226 return undefined;
4227 });
4228
4229 // 23.2.3.3. Set.prototype.constructor
4230 CreateMethodProperty(Set.prototype, 'constructor', Set);
4231
4232 // 23.2.3.4. Set.prototype.delete ( value )
4233 CreateMethodProperty(Set.prototype, 'delete', function (value) {
4234 // 1. Let S be the this value.
4235 var S = this;
4236 // 2. If Type(S) is not Object, throw a TypeError exception.
4237 if (typeof S !== 'object') {
4238 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
4239 }
4240 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
4241 if (S._es6Set !== true) {
4242 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
4243 }
4244 // 4. Let entries be the List that is S.[[SetData]].
4245 var entries = S._values;
4246 // 5. For each e that is an element of entries, do
4247 for (var i = 0; i < entries.length; i++) {
4248 var e = entries[i];
4249 // a. If e is not empty and SameValueZero(e, value) is true, then
4250 if (e !== undefMarker && SameValueZero(e, value)) {
4251 // i. Replace the element of entries whose value is e with an element whose value is empty.
4252 entries[i] = undefMarker;
4253
4254 this._size = --this._size;
4255 if (!supportsGetters) {
4256 this.size = this._size;
4257 }
4258 // ii. Return true.
4259 return true;
4260 }
4261 }
4262 // 6. Return false.
4263 return false;
4264 });
4265
4266 // 23.2.3.5. Set.prototype.entries ( )
4267 CreateMethodProperty(Set.prototype, 'entries', function entries() {
4268 // 1. Let S be the this value.
4269 var S = this;
4270 // 2. Return ? CreateSetIterator(S, "key+value").
4271 return CreateSetIterator(S, 'key+value');
4272 });
4273
4274 // 23.2.3.6. Set.prototype.forEach ( callbackfn [ , thisArg ] )
4275 CreateMethodProperty(Set.prototype, 'forEach', function forEach(callbackFn /*[ , thisArg ]*/
4276 ) {
4277 // 1. Let S be the this value.
4278 var S = this;
4279 // 2. If Type(S) is not Object, throw a TypeError exception.
4280 if (typeof S !== 'object') {
4281 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
4282 }
4283 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
4284 if (S._es6Set !== true) {
4285 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
4286 }
4287 // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
4288 if (!IsCallable(callbackFn)) {
4289 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
4290 }
4291 // 5. If thisArg is present, let T be thisArg; else let T be undefined.
4292 if (arguments[1]) {
4293 var T = arguments[1];
4294 }
4295 // 6. Let entries be the List that is S.[[SetData]].
4296 var entries = S._values;
4297 // 7. For each e that is an element of entries, in original insertion order, do
4298 for (var i = 0; i < entries.length; i++) {
4299 var e = entries[i];
4300 // a. If e is not empty, then
4301 if (e !== undefMarker) {
4302 // i. Perform ? Call(callbackfn, T, « e, e, S »).
4303 callbackFn.call(T, e, e, S);
4304 }
4305 }
4306 // 8. Return undefined.
4307 return undefined;
4308 });
4309
4310 // 23.2.3.7. Set.prototype.has ( value )
4311 CreateMethodProperty(Set.prototype, 'has', function has(value) {
4312 // 1. Let S be the this value.
4313 var S = this;
4314 // 2. If Type(S) is not Object, throw a TypeError exception.
4315 if (typeof S !== 'object') {
4316 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
4317 }
4318 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
4319 if (S._es6Set !== true) {
4320 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
4321 }
4322 // 4. Let entries be the List that is S.[[SetData]].
4323 var entries = S._values;
4324 // 5. For each e that is an element of entries, do
4325 for (var i = 0; i < entries.length; i++) {
4326 var e = entries[i];
4327 // a. If e is not empty and SameValueZero(e, value) is true, return true.
4328 if (e !== undefMarker && SameValueZero(e, value)) {
4329 return true;
4330 }
4331 }
4332 // 6. Return false.
4333 return false;
4334 });
4335
4336 // Polyfill.io - We need to define Set.prototype.values before Set.prototype.keys because keys is a reference to values.
4337 // 23.2.3.10. Set.prototype.values()
4338 var values = function values() {
4339 // 1. Let S be the this value.
4340 var S = this;
4341 // 2. Return ? CreateSetIterator(S, "value").
4342 return CreateSetIterator(S, "value");
4343 };
4344 CreateMethodProperty(Set.prototype, 'values', values);
4345
4346 // 23.2.3.8 Set.prototype.keys ( )
4347 // The initial value of the keys property is the same function object as the initial value of the values property.
4348 CreateMethodProperty(Set.prototype, 'keys', values);
4349
4350 // 23.2.3.9. get Set.prototype.size
4351 if (supportsGetters) {
4352 Object.defineProperty(Set.prototype, 'size', {
4353 configurable: true,
4354 enumerable: false,
4355 get: function () {
4356 // 1. Let S be the this value.
4357 var S = this;
4358 // 2. If Type(S) is not Object, throw a TypeError exception.
4359 if (typeof S !== 'object') {
4360 throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
4361 }
4362 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
4363 if (S._es6Set !== true) {
4364 throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
4365 }
4366 // 4. Let entries be the List that is S.[[SetData]].
4367 var entries = S._values;
4368 // 5. Let count be 0.
4369 var count = 0;
4370 // 6. For each e that is an element of entries, do
4371 for (var i = 0; i < entries.length; i++) {
4372 var e = entries[i];
4373 // a. If e is not empty, set count to count+1.
4374 if (e !== undefMarker) {
4375 count = count + 1;
4376 }
4377 }
4378 // 7. Return count.
4379 return count;
4380 },
4381 set: undefined
4382 });
4383 }
4384
4385 // 23.2.3.11. Set.prototype [ @@iterator ] ( )
4386 // The initial value of the @@iterator property is the same function object as the initial value of the values property.
4387 CreateMethodProperty(Set.prototype, Symbol.iterator, values);
4388
4389 // 23.2.3.12. Set.prototype [ @@toStringTag ]
4390 // The initial value of the @@toStringTag property is the String value "Set".
4391 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
4392
4393 // 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.
4394 if (!('name' in Set)) {
4395 // 19.2.4.2 name
4396 Object.defineProperty(Set, 'name', {
4397 configurable: true,
4398 enumerable: false,
4399 writable: false,
4400 value: 'Set'
4401 });
4402 }
4403
4404 // 23.2.5.1. CreateSetIterator ( set, kind )
4405 function CreateSetIterator(set, kind) {
4406 // 1. If Type(set) is not Object, throw a TypeError exception.
4407 if (typeof set !== 'object') {
4408 throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
4409 }
4410 // 2. If set does not have a [[SetData]] internal slot, throw a TypeError exception.
4411 if (set._es6Set !== true) {
4412 throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
4413 }
4414 // 3. Let iterator be ObjectCreate(%SetIteratorPrototype%, « [[IteratedSet]], [[SetNextIndex]], [[SetIterationKind]] »).
4415 var iterator = Object.create(SetIteratorPrototype);
4416 // 4. Set iterator.[[IteratedSet]] to set.
4417 Object.defineProperty(iterator, '[[IteratedSet]]', {
4418 configurable: true,
4419 enumerable: false,
4420 writable: true,
4421 value: set
4422 });
4423 // 5. Set iterator.[[SetNextIndex]] to 0.
4424 Object.defineProperty(iterator, '[[SetNextIndex]]', {
4425 configurable: true,
4426 enumerable: false,
4427 writable: true,
4428 value: 0
4429 });
4430 // 6. Set iterator.[[SetIterationKind]] to kind.
4431 Object.defineProperty(iterator, '[[SetIterationKind]]', {
4432 configurable: true,
4433 enumerable: false,
4434 writable: true,
4435 value: kind
4436 });
4437 // 7. Return iterator.
4438 return iterator;
4439 }
4440
4441 // 23.2.5.2. The %SetIteratorPrototype% Object
4442 var SetIteratorPrototype = {};
4443 //Polyfill.io - We add this property to help us identify what is a set iterator.
4444 Object.defineProperty(SetIteratorPrototype, 'isSetIterator', {
4445 configurable: false,
4446 enumerable: false,
4447 writable: false,
4448 value: true
4449 });
4450
4451 // 23.2.5.2.1. %SetIteratorPrototype%.next ( )
4452 CreateMethodProperty(SetIteratorPrototype, 'next', function next() {
4453 // 1. Let O be the this value.
4454 var O = this;
4455 // 2. If Type(O) is not Object, throw a TypeError exception.
4456 if (typeof O !== 'object') {
4457 throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
4458 }
4459 // 3. If O does not have all of the internal slots of a Set Iterator Instance (23.2.5.3), throw a TypeError exception.
4460 if (!O.isSetIterator) {
4461 throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
4462 }
4463 // 4. Let s be O.[[IteratedSet]].
4464 var s = O['[[IteratedSet]]'];
4465 // 5. Let index be O.[[SetNextIndex]].
4466 var index = O['[[SetNextIndex]]'];
4467 // 6. Let itemKind be O.[[SetIterationKind]].
4468 var itemKind = O['[[SetIterationKind]]'];
4469 // 7. If s is undefined, return CreateIterResultObject(undefined, true).
4470 if (s === undefined) {
4471 return CreateIterResultObject(undefined, true);
4472 }
4473 // 8. Assert: s has a [[SetData]] internal slot.
4474 if (!s._es6Set) {
4475 throw new Error(Object.prototype.toString.call(s) + ' does not have [[SetData]] internal slot.');
4476 }
4477 // 9. Let entries be the List that is s.[[SetData]].
4478 var entries = s._values;
4479 // 10. Let numEntries be the number of elements of entries.
4480 var numEntries = entries.length;
4481 // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
4482 // 12. Repeat, while index is less than numEntries,
4483 while (index < numEntries) {
4484 // a. Let e be entries[index].
4485 var e = entries[index];
4486 // b. Set index to index+1.
4487 index = index + 1;
4488 // c. Set O.[[SetNextIndex]] to index.
4489 O['[[SetNextIndex]]'] = index;
4490 // d. If e is not empty, then
4491 if (e !== undefMarker) {
4492 // i. If itemKind is "key+value", then
4493 if (itemKind === 'key+value') {
4494 // 1. Return CreateIterResultObject(CreateArrayFromList(« e, e »), false).
4495 return CreateIterResultObject([e, e], false);
4496 }
4497 // ii. Return CreateIterResultObject(e, false).
4498 return CreateIterResultObject(e, false);
4499 }
4500 }
4501 // 13. Set O.[[IteratedSet]] to undefined.
4502 O['[[IteratedSet]]'] = undefined;
4503 // 14. Return CreateIterResultObject(undefined, true).
4504 return CreateIterResultObject(undefined, true);
4505 });
4506
4507 // 23.2.5.2.2. %SetIteratorPrototype% [ @@toStringTag ]
4508 // The initial value of the @@toStringTag property is the String value "Set Iterator".
4509 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
4510
4511 CreateMethodProperty(SetIteratorPrototype, Symbol.iterator, function iterator() {
4512 return this;
4513 });
4514
4515 // Export the object
4516 try {
4517 CreateMethodProperty(global, 'Set', Set);
4518 } catch (e) {
4519 // IE8 throws an error here if we set enumerable to false.
4520 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
4521 global['Set'] = Set;
4522 }
4523
4524 }(this));
4525
4526 // Array.from
4527 /* globals
4528 IsCallable, GetMethod, Symbol, IsConstructor, Construct, ArrayCreate, GetIterator, IteratorClose,
4529 ToString, IteratorStep, IteratorValue, Call, CreateDataPropertyOrThrow, ToObject, ToLength, Get, CreateMethodProperty
4530 */
4531 (function () {
4532 var toString = Object.prototype.toString;
4533 var stringMatch = String.prototype.match;
4534 // A cross-realm friendly way to detect if a value is a String object or literal.
4535 function isString(value) {
4536 if (typeof value === 'string') {
4537 return true;
4538 }
4539 if (typeof value !== 'object') {
4540 return false;
4541 }
4542 return toString.call(value) === '[object String]';
4543 }
4544
4545 // 22.1.2.1. Array.from ( items [ , mapfn [ , thisArg ] ] )
4546 CreateMethodProperty(Array, 'from', function from(items /* [ , mapfn [ , thisArg ] ] */
4547 ) {
4548 // eslint-disable-line no-undef
4549 // 1. Let C be the this value.
4550 var C = this;
4551 // 2. If mapfn is undefined, let mapping be false.
4552 var mapfn = arguments.length > 1 ? arguments[1] : undefined;
4553 if (mapfn === undefined) {
4554 var mapping = false;
4555 // 3. Else,
4556 } else {
4557 // a. If IsCallable(mapfn) is false, throw a TypeError exception.
4558 if (IsCallable(mapfn) === false) {
4559 throw new TypeError(Object.prototype.toString.call(mapfn) + ' is not a function.');
4560 }
4561 // b. If thisArg is present, let T be thisArg; else let T be undefined.
4562 var thisArg = arguments.length > 2 ? arguments[2] : undefined;
4563 if (thisArg !== undefined) {
4564 var T = thisArg;
4565 } else {
4566 T = undefined;
4567 }
4568 // c. Let mapping be true.
4569 mapping = true;
4570
4571 }
4572 // 4. Let usingIterator be ? GetMethod(items, @@iterator).
4573 var usingIterator = GetMethod(items, Symbol.iterator);
4574 // 5. If usingIterator is not undefined, then
4575 if (usingIterator !== undefined) {
4576 // a. If IsConstructor(C) is true, then
4577 if (IsConstructor(C)) {
4578 // i. Let A be ? Construct(C).
4579 var A = Construct(C);
4580 // b. Else,
4581 } else {
4582 // i. Let A be ! ArrayCreate(0).
4583 A = ArrayCreate(0);
4584 }
4585 // c. Let iteratorRecord be ? GetIterator(items, usingIterator).
4586 var iteratorRecord = GetIterator(items, usingIterator);
4587 // d. Let k be 0.
4588 var k = 0;
4589 // e. Repeat,
4590 while (true) {
4591 // i. If k ≥ 2^53-1, then
4592 if (k >= (Math.pow(2, 53) - 1)) {
4593 // 1. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
4594 var error = new TypeError('Iteration count can not be greater than or equal 9007199254740991.');
4595 // 2. Return ? IteratorClose(iteratorRecord, error).
4596 return IteratorClose(iteratorRecord, error);
4597 }
4598 // ii. Let Pk be ! ToString(k).
4599 var Pk = ToString(k);
4600 // iii. Let next be ? IteratorStep(iteratorRecord).
4601 var next = IteratorStep(iteratorRecord);
4602 // iv. If next is false, then
4603 if (next === false) {
4604 // 1. Perform ? Set(A, "length", k, true).
4605 A["length"] = k;
4606 // 2. Return A.
4607 return A;
4608 }
4609 // v. Let nextValue be ? IteratorValue(next).
4610 var nextValue = IteratorValue(next);
4611 // vi. If mapping is true, then
4612 if (mapping) {
4613 try {
4614 // Polyfill.io - The try catch accounts for step 2.
4615 // 1. Let mappedValue be Call(mapfn, T, « nextValue, k »).
4616 var mappedValue = Call(mapfn, T, [nextValue, k]);
4617 // 2. If mappedValue is an abrupt completion, return ? IteratorClose(iteratorRecord, mappedValue).
4618 // 3. Let mappedValue be mappedValue.[[Value]].
4619 } catch (e) {
4620 return IteratorClose(iteratorRecord, e);
4621 }
4622
4623 // vii. Else, let mappedValue be nextValue.
4624 } else {
4625 mappedValue = nextValue;
4626 }
4627 try {
4628 // Polyfill.io - The try catch accounts for step ix.
4629 // viii. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, mappedValue).
4630 CreateDataPropertyOrThrow(A, Pk, mappedValue);
4631 // ix. If defineStatus is an abrupt completion, return ? IteratorClose(iteratorRecord, defineStatus).
4632 } catch (e) {
4633 return IteratorClose(iteratorRecord, e);
4634 }
4635 // x. Increase k by 1.
4636 k = k + 1;
4637 }
4638 }
4639 // 6. NOTE: items is not an Iterable so assume it is an array-like object.
4640 // 7. Let arrayLike be ! ToObject(items).
4641 // Polyfill.io - For Strings we need to split astral symbols into surrogate pairs.
4642 if (isString(items)) {
4643 var arrayLike = stringMatch.call(items, /[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g) || [];
4644 } else {
4645 arrayLike = ToObject(items);
4646 }
4647 // 8. Let len be ? ToLength(? Get(arrayLike, "length")).
4648 var len = ToLength(Get(arrayLike, "length"));
4649 // 9. If IsConstructor(C) is true, then
4650 if (IsConstructor(C)) {
4651 // a. Let A be ? Construct(C, « len »).
4652 A = Construct(C, [len]);
4653 // 10. Else,
4654 } else {
4655 // a. Let A be ? ArrayCreate(len).
4656 A = ArrayCreate(len);
4657 }
4658 // 11. Let k be 0.
4659 k = 0;
4660 // 12. Repeat, while k < len
4661 while (k < len) {
4662 // a. Let Pk be ! ToString(k).
4663 Pk = ToString(k);
4664 // b. Let kValue be ? Get(arrayLike, Pk).
4665 var kValue = Get(arrayLike, Pk);
4666 // c. If mapping is true, then
4667 if (mapping === true) {
4668 // i. Let mappedValue be ? Call(mapfn, T, « kValue, k »).
4669 mappedValue = Call(mapfn, T, [kValue, k]);
4670 // d. Else, let mappedValue be kValue.
4671 } else {
4672 mappedValue = kValue;
4673 }
4674 // e. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
4675 CreateDataPropertyOrThrow(A, Pk, mappedValue);
4676 // f. Increase k by 1.
4677 k = k + 1;
4678 }
4679 // 13. Perform ? Set(A, "length", len, true).
4680 A["length"] = len;
4681 // 14. Return A.
4682 return A;
4683 });
4684 }());
4685
4686 // Symbol.split
4687 /* global Symbol */
4688 Object.defineProperty(Symbol, 'split', {
4689 value: Symbol('split')
4690 });
4691
4692 // Symbol.toPrimitive
4693 /* global Symbol */
4694 Object.defineProperty(Symbol, 'toPrimitive', {
4695 value: Symbol('toPrimitive')
4696 });
4697
4698 // Symbol.toStringTag
4699 /* global Symbol */
4700 Object.defineProperty(Symbol, 'toStringTag', {
4701 value: Symbol('toStringTag')
4702 });
4703
4704 // _Iterator
4705 /* global Symbol */
4706 // A modification of https://github.com/medikoo/es6-iterator
4707 // Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
4708
4709 var Iterator = (function () {
4710 // eslint-disable-line no-unused-vars
4711 var clear = function () {
4712 this.length = 0;
4713 return this;
4714 };
4715 var callable = function (fn) {
4716 if (typeof fn !== 'function')
4717 throw new TypeError(fn + " is not a function");
4718 return fn;
4719 };
4720
4721 var Iterator = function (list, context) {
4722 if (!(this instanceof Iterator)) {
4723 return new Iterator(list, context);
4724 }
4725 Object.defineProperties(this, {
4726 __list__: {
4727 writable: true,
4728 value: list
4729 },
4730 __context__: {
4731 writable: true,
4732 value: context
4733 },
4734 __nextIndex__: {
4735 writable: true,
4736 value: 0
4737 }
4738 });
4739 if (!context)
4740 return;
4741 callable(context.on);
4742 context.on('_add', this._onAdd.bind(this));
4743 context.on('_delete', this._onDelete.bind(this));
4744 context.on('_clear', this._onClear.bind(this));
4745 };
4746
4747 Object.defineProperties(Iterator.prototype, Object.assign({
4748 constructor: {
4749 value: Iterator,
4750 configurable: true,
4751 enumerable: false,
4752 writable: true
4753 },
4754 _next: {
4755 value: function () {
4756 var i;
4757 if (!this.__list__)
4758 return;
4759 if (this.__redo__) {
4760 i = this.__redo__.shift();
4761 if (i !== undefined)
4762 return i;
4763 }
4764 if (this.__nextIndex__ < this.__list__.length)
4765 return this.__nextIndex__++;
4766 this._unBind();
4767 },
4768 configurable: true,
4769 enumerable: false,
4770 writable: true
4771 },
4772 next: {
4773 value: function () {
4774 return this._createResult(this._next());
4775 },
4776 configurable: true,
4777 enumerable: false,
4778 writable: true
4779 },
4780 _createResult: {
4781 value: function (i) {
4782 if (i === undefined)
4783 return {
4784 done: true,
4785 value: undefined
4786 };
4787 return {
4788 done: false,
4789 value: this._resolve(i)
4790 };
4791 },
4792 configurable: true,
4793 enumerable: false,
4794 writable: true
4795 },
4796 _resolve: {
4797 value: function (i) {
4798 return this.__list__[i];
4799 },
4800 configurable: true,
4801 enumerable: false,
4802 writable: true
4803 },
4804 _unBind: {
4805 value: function () {
4806 this.__list__ = null;
4807 delete this.__redo__;
4808 if (!this.__context__)
4809 return;
4810 this.__context__.off('_add', this._onAdd.bind(this));
4811 this.__context__.off('_delete', this._onDelete.bind(this));
4812 this.__context__.off('_clear', this._onClear.bind(this));
4813 this.__context__ = null;
4814 },
4815 configurable: true,
4816 enumerable: false,
4817 writable: true
4818 },
4819 toString: {
4820 value: function () {
4821 return '[object Iterator]';
4822 },
4823 configurable: true,
4824 enumerable: false,
4825 writable: true
4826 }
4827 }, {
4828 _onAdd: {
4829 value: function (index) {
4830 if (index >= this.__nextIndex__)
4831 return;
4832 ++this.__nextIndex__;
4833 if (!this.__redo__) {
4834 Object.defineProperty(this, '__redo__', {
4835 value: [index],
4836 configurable: true,
4837 enumerable: false,
4838 writable: false
4839 });
4840 return;
4841 }
4842 this.__redo__.forEach(function (redo, i) {
4843 if (redo >= index)
4844 this.__redo__[i] = ++redo;
4845 }, this);
4846 this.__redo__.push(index);
4847 },
4848 configurable: true,
4849 enumerable: false,
4850 writable: true
4851 },
4852 _onDelete: {
4853 value: function (index) {
4854 var i;
4855 if (index >= this.__nextIndex__)
4856 return;
4857 --this.__nextIndex__;
4858 if (!this.__redo__)
4859 return;
4860 i = this.__redo__.indexOf(index);
4861 if (i !== - 1)
4862 this.__redo__.splice(i, 1);
4863 this.__redo__.forEach(function (redo, i) {
4864 if (redo > index)
4865 this.__redo__[i] = --redo;
4866 }, this);
4867 },
4868 configurable: true,
4869 enumerable: false,
4870 writable: true
4871 },
4872 _onClear: {
4873 value: function () {
4874 if (this.__redo__)
4875 clear.call(this.__redo__);
4876 this.__nextIndex__ = 0;
4877 },
4878 configurable: true,
4879 enumerable: false,
4880 writable: true
4881 }
4882 }));
4883
4884 Object.defineProperty(Iterator.prototype, Symbol.iterator, {
4885 value: function () {
4886 return this;
4887 },
4888 configurable: true,
4889 enumerable: false,
4890 writable: true
4891 });
4892 Object.defineProperty(Iterator.prototype, Symbol.toStringTag, {
4893 value: 'Iterator',
4894 configurable: false,
4895 enumerable: false,
4896 writable: true
4897 });
4898
4899 return Iterator;
4900 }());
4901
4902 // _ArrayIterator
4903 /* global Iterator */
4904 // A modification of https://github.com/medikoo/es6-iterator
4905 // Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
4906
4907 var ArrayIterator = (function() {
4908 // eslint-disable-line no-unused-vars
4909
4910 var ArrayIterator = function(arr, kind) {
4911 if (!(this instanceof ArrayIterator))
4912 return new ArrayIterator(arr, kind);
4913 Iterator.call(this, arr);
4914 if (!kind)
4915 kind = 'value';
4916 else if (String.prototype.includes.call(kind, 'key+value'))
4917 kind = 'key+value';
4918 else if (String.prototype.includes.call(kind, 'key'))
4919 kind = 'key';
4920 else
4921 kind = 'value';
4922 Object.defineProperty(this, '__kind__', {
4923 value: kind,
4924 configurable: false,
4925 enumerable: false,
4926 writable: false
4927 });
4928 };
4929 if (Object.setPrototypeOf)
4930 Object.setPrototypeOf(ArrayIterator, Iterator.prototype);
4931
4932 ArrayIterator.prototype = Object.create(Iterator.prototype, {
4933 constructor: {
4934 value: ArrayIterator,
4935 configurable: true,
4936 enumerable: false,
4937 writable: true
4938 },
4939 _resolve: {
4940 value: function(i) {
4941 if (this.__kind__ === 'value')
4942 return this.__list__[i];
4943 if (this.__kind__ === 'key+value')
4944 return [i, this.__list__[i]];
4945 return i;
4946 },
4947 configurable: true,
4948 enumerable: false,
4949 writable: true
4950 },
4951 toString: {
4952 value: function() {
4953 return '[object Array Iterator]';
4954 },
4955 configurable: true,
4956 enumerable: false,
4957 writable: true
4958 }
4959 });
4960
4961 return ArrayIterator;
4962 }());
4963
4964 // Array.prototype.entries
4965 /* global CreateMethodProperty, ToObject */
4966 // 22.1.3.4. Array.prototype.entries ( )
4967 CreateMethodProperty(Array.prototype, 'entries', function entries() {
4968 // 1. Let O be ? ToObject(this value).
4969 var O = ToObject(this);
4970 // 2. Return CreateArrayIterator(O, "key+value").
4971 // TODO: Add CreateArrayIterator
4972 return new ArrayIterator(O, 'key+value');
4973 });
4974
4975 // Array.prototype.keys
4976 /* global CreateMethodProperty, ToObject */
4977 // 22.1.3.14. Array.prototype.keys ( )
4978 CreateMethodProperty(Array.prototype, 'keys', function keys() {
4979 // 1. Let O be ? ToObject(this value).
4980 var O = ToObject(this);
4981 // 2. Return CreateArrayIterator(O, "key").
4982 // TODO: Add CreateArrayIterator.
4983 return new ArrayIterator(O, 'key');
4984 });
4985
4986 // Array.prototype.values
4987 /* global CreateMethodProperty, Symbol, ToObject */
4988 // 22.1.3.30/ Array.prototype.values ( )
4989 // Polyfill.io - Firefox, Chrome and Opera have Array.prototype[Symbol.iterator], which is the exact same function as Array.prototype.values.
4990 if ('Symbol' in this && 'iterator' in Symbol && typeof Array.prototype[Symbol.iterator] === 'function') {
4991 CreateMethodProperty(Array.prototype, 'values', Array.prototype[Symbol.iterator]);
4992 } else {
4993 CreateMethodProperty(Array.prototype, 'values', function values () {
4994 // 1. Let O be ? ToObject(this value).
4995 var O = ToObject(this);
4996 // 2. Return CreateArrayIterator(O, "value").
4997 // TODO: Add CreateArrayIterator
4998 return new ArrayIterator(O, 'value');
4999 });
5000 }
5001
5002 // Array.prototype.@@iterator
5003 /* global Symbol, CreateMethodProperty */
5004 // 22.1.3.31. Array.prototype [ @@iterator ] ( )
5005 // The initial value of the @@iterator property is the same function object as the initial value of the Array.prototype.values property.
5006 CreateMethodProperty(Array.prototype, Symbol.iterator, Array.prototype.values);
5007
5008 // Symbol.unscopables
5009 /* global Symbol */
5010 Object.defineProperty(Symbol, 'unscopables', {
5011 value: Symbol('unscopables')
5012 });
5013
5014 // WeakMap
5015 /* globals Symbol, OrdinaryCreateFromConstructor, IsCallable, GetIterator, IteratorStep, IteratorValue, IteratorClose, Get, Call, CreateMethodProperty, Type, SameValue */
5016 (function (global) {
5017 // 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.
5018 var undefMarker = Symbol('undef');
5019 // 23.3.1.1 WeakMap ( [ iterable ] )
5020 var WeakMap = function WeakMap( /* iterable */
5021 ) {
5022 // 1. If NewTarget is undefined, throw a TypeError exception.
5023 if (!(this instanceof WeakMap)) {
5024 throw new TypeError('Constructor WeakMap requires "new"');
5025 }
5026 // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakMapPrototype%", « [[WeakMapData]] »).
5027 var map = OrdinaryCreateFromConstructor(this, WeakMap.prototype, {
5028 _keys: [],
5029 _values: [],
5030 _es6WeakMap: true
5031 });
5032
5033 // 3. Set map.[[WeakMapData]] to a new empty List.
5034 // Polyfill.io - This step was done as part of step two.
5035
5036 // 4. If iterable is not present, let iterable be undefined.
5037 var iterable = arguments.length > 0 ? arguments[0] : undefined;
5038
5039 // 5. If iterable is either undefined or null, return map.
5040 if (iterable === null || iterable === undefined) {
5041 return map;
5042 }
5043
5044 // 6. Let adder be ? Get(map, "set").
5045 var adder = Get(map, "set");
5046
5047 // 7. If IsCallable(adder) is false, throw a TypeError exception.
5048 if (!IsCallable(adder)) {
5049 throw new TypeError("WeakMap.prototype.set is not a function");
5050 }
5051
5052 // 8. Let iteratorRecord be ? GetIterator(iterable).
5053 try {
5054 var iteratorRecord = GetIterator(iterable);
5055 // 9. Repeat,
5056 while (true) {
5057 // a. Let next be ? IteratorStep(iteratorRecord).
5058 var next = IteratorStep(iteratorRecord);
5059 // b. If next is false, return map.
5060 if (next === false) {
5061 return map;
5062 }
5063 // c. Let nextItem be ? IteratorValue(next).
5064 var nextItem = IteratorValue(next);
5065 // d. If Type(nextItem) is not Object, then
5066 if (Type(nextItem) !== 'object') {
5067 // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
5068 try {
5069 throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
5070 } catch (error) {
5071 // ii. Return ? IteratorClose(iteratorRecord, error).
5072 return IteratorClose(iteratorRecord, error);
5073 }
5074 }
5075 try {
5076 // Polyfill.io - The try catch accounts for steps: f, h, and j.
5077
5078 // e. Let k be Get(nextItem, "0").
5079 var k = Get(nextItem, "0");
5080 // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
5081 // g. Let v be Get(nextItem, "1").
5082 var v = Get(nextItem, "1");
5083 // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
5084 // i. Let status be Call(adder, map, « k.[[Value]], v.[[Value]] »).
5085 Call(adder, map, [k, v]);
5086 } catch (e) {
5087 // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
5088 return IteratorClose(iteratorRecord, e);
5089 }
5090 }
5091 } catch (e) {
5092 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
5093 if (Array.isArray(iterable) ||
5094 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
5095 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
5096 (!!iterable.callee)) {
5097 var index;
5098 var length = iterable.length;
5099 for (index = 0; index < length; index++) {
5100 var k = iterable[index][0];
5101 var v = iterable[index][1];
5102 Call(adder, map, [k, v]);
5103 }
5104 }
5105 }
5106 return map;
5107 };
5108
5109 // 23.3.2.1 WeakMap.prototype
5110 // The initial value of WeakMap.prototype is the intrinsic object %WeakMapPrototype%.
5111 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
5112 Object.defineProperty(WeakMap, 'prototype', {
5113 configurable: false,
5114 enumerable: false,
5115 writable: false,
5116 value: {}
5117 });
5118
5119 // 23.3.3.1 WeakMap.prototype.constructor
5120 CreateMethodProperty(WeakMap.prototype, 'constructor', WeakMap);
5121
5122 // 23.3.3.2 WeakMap.prototype.delete ( key )
5123 CreateMethodProperty(WeakMap.prototype, 'delete', function (key) {
5124 // 1. Let M be the this value.
5125 var M = this;
5126 // 2. If Type(M) is not Object, throw a TypeError exception.
5127 if (Type(M) !== 'object') {
5128 throw new TypeError('Method WeakMap.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
5129 }
5130 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
5131 if (M._es6WeakMap !== true) {
5132 throw new TypeError('Method WeakMap.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
5133 }
5134 // 4. Let entries be the List that is M.[[WeakMapData]].
5135 var entries = M._keys;
5136 // 5. If Type(key) is not Object, return false.
5137 if (Type(key) !== 'object') {
5138 return false;
5139 }
5140 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
5141 for (var i = 0; i < entries.length; i++) {
5142 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, then
5143 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
5144 // i. Set p.[[Key]] to empty.
5145 this._keys[i] = undefMarker;
5146 // ii. Set p.[[Value]] to empty.
5147 this._values[i] = undefMarker;
5148 this._size = --this._size;
5149 // iii. Return true.
5150 return true;
5151 }
5152 }
5153 // 7. Return false.
5154 return false;
5155 });
5156
5157 // 23.3.3.3 WeakMap.prototype.get ( key )
5158 CreateMethodProperty(WeakMap.prototype, 'get', function get(key) {
5159 // 1. Let M be the this value.
5160 var M = this;
5161 // 2. If Type(M) is not Object, throw a TypeError exception.
5162 if (Type(M) !== 'object') {
5163 throw new TypeError('Method WeakMap.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
5164 }
5165 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
5166 if (M._es6WeakMap !== true) {
5167 throw new TypeError('Method WeakMap.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
5168 }
5169 // 4. Let entries be the List that is M.[[WeakMapData]].
5170 var entries = M._keys;
5171 // 5. If Type(key) is not Object, return undefined.
5172 if (Type(key) !== 'object') {
5173 return undefined;
5174 }
5175 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
5176 for (var i = 0; i < entries.length; i++) {
5177 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
5178 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
5179 return M._values[i];
5180 }
5181 }
5182 // 7. Return undefined.
5183 return undefined;
5184 });
5185
5186 // 23.3.3.4 WeakMap.prototype.has ( key )
5187 CreateMethodProperty(WeakMap.prototype, 'has', function has(key) {
5188 // 1. Let M be the this value.
5189 var M = this;
5190 // 2. If Type(M) is not Object, throw a TypeError exception.
5191 if (typeof M !== 'object') {
5192 throw new TypeError('Method WeakMap.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
5193 }
5194 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
5195 if (M._es6WeakMap !== true) {
5196 throw new TypeError('Method WeakMap.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
5197 }
5198 // 4. Let entries be the List that is M.[[WeakMapData]].
5199 var entries = M._keys;
5200 // 5. If Type(key) is not Object, return false.
5201 if (Type(key) !== 'object') {
5202 return false;
5203 }
5204 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
5205 for (var i = 0; i < entries.length; i++) {
5206 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return true.
5207 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
5208 return true;
5209 }
5210 }
5211 // 7. Return false.
5212 return false;
5213 });
5214
5215 // 23.3.3.5 WeakMap.prototype.set ( key, value )
5216 CreateMethodProperty(WeakMap.prototype, 'set', function set(key, value) {
5217 // 1. Let M be the this value.
5218 var M = this;
5219 // 2. If Type(M) is not Object, throw a TypeError exception.
5220 if (Type(M) !== 'object') {
5221 throw new TypeError('Method WeakMap.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
5222 }
5223 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
5224 if (M._es6WeakMap !== true) {
5225 throw new TypeError('Method WeakMap.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
5226 }
5227 // 4. Let entries be the List that is M.[[WeakMapData]].
5228 var entries = M._keys;
5229 // 5. If Type(key) is not Object, throw a TypeError exception.
5230 if (Type(key) !== 'object') {
5231 throw new TypeError("Invalid value used as weak map key");
5232 }
5233 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
5234 for (var i = 0; i < entries.length; i++) {
5235 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, then
5236 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
5237 // i. Set p.[[Value]] to value.
5238 M._values[i] = value;
5239 // ii. Return M.
5240 return M;
5241 }
5242 }
5243 // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
5244 var p = {
5245 '[[Key]]': key,
5246 '[[Value]]': value
5247 };
5248 // 8. Append p as the last element of entries.
5249 M._keys.push(p['[[Key]]']);
5250 M._values.push(p['[[Value]]']);
5251 // 9. Return M.
5252 return M;
5253 });
5254
5255 // 23.3.3.6 WeakMap.prototype [ @@toStringTag ]
5256 // The initial value of the @@toStringTag property is the String value "WeakMap".
5257 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
5258
5259 // 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.
5260 if (!('name' in WeakMap)) {
5261 // 19.2.4.2 name
5262 Object.defineProperty(WeakMap, 'name', {
5263 configurable: true,
5264 enumerable: false,
5265 writable: false,
5266 value: 'WeakMap'
5267 });
5268 }
5269
5270 // Export the object
5271 try {
5272 CreateMethodProperty(global, 'WeakMap', WeakMap);
5273 } catch (e) {
5274 // IE8 throws an error here if we set enumerable to false.
5275 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
5276 global['WeakMap'] = WeakMap;
5277 }
5278 }(this));
5279
5280 // WeakSet
5281 /* global Call, CreateMethodProperty, Get, GetIterator, IsArray, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
5282 (function (global) {
5283 // 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.
5284 var undefMarker = Symbol('undef');
5285 // 23.4.1.1. WeakSet ( [ iterable ] )
5286 var WeakSet = function WeakSet() {
5287 // 1. If NewTarget is undefined, throw a TypeError exception.
5288 if (!(this instanceof WeakSet)) {
5289 throw new TypeError('Constructor WeakSet requires "new"');
5290 }
5291 // 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakSetPrototype%", « [[WeakSetData]] »).
5292 var set = OrdinaryCreateFromConstructor(this, WeakSet.prototype, {
5293 _values: [],
5294 _size: 0,
5295 _es6WeakSet: true
5296 });
5297
5298 // 3. Set set.[[WeakSetData]] to a new empty List.
5299 // Polyfill.io - This step was done as part of step two.
5300
5301 // 4. If iterable is not present, let iterable be undefined.
5302 var iterable = arguments.length > 0 ? arguments[0] : undefined;
5303 // 5. If iterable is either undefined or null, return set.
5304 if (iterable === null || iterable === undefined) {
5305 return set;
5306 }
5307 // 6. Let adder be ? Get(set, "add").
5308 var adder = Get(set, 'add');
5309 // 7. If IsCallable(adder) is false, throw a TypeError exception.
5310 if (!IsCallable(adder)) {
5311 throw new TypeError("WeakSet.prototype.add is not a function");
5312 }
5313 try {
5314 // 8. Let iteratorRecord be ? GetIterator(iterable).
5315 var iteratorRecord = GetIterator(iterable);
5316 // 9. Repeat,
5317 while (true) {
5318 // a. Let next be ? IteratorStep(iteratorRecord).
5319 var next = IteratorStep(iteratorRecord);
5320 // b. If next is false, return set.
5321 if (next === false) {
5322 return set;
5323 }
5324 // c. Let nextValue be ? IteratorValue(next).
5325 var nextValue = IteratorValue(next);
5326 // d. Let status be Call(adder, set, « nextValue »).
5327 try {
5328 Call(adder, set, [nextValue]);
5329 } catch (e) {
5330 // e. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
5331 return IteratorClose(iteratorRecord, e);
5332 }
5333 }
5334 } catch (e) {
5335 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
5336 if (IsArray(iterable) ||
5337 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
5338 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
5339 (!!iterable.callee)) {
5340 var index;
5341 var length = iterable.length;
5342 for (index = 0; index < length; index++) {
5343 Call(adder, set, [iterable[index]]);
5344 }
5345 }
5346 }
5347 return set;
5348 };
5349
5350 // 23.4.2.1. WeakSet.prototype
5351 // The initial value of WeakSet.prototype is the intrinsic %WeakSetPrototype% object.
5352 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
5353 Object.defineProperty(WeakSet, 'prototype', {
5354 configurable: false,
5355 enumerable: false,
5356 writable: false,
5357 value: {}
5358 });
5359
5360 // 23.4.3.1. WeakSet.prototype.add ( value )
5361 CreateMethodProperty(WeakSet.prototype, 'add', function add(value) {
5362 // 1. Let S be the this value.
5363 var S = this;
5364 // 2. If Type(S) is not Object, throw a TypeError exception.
5365 if (Type(S) !== 'object') {
5366 throw new TypeError('Method WeakSet.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
5367 }
5368 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
5369 if (S._es6WeakSet !== true) {
5370 throw new TypeError('Method WeakSet.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
5371 }
5372 // 4. If Type(value) is not Object, throw a TypeError exception.
5373 if (Type(value) !== 'object') {
5374 throw new TypeError('Invalid value used in weak set');
5375 }
5376 // 5. Let entries be the List that is S.[[WeakSetData]].
5377 var entries = S._values;
5378 // 6. For each e that is an element of entries, do
5379 for (var i = 0; i < entries.length; i++) {
5380 var e = entries[i];
5381 // a. If e is not empty and SameValue(e, value) is true, then
5382 if (e !== undefMarker && SameValueZero(e, value)) {
5383 // i. Return S.
5384 return S;
5385 }
5386 }
5387 // 7. Append value as the last element of entries.
5388 S._values.push(value);
5389 // 8. Return S.
5390 return S;
5391 });
5392
5393 // 23.4.3.2. WeakSet.prototype.constructor
5394 CreateMethodProperty(WeakSet.prototype, 'constructor', WeakSet);
5395
5396 // 23.4.3.3. WeakSet.prototype.delete ( value )
5397 CreateMethodProperty(WeakSet.prototype, 'delete', function (value) {
5398 // 1. Let S be the this value.
5399 var S = this;
5400 // 2. If Type(S) is not Object, throw a TypeError exception.
5401 if (Type(S) !== 'object') {
5402 throw new TypeError('Method WeakSet.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
5403 }
5404 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
5405 if (S._es6WeakSet !== true) {
5406 throw new TypeError('Method WeakSet.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
5407 }
5408 // 4. If Type(value) is not Object, return false.
5409 if (Type(value) !== 'object') {
5410 return false;
5411 }
5412 // 5. Let entries be the List that is S.[[WeakSetData]].
5413 var entries = S._values;
5414 // 6. For each e that is an element of entries, do
5415 for (var i = 0; i < entries.length; i++) {
5416 var e = entries[i];
5417 // a. If e is not empty and SameValue(e, value) is true, then
5418 if (e !== undefMarker && SameValueZero(e, value)) {
5419 // i. Replace the element of entries whose value is e with an element whose value is empty.
5420 entries[i] = undefMarker;
5421 // ii. Return true.
5422 return true;
5423 }
5424 }
5425 // 7. Return false.
5426 return false;
5427 });
5428
5429 // 23.4.3.4. WeakSet.prototype.has ( value )
5430 CreateMethodProperty(WeakSet.prototype, 'has', function has(value) {
5431 // 1. Let S be the this value.
5432 var S = this;
5433 // 2. If Type(S) is not Object, throw a TypeError exception.
5434 if (Type(S) !== 'object') {
5435 throw new TypeError('Method WeakSet.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(S));
5436 }
5437 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
5438 if (S._es6WeakSet !== true) {
5439 throw new TypeError('Method WeakSet.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(S));
5440 }
5441 // 4. Let entries be the List that is S.[[WeakSetData]].
5442 var entries = S._values;
5443 // 5. If Type(value) is not Object, return false.
5444 if (Type(value) !== 'object') {
5445 return false;
5446 }
5447 // 6. For each e that is an element of entries, do
5448 for (var i = 0; i < entries.length; i++) {
5449 var e = entries[i];
5450 // a. If e is not empty and SameValue(e, value) is true, return true.
5451 if (e !== undefMarker && SameValueZero(e, value)) {
5452 return true;
5453 }
5454 }
5455 // 7. Return false.
5456 return false;
5457 });
5458
5459 // 23.4.3.5. WeakSet.prototype [ @@toStringTag ]
5460 // The initial value of the @@toStringTag property is the String value "WeakSet".
5461 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
5462
5463 // 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.
5464 if (!('name' in WeakSet)) {
5465 // 19.2.4.2 name
5466 Object.defineProperty(WeakSet, 'name', {
5467 configurable: true,
5468 enumerable: false,
5469 writable: false,
5470 value: 'WeakSet'
5471 });
5472 }
5473
5474 // Export the object
5475 try {
5476 CreateMethodProperty(global, 'WeakSet', WeakSet);
5477 } catch (e) {
5478 // IE8 throws an error here if we set enumerable to false.
5479 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
5480 global['WeakSet'] = WeakSet;
5481 }
5482
5483 }(this));
5484})
5485.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});