· 6 years ago · May 13, 2019, 10:44 PM
1/* Polyfill service v3.34.0
2 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
3 *
4 * Features requested: default
5 *
6 * - _DOMTokenList, License: ISC (required by "DOMTokenList", "default")
7 * - _ESAbstract.ArrayCreate, License: CC0 (required by "Array.from", "default", "Array.of", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.iterator", "Array.prototype.map")
8 * - _ESAbstract.Call, License: CC0 (required by "Array.from", "default", "_ESAbstract.GetIterator", "Map", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.IteratorNext", "_ESAbstract.IteratorStep", "Array.prototype.forEach", "URL", "Symbol", "Symbol.iterator", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.of", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.OrdinaryToPrimitive")
9 * - _ESAbstract.CreateDataProperty, License: CC0 (required by "_ESAbstract.CreateDataPropertyOrThrow", "Array.from", "default", "Array.of", "_ESAbstract.CreateIterResultObject", "Map", "Set")
10 * - _ESAbstract.CreateDataPropertyOrThrow, License: CC0 (required by "Array.from", "default", "Array.of", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.iterator", "Array.prototype.map")
11 * - _ESAbstract.CreateMethodProperty, License: CC0 (required by "Array.from", "default", "Array.of", "Array.prototype.fill", "Map", "Number.isNaN", "Object.assign", "Set", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.indexOf", "Element.prototype.after", "Element.prototype.before", "Array.isArray", "URL", "Object.create", "_ESAbstract.GetIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Symbol", "Symbol.iterator", "Object.getOwnPropertyDescriptor", "Object.keys", "Object.defineProperties", "Array.prototype.forEach", "Function.prototype.bind", "Object.getPrototypeOf", "Array.prototype.filter", "Array.prototype.map", "Object.getOwnPropertyNames", "Object.freeze")
12 * - _ESAbstract.Get, License: CC0 (required by "Array.from", "default", "Array.prototype.fill", "Object.assign", "_ESAbstract.IteratorValue", "Map", "Set", "Array.prototype.indexOf", "Element.prototype.after", "Element.prototype.before", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Object.defineProperties", "URL", "Object.create", "_ESAbstract.GetIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "Symbol", "Symbol.iterator", "Array.prototype.forEach", "_ESAbstract.GetPrototypeFromConstructor", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "_ESAbstract.ArraySpeciesCreate")
13 * - _ESAbstract.IsCallable, License: CC0 (required by "Array.from", "default", "Map", "Set", "_ESAbstract.GetMethod", "Array.prototype.forEach", "URL", "Symbol", "Symbol.iterator", "Function.prototype.bind", "_ESAbstract.Construct", "Array.of", "Object.getOwnPropertyDescriptor", "Object.assign", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith")
14 * - _ESAbstract.RequireObjectCoercible, License: CC0 (required by "String.prototype.endsWith", "default", "String.prototype.includes", "String.prototype.startsWith")
15 * - _ESAbstract.SameValueNonNumber, License: CC0 (required by "_ESAbstract.SameValueZero", "Map", "default", "Array.from", "Set")
16 * - _ESAbstract.ToBoolean, License: CC0 (required by "_ESAbstract.IteratorComplete", "Map", "default", "Array.from", "Set", "_ESAbstract.IteratorStep", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.filter", "Symbol", "Symbol.iterator")
17 * - _ESAbstract.ToInteger, License: CC0 (required by "Array.prototype.fill", "default", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "_ESAbstract.ToLength", "Array.from", "Array.prototype.indexOf", "Element.prototype.after", "Element.prototype.before")
18 * - _ESAbstract.ToLength, License: CC0 (required by "Array.from", "default", "Array.prototype.fill", "Array.prototype.indexOf", "Element.prototype.after", "Element.prototype.before", "Array.prototype.forEach", "URL", "Symbol", "Map", "Set", "Symbol.iterator", "Array.prototype.filter", "Array.prototype.map")
19 * - _ESAbstract.ToObject, License: CC0 (required by "Array.from", "default", "Array.prototype.fill", "Object.assign", "Array.prototype.indexOf", "Element.prototype.after", "Element.prototype.before", "Object.defineProperties", "URL", "Object.create", "Map", "Set", "_ESAbstract.GetIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "Symbol", "Symbol.iterator", "Array.prototype.forEach", "_ESAbstract.GetV", "_ESAbstract.GetMethod", "Array.prototype.filter", "Array.prototype.map")
20 * - _ESAbstract.GetV, License: CC0 (required by "_ESAbstract.GetMethod", "Array.from", "default", "Map", "Set", "_ESAbstract.GetIterator")
21 * - _ESAbstract.GetMethod, License: CC0 (required by "Array.from", "default", "Map", "Set", "_ESAbstract.IsConstructor", "Array.of", "_ESAbstract.GetIterator", "_ESAbstract.IteratorClose", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith")
22 * - _ESAbstract.Type, License: CC0 (required by "Map", "default", "Array.from", "Number.isNaN", "_ESAbstract.IsConstructor", "Array.of", "_ESAbstract.GetIterator", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.ToString", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "_ESAbstract.IteratorValue", "_ESAbstract.CreateIterResultObject", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "_ESAbstract.IteratorNext", "_ESAbstract.SameValueZero", "Object.create", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Symbol", "Symbol.iterator", "_ESAbstract.IsRegExp", "Object.defineProperties", "URL", "_ESAbstract.ToPrimitive", "_ESAbstract.GetPrototypeFromConstructor", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map")
23 * - _ESAbstract.CreateIterResultObject, License: CC0 (required by "Map", "default", "Array.from", "Set")
24 * - _ESAbstract.GetIterator, License: CC0 (required by "Array.from", "default", "Map", "Set")
25 * - _ESAbstract.GetPrototypeFromConstructor, License: CC0 (required by "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "default", "Array.from", "Set", "_ESAbstract.Construct", "Array.of")
26 * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "Map", "default", "Array.from", "Set", "_ESAbstract.Construct", "Array.of")
27 * - _ESAbstract.IsConstructor, License: CC0 (required by "Array.from", "default", "Array.of", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.iterator", "Array.prototype.map")
28 * - _ESAbstract.Construct, License: CC0 (required by "Array.from", "default", "Array.of", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.iterator", "Array.prototype.map")
29 * - _ESAbstract.IsRegExp, License: CC0 (required by "String.prototype.endsWith", "default", "String.prototype.includes", "String.prototype.startsWith")
30 * - _ESAbstract.IteratorClose, License: CC0 (required by "Array.from", "default", "Map", "Set")
31 * - _ESAbstract.IteratorComplete, License: CC0 (required by "Map", "default", "Array.from", "Set", "_ESAbstract.IteratorStep")
32 * - _ESAbstract.IteratorNext, License: CC0 (required by "Map", "default", "Array.from", "Set", "_ESAbstract.IteratorStep")
33 * - _ESAbstract.IteratorStep, License: CC0 (required by "Array.from", "default", "Map", "Set")
34 * - _ESAbstract.IteratorValue, License: CC0 (required by "Array.from", "default", "Map", "Set")
35 * - _ESAbstract.OrdinaryToPrimitive, License: CC0 (required by "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.from", "default", "Array.of", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith")
36 * - _ESAbstract.SameValueZero, License: CC0 (required by "Map", "default", "Array.from", "Set")
37 * - _ESAbstract.ToPrimitive, License: CC0 (required by "_ESAbstract.ToString", "Array.from", "default", "Array.of", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith")
38 * - _ESAbstract.ToString, License: CC0 (required by "Array.from", "default", "Array.of", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.indexOf", "Element.prototype.after", "Element.prototype.before", "Array.prototype.forEach", "URL", "Symbol", "Map", "Set", "Symbol.iterator", "Array.prototype.filter", "Array.prototype.map")
39 * - _mutation, License: CC0 (required by "DocumentFragment.prototype.append", "default", "DocumentFragment.prototype.prepend", "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith")
40 * - Array.of, License: CC0 (required by "default")
41 * - Array.prototype.fill, License: CC0 (required by "default")
42 * - DocumentFragment.prototype.append, License: CC0 (required by "default")
43 * - DocumentFragment.prototype.prepend, License: CC0 (required by "default")
44 * - DOMTokenList, License: CC0 (required by "default", "Element.prototype.classList")
45 * - Element.prototype.after, License: CC0 (required by "default")
46 * - Element.prototype.append, License: CC0 (required by "default")
47 * - Element.prototype.before, License: CC0 (required by "default")
48 * - Element.prototype.classList, License: ISC (required by "default")
49 * - Element.prototype.matches, License: CC0 (required by "default", "Element.prototype.closest")
50 * - Element.prototype.closest, License: CC0 (required by "default")
51 * - Element.prototype.prepend, License: CC0 (required by "default")
52 * - Element.prototype.remove, License: CC0 (required by "default")
53 * - Element.prototype.replaceWith, License: CC0 (required by "default")
54 * - Event, License: CC0 (required by "default", "CustomEvent")
55 * - CustomEvent, License: CC0 (required by "default")
56 * - Node.prototype.contains, License: CC0 (required by "default")
57 * - Number.isNaN, License: MIT (required by "default")
58 * - Object.assign, License: CC0 (required by "default")
59 * - Promise, License: MIT (required by "default")
60 * - String.prototype.endsWith, License: CC0 (required by "default")
61 * - String.prototype.includes, License: CC0 (required by "default")
62 * - String.prototype.startsWith, License: CC0 (required by "default")
63 * - Symbol, License: MIT (required by "Map", "default", "Array.from", "Set", "Symbol.iterator", "Symbol.species")
64 * - Symbol.iterator, License: MIT (required by "Array.from", "default", "Map", "Set")
65 * - Symbol.species, License: MIT (required by "Map", "default", "Array.from", "Set")
66 * - Map, License: CC0 (required by "default", "Array.from")
67 * - Set, License: CC0 (required by "default", "Array.from")
68 * - Array.from, License: CC0 (required by "default")
69 * - URL, License: CC0-1.0 (required by "default") */
70
71(function(undefined) {
72
73// _DOMTokenList
74/*
75Copyright (c) 2016, John Gardner
76
77Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
78
79THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
80*/
81var _DOMTokenList = (function() { // eslint-disable-line no-unused-vars
82 var dpSupport = true;
83 var defineGetter = function (object, name, fn, configurable) {
84 if (Object.defineProperty)
85 Object.defineProperty(object, name, {
86 configurable: false === dpSupport ? true : !!configurable,
87 get: fn
88 });
89
90 else object.__defineGetter__(name, fn);
91 };
92
93 /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
94 try {
95 defineGetter({}, "support");
96 }
97 catch (e) {
98 dpSupport = false;
99 }
100
101
102 var _DOMTokenList = function (el, prop) {
103 var that = this;
104 var tokens = [];
105 var tokenMap = {};
106 var length = 0;
107 var maxLength = 0;
108 var addIndexGetter = function (i) {
109 defineGetter(that, i, function () {
110 preop();
111 return tokens[i];
112 }, false);
113
114 };
115 var reindex = function () {
116
117 /** Define getter functions for array-like access to the tokenList's contents. */
118 if (length >= maxLength)
119 for (; maxLength < length; ++maxLength) {
120 addIndexGetter(maxLength);
121 }
122 };
123
124 /** Helper function called at the start of each class method. Internal use only. */
125 var preop = function () {
126 var error;
127 var i;
128 var args = arguments;
129 var rSpace = /\s+/;
130
131 /** Validate the token/s passed to an instance method, if any. */
132 if (args.length)
133 for (i = 0; i < args.length; ++i)
134 if (rSpace.test(args[i])) {
135 error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
136 error.code = 5;
137 error.name = "InvalidCharacterError";
138 throw error;
139 }
140
141
142 /** Split the new value apart by whitespace*/
143 if (typeof el[prop] === "object") {
144 tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
145 } else {
146 tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
147 }
148
149 /** Avoid treating blank strings as single-item token lists */
150 if ("" === tokens[0]) tokens = [];
151
152 /** Repopulate the internal token lists */
153 tokenMap = {};
154 for (i = 0; i < tokens.length; ++i)
155 tokenMap[tokens[i]] = true;
156 length = tokens.length;
157 reindex();
158 };
159
160 /** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
161 preop();
162
163 /** Return the number of tokens in the underlying string. Read-only. */
164 defineGetter(that, "length", function () {
165 preop();
166 return length;
167 });
168
169 /** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
170 that.toLocaleString =
171 that.toString = function () {
172 preop();
173 return tokens.join(" ");
174 };
175
176 that.item = function (idx) {
177 preop();
178 return tokens[idx];
179 };
180
181 that.contains = function (token) {
182 preop();
183 return !!tokenMap[token];
184 };
185
186 that.add = function () {
187 preop.apply(that, args = arguments);
188
189 for (var args, token, i = 0, l = args.length; i < l; ++i) {
190 token = args[i];
191 if (!tokenMap[token]) {
192 tokens.push(token);
193 tokenMap[token] = true;
194 }
195 }
196
197 /** Update the targeted attribute of the attached element if the token list's changed. */
198 if (length !== tokens.length) {
199 length = tokens.length >>> 0;
200 if (typeof el[prop] === "object") {
201 el[prop].baseVal = tokens.join(" ");
202 } else {
203 el[prop] = tokens.join(" ");
204 }
205 reindex();
206 }
207 };
208
209 that.remove = function () {
210 preop.apply(that, args = arguments);
211
212 /** Build a hash of token names to compare against when recollecting our token list. */
213 for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
214 ignore[args[i]] = true;
215 delete tokenMap[args[i]];
216 }
217
218 /** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
219 for (i = 0; i < tokens.length; ++i)
220 if (!ignore[tokens[i]]) t.push(tokens[i]);
221
222 tokens = t;
223 length = t.length >>> 0;
224
225 /** Update the targeted attribute of the attached element. */
226 if (typeof el[prop] === "object") {
227 el[prop].baseVal = tokens.join(" ");
228 } else {
229 el[prop] = tokens.join(" ");
230 }
231 reindex();
232 };
233
234 that.toggle = function (token, force) {
235 preop.apply(that, [token]);
236
237 /** Token state's being forced. */
238 if (undefined !== force) {
239 if (force) {
240 that.add(token);
241 return true;
242 } else {
243 that.remove(token);
244 return false;
245 }
246 }
247
248 /** Token already exists in tokenList. Remove it, and return FALSE. */
249 if (tokenMap[token]) {
250 that.remove(token);
251 return false;
252 }
253
254 /** Otherwise, add the token and return TRUE. */
255 that.add(token);
256 return true;
257 };
258
259 return that;
260 };
261
262 return _DOMTokenList;
263}());
264
265// _ESAbstract.ArrayCreate
266// 9.4.2.2. ArrayCreate ( length [ , proto ] )
267function ArrayCreate(length /* [, proto] */) { // eslint-disable-line no-unused-vars
268 // 1. Assert: length is an integer Number ≥ 0.
269 // 2. If length is -0, set length to +0.
270 if (1 / length === -Infinity) {
271 length = 0;
272 }
273 // 3. If length>2^32-1, throw a RangeError exception.
274 if (length > (Math.pow(2, 32) - 1)) {
275 throw new RangeError('Invalid array length');
276 }
277 // 4. If proto is not present, set proto to the intrinsic object %ArrayPrototype%.
278 // 5. Let A be a newly created Array exotic object.
279 var A = [];
280 // 6. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.
281 // 7. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1.
282 // 8. Set A.[[Prototype]] to proto.
283 // 9. Set A.[[Extensible]] to true.
284 // 10. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
285 A.length = length;
286 // 11. Return A.
287 return A;
288}
289
290// _ESAbstract.Call
291/* global IsCallable */
292// 7.3.12. Call ( F, V [ , argumentsList ] )
293function Call(F, V /* [, argumentsList] */) { // eslint-disable-line no-unused-vars
294 // 1. If argumentsList is not present, set argumentsList to a new empty List.
295 var argumentsList = arguments.length > 2 ? arguments[2] : [];
296 // 2. If IsCallable(F) is false, throw a TypeError exception.
297 if (IsCallable(F) === false) {
298 throw new TypeError(Object.prototype.toString.call(F) + 'is not a function.');
299 }
300 // 3. Return ? F.[[Call]](V, argumentsList).
301 return F.apply(V, argumentsList);
302}
303
304// _ESAbstract.CreateDataProperty
305// 7.3.4. CreateDataProperty ( O, P, V )
306// NOTE
307// This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator.
308// 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.
309function CreateDataProperty(O, P, V) { // eslint-disable-line no-unused-vars
310 // 1. Assert: Type(O) is Object.
311 // 2. Assert: IsPropertyKey(P) is true.
312 // 3. Let newDesc be the PropertyDescriptor{ [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.
313 var newDesc = {
314 value: V,
315 writable: true,
316 enumerable: true,
317 configurable: true
318 };
319 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
320 try {
321 Object.defineProperty(O, P, newDesc);
322 return true;
323 } catch (e) {
324 return false;
325 }
326}
327
328// _ESAbstract.CreateDataPropertyOrThrow
329/* global CreateDataProperty */
330// 7.3.6. CreateDataPropertyOrThrow ( O, P, V )
331function CreateDataPropertyOrThrow(O, P, V) { // eslint-disable-line no-unused-vars
332 // 1. Assert: Type(O) is Object.
333 // 2. Assert: IsPropertyKey(P) is true.
334 // 3. Let success be ? CreateDataProperty(O, P, V).
335 var success = CreateDataProperty(O, P, V);
336 // 4. If success is false, throw a TypeError exception.
337 if (!success) {
338 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) + '`');
339 }
340 // 5. Return success.
341 return success;
342}
343
344// _ESAbstract.CreateMethodProperty
345// 7.3.5. CreateMethodProperty ( O, P, V )
346function CreateMethodProperty(O, P, V) { // eslint-disable-line no-unused-vars
347 // 1. Assert: Type(O) is Object.
348 // 2. Assert: IsPropertyKey(P) is true.
349 // 3. Let newDesc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}.
350 var newDesc = {
351 value: V,
352 writable: true,
353 enumerable: false,
354 configurable: true
355 };
356 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
357 Object.defineProperty(O, P, newDesc);
358}
359
360// _ESAbstract.Get
361// 7.3.1. Get ( O, P )
362function Get(O, P) { // eslint-disable-line no-unused-vars
363 // 1. Assert: Type(O) is Object.
364 // 2. Assert: IsPropertyKey(P) is true.
365 // 3. Return ? O.[[Get]](P, O).
366 return O[P];
367}
368
369// _ESAbstract.IsCallable
370// 7.2.3. IsCallable ( argument )
371function IsCallable(argument) { // eslint-disable-line no-unused-vars
372 // 1. If Type(argument) is not Object, return false.
373 // 2. If argument has a [[Call]] internal method, return true.
374 // 3. Return false.
375
376 // 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.
377 return typeof argument === 'function';
378}
379
380// _ESAbstract.RequireObjectCoercible
381// 7.2.1. RequireObjectCoercible ( argument )
382// The abstract operation ToObject converts argument to a value of type Object according to Table 12:
383// Table 12: ToObject Conversions
384/*
385|----------------------------------------------------------------------------------------------------------------------------------------------------|
386| Argument Type | Result |
387|----------------------------------------------------------------------------------------------------------------------------------------------------|
388| Undefined | Throw a TypeError exception. |
389| Null | Throw a TypeError exception. |
390| Boolean | Return argument. |
391| Number | Return argument. |
392| String | Return argument. |
393| Symbol | Return argument. |
394| Object | Return argument. |
395|----------------------------------------------------------------------------------------------------------------------------------------------------|
396*/
397function RequireObjectCoercible(argument) { // eslint-disable-line no-unused-vars
398 if (argument === null || argument === undefined) {
399 throw TypeError();
400 }
401 return argument;
402}
403
404// _ESAbstract.SameValueNonNumber
405// 7.2.12. SameValueNonNumber ( x, y )
406function SameValueNonNumber(x, y) { // eslint-disable-line no-unused-vars
407 // 1. Assert: Type(x) is not Number.
408 // 2. Assert: Type(x) is the same as Type(y).
409 // 3. If Type(x) is Undefined, return true.
410 // 4. If Type(x) is Null, return true.
411 // 5. If Type(x) is String, then
412 // 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.
413 // 6. If Type(x) is Boolean, then
414 // a. If x and y are both true or both false, return true; otherwise, return false.
415 // 7. If Type(x) is Symbol, then
416 // a. If x and y are both the same Symbol value, return true; otherwise, return false.
417 // 8. If x and y are the same Object value, return true. Otherwise, return false.
418
419 // Polyfill.io - We can skip all above steps because the === operator does it all for us.
420 return x === y;
421}
422
423// _ESAbstract.ToBoolean
424// 7.1.2. ToBoolean ( argument )
425// The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 9:
426/*
427--------------------------------------------------------------------------------------------------------------
428| Argument Type | Result |
429--------------------------------------------------------------------------------------------------------------
430| Undefined | Return false. |
431| Null | Return false. |
432| Boolean | Return argument. |
433| Number | If argument is +0, -0, or NaN, return false; otherwise return true. |
434| String | If argument is the empty String (its length is zero), return false; otherwise return true. |
435| Symbol | Return true. |
436| Object | Return true. |
437--------------------------------------------------------------------------------------------------------------
438*/
439function ToBoolean(argument) { // eslint-disable-line no-unused-vars
440 return Boolean(argument);
441}
442
443// _ESAbstract.ToInteger
444// 7.1.4. ToInteger ( argument )
445function ToInteger(argument) { // eslint-disable-line no-unused-vars
446 // 1. Let number be ? ToNumber(argument).
447 var number = Number(argument);
448 // 2. If number is NaN, return +0.
449 if (isNaN(number)) {
450 return 0;
451 }
452 // 3. If number is +0, -0, +∞, or -∞, return number.
453 if (1/number === Infinity || 1/number === -Infinity || number === Infinity || number === -Infinity) {
454 return number;
455 }
456 // 4. Return the number value that is the same sign as number and whose magnitude is floor(abs(number)).
457 return ((number < 0) ? -1 : 1) * Math.floor(Math.abs(number));
458}
459
460// _ESAbstract.ToLength
461/* global ToInteger */
462// 7.1.15. ToLength ( argument )
463function ToLength(argument) { // eslint-disable-line no-unused-vars
464 // 1. Let len be ? ToInteger(argument).
465 var len = ToInteger(argument);
466 // 2. If len ≤ +0, return +0.
467 if (len <= 0) {
468 return 0;
469 }
470 // 3. Return min(len, 253-1).
471 return Math.min(len, Math.pow(2, 53) -1);
472}
473
474// _ESAbstract.ToObject
475// 7.1.13 ToObject ( argument )
476// The abstract operation ToObject converts argument to a value of type Object according to Table 12:
477// Table 12: ToObject Conversions
478/*
479|----------------------------------------------------------------------------------------------------------------------------------------------------|
480| Argument Type | Result |
481|----------------------------------------------------------------------------------------------------------------------------------------------------|
482| Undefined | Throw a TypeError exception. |
483| Null | Throw a TypeError exception. |
484| Boolean | Return a new Boolean object whose [[BooleanData]] internal slot is set to argument. See 19.3 for a description of Boolean objects. |
485| Number | Return a new Number object whose [[NumberData]] internal slot is set to argument. See 20.1 for a description of Number objects. |
486| String | Return a new String object whose [[StringData]] internal slot is set to argument. See 21.1 for a description of String objects. |
487| Symbol | Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 19.4 for a description of Symbol objects. |
488| Object | Return argument. |
489|----------------------------------------------------------------------------------------------------------------------------------------------------|
490*/
491function ToObject(argument) { // eslint-disable-line no-unused-vars
492 if (argument === null || argument === undefined) {
493 throw TypeError();
494 }
495 return Object(argument);
496}
497
498// _ESAbstract.GetV
499/* global ToObject */
500// 7.3.2 GetV (V, P)
501function GetV(v, p) { // eslint-disable-line no-unused-vars
502 // 1. Assert: IsPropertyKey(P) is true.
503 // 2. Let O be ? ToObject(V).
504 var o = ToObject(v);
505 // 3. Return ? O.[[Get]](P, V).
506 return o[p];
507}
508
509// _ESAbstract.GetMethod
510/* global GetV, IsCallable */
511// 7.3.9. GetMethod ( V, P )
512function GetMethod(V, P) { // eslint-disable-line no-unused-vars
513 // 1. Assert: IsPropertyKey(P) is true.
514 // 2. Let func be ? GetV(V, P).
515 var func = GetV(V, P);
516 // 3. If func is either undefined or null, return undefined.
517 if (func === null || func === undefined) {
518 return undefined;
519 }
520 // 4. If IsCallable(func) is false, throw a TypeError exception.
521 if (IsCallable(func) === false) {
522 throw new TypeError('Method not callable: ' + P);
523 }
524 // 5. Return func.
525 return func;
526}
527
528// _ESAbstract.Type
529// "Type(x)" is used as shorthand for "the type of x"...
530function Type(x) { // eslint-disable-line no-unused-vars
531 switch (typeof x) {
532 case 'undefined':
533 return 'undefined';
534 case 'boolean':
535 return 'boolean';
536 case 'number':
537 return 'number';
538 case 'string':
539 return 'string';
540 case 'symbol':
541 return 'symbol';
542 default:
543 // typeof null is 'object'
544 if (x === null) return 'null';
545 // Polyfill.io - This is here because a Symbol polyfill will have a typeof `object`.
546 if ('Symbol' in this && x instanceof this.Symbol) return 'symbol';
547 return 'object';
548 }
549}
550
551// _ESAbstract.CreateIterResultObject
552/* global Type, CreateDataProperty */
553// 7.4.7. CreateIterResultObject ( value, done )
554function CreateIterResultObject(value, done) { // eslint-disable-line no-unused-vars
555 // 1. Assert: Type(done) is Boolean.
556 if (Type(done) !== 'boolean') {
557 throw new Error();
558 }
559 // 2. Let obj be ObjectCreate(%ObjectPrototype%).
560 var obj = {};
561 // 3. Perform CreateDataProperty(obj, "value", value).
562 CreateDataProperty(obj, "value", value);
563 // 4. Perform CreateDataProperty(obj, "done", done).
564 CreateDataProperty(obj, "done", done);
565 // 5. Return obj.
566 return obj;
567}
568
569// _ESAbstract.GetIterator
570/* global GetMethod, Symbol, Call, Type, GetV */
571// 7.4.1. GetIterator ( obj [ , method ] )
572// The abstract operation GetIterator with argument obj and optional argument method performs the following steps:
573function GetIterator(obj /*, method */) { // eslint-disable-line no-unused-vars
574 // 1. If method is not present, then
575 // a. Set method to ? GetMethod(obj, @@iterator).
576 var method = arguments.length > 1 ? arguments[1] : GetMethod(obj, Symbol.iterator);
577 // 2. Let iterator be ? Call(method, obj).
578 var iterator = Call(method, obj);
579 // 3. If Type(iterator) is not Object, throw a TypeError exception.
580 if (Type(iterator) !== 'object') {
581 throw new TypeError('bad iterator');
582 }
583 // 4. Let nextMethod be ? GetV(iterator, "next").
584 var nextMethod = GetV(iterator, "next");
585 // 5. Let iteratorRecord be Record {[[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false}.
586 var iteratorRecord = Object.create(null);
587 iteratorRecord['[[Iterator]]'] = iterator;
588 iteratorRecord['[[NextMethod]]'] = nextMethod;
589 iteratorRecord['[[Done]]'] = false;
590 // 6. Return iteratorRecord.
591 return iteratorRecord;
592}
593
594// _ESAbstract.GetPrototypeFromConstructor
595/* global Get, Type */
596// 9.1.14. GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
597function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
598 // 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.
599 // 2. Assert: IsCallable(constructor) is true.
600 // 3. Let proto be ? Get(constructor, "prototype").
601 var proto = Get(constructor, "prototype");
602 // 4. If Type(proto) is not Object, then
603 if (Type(proto) !== 'object') {
604 // a. Let realm be ? GetFunctionRealm(constructor).
605 // b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
606 proto = intrinsicDefaultProto;
607 }
608 // 5. Return proto.
609 return proto;
610}
611
612// _ESAbstract.OrdinaryCreateFromConstructor
613/* global GetPrototypeFromConstructor */
614// 9.1.13. OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
615function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
616 var internalSlotsList = arguments[2] || {};
617 // 1. Assert: intrinsicDefaultProto is a String value that is this specification's name of an intrinsic object.
618 // The corresponding object must be an intrinsic that is intended to be used as the[[Prototype]] value of an object.
619
620 // 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
621 var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto);
622
623 // 3. Return ObjectCreate(proto, internalSlotsList).
624 // 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.
625 var obj = Object.create(proto);
626 for (var name in internalSlotsList) {
627 if (Object.prototype.hasOwnProperty.call(internalSlotsList, name)) {
628 Object.defineProperty(obj, name, {
629 configurable: true,
630 enumerable: false,
631 writable: true,
632 value: internalSlotsList[name]
633 });
634 }
635 }
636 return obj;
637}
638
639// _ESAbstract.IsConstructor
640/* global Type */
641// 7.2.4. IsConstructor ( argument )
642function IsConstructor(argument) { // eslint-disable-line no-unused-vars
643 // 1. If Type(argument) is not Object, return false.
644 if (Type(argument) !== 'object') {
645 return false;
646 }
647 // 2. If argument has a [[Construct]] internal method, return true.
648 // 3. Return false.
649
650 // Polyfill.io - `new argument` is the only way to truly test if a function is a constructor.
651 // We choose to not use`new argument` because the argument could have side effects when called.
652 // Instead we check to see if the argument is a function and if it has a prototype.
653 // Arrow functions do not have a [[Construct]] internal method, nor do they have a prototype.
654 return typeof argument === 'function' && !!argument.prototype;
655}
656
657// _ESAbstract.Construct
658/* global IsConstructor, OrdinaryCreateFromConstructor, Call */
659// 7.3.13. Construct ( F [ , argumentsList [ , newTarget ]] )
660function Construct(F /* [ , argumentsList [ , newTarget ]] */) { // eslint-disable-line no-unused-vars
661 // 1. If newTarget is not present, set newTarget to F.
662 var newTarget = arguments.length > 2 ? arguments[2] : F;
663
664 // 2. If argumentsList is not present, set argumentsList to a new empty List.
665 var argumentsList = arguments.length > 1 ? arguments[1] : [];
666
667 // 3. Assert: IsConstructor(F) is true.
668 if (!IsConstructor(F)) {
669 throw new TypeError('F must be a constructor.');
670 }
671
672 // 4. Assert: IsConstructor(newTarget) is true.
673 if (!IsConstructor(newTarget)) {
674 throw new TypeError('newTarget must be a constructor.');
675 }
676
677 // 5. Return ? F.[[Construct]](argumentsList, newTarget).
678 // Polyfill.io - If newTarget is the same as F, it is equivalent to new F(...argumentsList).
679 if (newTarget === F) {
680 return new (Function.prototype.bind.apply(F, [null].concat(argumentsList)))();
681 } else {
682 // Polyfill.io - This is mimicking section 9.2.2 step 5.a.
683 var obj = OrdinaryCreateFromConstructor(newTarget, Object.prototype);
684 return Call(F, obj, argumentsList);
685 }
686}
687
688// _ESAbstract.IsRegExp
689/* global Type, Get, ToBoolean */
690// 7.2.8. IsRegExp ( argument )
691function IsRegExp(argument) { // eslint-disable-line no-unused-vars
692 // 1. If Type(argument) is not Object, return false.
693 if (Type(argument) !== 'object') {
694 return false;
695 }
696 // 2. Let matcher be ? Get(argument, @@match).
697 var matcher = 'Symbol' in this && 'match' in this.Symbol ? Get(argument, this.Symbol.match) : undefined;
698 // 3. If matcher is not undefined, return ToBoolean(matcher).
699 if (matcher !== undefined) {
700 return ToBoolean(matcher);
701 }
702 // 4. If argument has a [[RegExpMatcher]] internal slot, return true.
703 try {
704 var lastIndex = argument.lastIndex;
705 argument.lastIndex = 0;
706 RegExp.prototype.exec.call(argument);
707 return true;
708 } catch (e) {} finally {
709 argument.lastIndex = lastIndex;
710 }
711 // 5. Return false.
712 return false;
713}
714
715// _ESAbstract.IteratorClose
716/* global GetMethod, Type, Call */
717// 7.4.6. IteratorClose ( iteratorRecord, completion )
718function IteratorClose(iteratorRecord, completion) { // eslint-disable-line no-unused-vars
719 // 1. Assert: Type(iteratorRecord.[[Iterator]]) is Object.
720 if (Type(iteratorRecord['[[Iterator]]']) !== 'object') {
721 throw new Error(Object.prototype.toString.call(iteratorRecord['[[Iterator]]']) + 'is not an Object.');
722 }
723 // 2. Assert: completion is a Completion Record.
724 // Polyfill.io - Ignoring this step as there is no way to check if something is a Completion Record in userland JavaScript.
725
726 // 3. Let iterator be iteratorRecord.[[Iterator]].
727 var iterator = iteratorRecord['[[Iterator]]'];
728 // 4. Let return be ? GetMethod(iterator, "return").
729 // 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).
730 var returnMethod = GetMethod(iterator, "return");
731 // 5. If return is undefined, return Completion(completion).
732 if (returnMethod === undefined) {
733 return completion;
734 }
735 // 6. Let innerResult be Call(return, iterator, « »).
736 try {
737 var innerResult = Call(returnMethod, iterator);
738 } catch (error) {
739 var innerException = error;
740 }
741 // 7. If completion.[[Type]] is throw, return Completion(completion).
742 if (completion) {
743 return completion;
744 }
745 // 8. If innerResult.[[Type]] is throw, return Completion(innerResult).
746 if (innerException) {
747 throw innerException;
748 }
749 // 9. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
750 if (Type(innerResult) !== 'object') {
751 throw new TypeError("Iterator's return method returned a non-object.");
752 }
753 // 10. Return Completion(completion).
754 return completion;
755}
756
757// _ESAbstract.IteratorComplete
758/* global Type, ToBoolean, Get */
759// 7.4.3 IteratorComplete ( iterResult )
760function IteratorComplete(iterResult) { // eslint-disable-line no-unused-vars
761 // 1. Assert: Type(iterResult) is Object.
762 if (Type(iterResult) !== 'object') {
763 throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
764 }
765 // 2. Return ToBoolean(? Get(iterResult, "done")).
766 return ToBoolean(Get(iterResult, "done"));
767}
768
769// _ESAbstract.IteratorNext
770/* global Call, Type */
771// 7.4.2. IteratorNext ( iteratorRecord [ , value ] )
772function IteratorNext(iteratorRecord /* [, value] */) { // eslint-disable-line no-unused-vars
773 // 1. If value is not present, then
774 if (arguments.length < 2) {
775 // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « »).
776 var result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']);
777 // 2. Else,
778 } else {
779 // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « value »).
780 result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]);
781 }
782 // 3. If Type(result) is not Object, throw a TypeError exception.
783 if (Type(result) !== 'object') {
784 throw new TypeError('bad iterator');
785 }
786 // 4. Return result.
787 return result;
788}
789
790// _ESAbstract.IteratorStep
791/* global IteratorNext, IteratorComplete */
792// 7.4.5. IteratorStep ( iteratorRecord )
793function IteratorStep(iteratorRecord) { // eslint-disable-line no-unused-vars
794 // 1. Let result be ? IteratorNext(iteratorRecord).
795 var result = IteratorNext(iteratorRecord);
796 // 2. Let done be ? IteratorComplete(result).
797 var done = IteratorComplete(result);
798 // 3. If done is true, return false.
799 if (done === true) {
800 return false;
801 }
802 // 4. Return result.
803 return result;
804}
805
806// _ESAbstract.IteratorValue
807/* global Type, Get */
808// 7.4.4 IteratorValue ( iterResult )
809function IteratorValue(iterResult) { // eslint-disable-line no-unused-vars
810 // Assert: Type(iterResult) is Object.
811 if (Type(iterResult) !== 'object') {
812 throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
813 }
814 // Return ? Get(iterResult, "value").
815 return Get(iterResult, "value");
816}
817
818// _ESAbstract.OrdinaryToPrimitive
819/* global Get, IsCallable, Call, Type */
820// 7.1.1.1. OrdinaryToPrimitive ( O, hint )
821function OrdinaryToPrimitive(O, hint) { // eslint-disable-line no-unused-vars
822 // 1. Assert: Type(O) is Object.
823 // 2. Assert: Type(hint) is String and its value is either "string" or "number".
824 // 3. If hint is "string", then
825 if (hint === 'string') {
826 // a. Let methodNames be « "toString", "valueOf" ».
827 var methodNames = ['toString', 'valueOf'];
828 // 4. Else,
829 } else {
830 // a. Let methodNames be « "valueOf", "toString" ».
831 methodNames = ['valueOf', 'toString'];
832 }
833 // 5. For each name in methodNames in List order, do
834 for (var i = 0; i < methodNames.length; ++i) {
835 var name = methodNames[i];
836 // a. Let method be ? Get(O, name).
837 var method = Get(O, name);
838 // b. If IsCallable(method) is true, then
839 if (IsCallable(method)) {
840 // i. Let result be ? Call(method, O).
841 var result = Call(method, O);
842 // ii. If Type(result) is not Object, return result.
843 if (Type(result) !== 'object') {
844 return result;
845 }
846 }
847 }
848 // 6. Throw a TypeError exception.
849 throw new TypeError('Cannot convert to primitive.');
850}
851
852// _ESAbstract.SameValueZero
853/* global Type, SameValueNonNumber */
854// 7.2.11. SameValueZero ( x, y )
855function SameValueZero (x, y) { // eslint-disable-line no-unused-vars
856 // 1. If Type(x) is different from Type(y), return false.
857 if (Type(x) !== Type(y)) {
858 return false;
859 }
860 // 2. If Type(x) is Number, then
861 if (Type(x) === 'number') {
862 // a. If x is NaN and y is NaN, return true.
863 if (isNaN(x) && isNaN(y)) {
864 return true;
865 }
866 // b. If x is +0 and y is -0, return true.
867 if (1/x === Infinity && 1/y === -Infinity) {
868 return true;
869 }
870 // c. If x is -0 and y is +0, return true.
871 if (1/x === -Infinity && 1/y === Infinity) {
872 return true;
873 }
874 // d. If x is the same Number value as y, return true.
875 if (x === y) {
876 return true;
877 }
878 // e. Return false.
879 return false;
880 }
881 // 3. Return SameValueNonNumber(x, y).
882 return SameValueNonNumber(x, y);
883}
884
885// _ESAbstract.ToPrimitive
886/* global Type, GetMethod, Call, OrdinaryToPrimitive */
887// 7.1.1. ToPrimitive ( input [ , PreferredType ] )
888function ToPrimitive(input /* [, PreferredType] */) { // eslint-disable-line no-unused-vars
889 var PreferredType = arguments.length > 1 ? arguments[1] : undefined;
890 // 1. Assert: input is an ECMAScript language value.
891 // 2. If Type(input) is Object, then
892 if (Type(input) === 'object') {
893 // a. If PreferredType is not present, let hint be "default".
894 if (arguments.length < 2) {
895 var hint = 'default';
896 // b. Else if PreferredType is hint String, let hint be "string".
897 } else if (PreferredType === String) {
898 hint = 'string';
899 // c. Else PreferredType is hint Number, let hint be "number".
900 } else if (PreferredType === Number) {
901 hint = 'number';
902 }
903 // d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
904 var exoticToPrim = typeof this.Symbol === 'function' && typeof this.Symbol.toPrimitive === 'symbol' ? GetMethod(input, this.Symbol.toPrimitive) : undefined;
905 // e. If exoticToPrim is not undefined, then
906 if (exoticToPrim !== undefined) {
907 // i. Let result be ? Call(exoticToPrim, input, « hint »).
908 var result = Call(exoticToPrim, input, [hint]);
909 // ii. If Type(result) is not Object, return result.
910 if (Type(result) !== 'object') {
911 return result;
912 }
913 // iii. Throw a TypeError exception.
914 throw new TypeError('Cannot convert exotic object to primitive.');
915 }
916 // f. If hint is "default", set hint to "number".
917 if (hint === 'default') {
918 hint = 'number';
919 }
920 // g. Return ? OrdinaryToPrimitive(input, hint).
921 return OrdinaryToPrimitive(input, hint);
922 }
923 // 3. Return input
924 return input;
925}
926
927// _ESAbstract.ToString
928/* global Type, ToPrimitive */
929// 7.1.12. ToString ( argument )
930// The abstract operation ToString converts argument to a value of type String according to Table 11:
931// Table 11: ToString Conversions
932/*
933|---------------|--------------------------------------------------------|
934| Argument Type | Result |
935|---------------|--------------------------------------------------------|
936| Undefined | Return "undefined". |
937|---------------|--------------------------------------------------------|
938| Null | Return "null". |
939|---------------|--------------------------------------------------------|
940| Boolean | If argument is true, return "true". |
941| | If argument is false, return "false". |
942|---------------|--------------------------------------------------------|
943| Number | Return NumberToString(argument). |
944|---------------|--------------------------------------------------------|
945| String | Return argument. |
946|---------------|--------------------------------------------------------|
947| Symbol | Throw a TypeError exception. |
948|---------------|--------------------------------------------------------|
949| Object | Apply the following steps: |
950| | Let primValue be ? ToPrimitive(argument, hint String). |
951| | Return ? ToString(primValue). |
952|---------------|--------------------------------------------------------|
953*/
954function ToString(argument) { // eslint-disable-line no-unused-vars
955 switch(Type(argument)) {
956 case 'symbol':
957 throw new TypeError('Cannot convert a Symbol value to a string');
958 break;
959 case 'object':
960 var primValue = ToPrimitive(argument, 'string');
961 return ToString(primValue);
962 default:
963 return String(argument);
964 }
965}
966
967// _mutation
968var _mutation = (function () { // eslint-disable-line no-unused-vars
969
970 function isNode(object) {
971 // DOM, Level2
972 if (typeof Node === 'function') {
973 return object instanceof Node;
974 }
975 // Older browsers, check if it looks like a Node instance)
976 return object &&
977 typeof object === "object" &&
978 object.nodeName &&
979 object.nodeType >= 1 &&
980 object.nodeType <= 12;
981 }
982
983 // http://dom.spec.whatwg.org/#mutation-method-macro
984 return function mutation(nodes) {
985 if (nodes.length === 1) {
986 return isNode(nodes[0]) ? nodes[0] : document.createTextNode(nodes[0] + '');
987 }
988
989 var fragment = document.createDocumentFragment();
990 for (var i = 0; i < nodes.length; i++) {
991 fragment.appendChild(isNode(nodes[i]) ? nodes[i] : document.createTextNode(nodes[i] + ''));
992
993 }
994 return fragment;
995 };
996}());
997
998// Array.of
999/* global ArrayCreate, Construct, CreateDataPropertyOrThrow, CreateMethodProperty, IsConstructor, ToString */
1000// 22.1.2.3. Array.of ( ...items )
1001CreateMethodProperty(Array, 'of', function of() {
1002 // 1. Let len be the actual number of arguments passed to this function.
1003 var len = arguments.length;
1004 // 2. Let items be the List of arguments passed to this function.
1005 var items = arguments;
1006 // 3. Let C be the this value.
1007 var C = this;
1008 // 4. If IsConstructor(C) is true, then
1009 if (IsConstructor(C)) {
1010 // a. Let A be ? Construct(C, « len »).
1011 var A = Construct(C, [len]);
1012 // 5. Else,
1013 } else {
1014 // a. Let A be ? ArrayCreate(len).
1015 var A = ArrayCreate(len);
1016 }
1017 // 6. Let k be 0.
1018 var k = 0;
1019 // 7. Repeat, while k < len
1020 while (k < len) {
1021 // a. Let kValue be items[k].
1022 var kValue = items[k];
1023 // b. Let Pk be ! ToString(k).
1024 var Pk = ToString(k);
1025 // c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue).
1026 CreateDataPropertyOrThrow(A, Pk, kValue);
1027 // d. Increase k by 1.
1028 var k = k + 1;
1029
1030 }
1031 // 8. Perform ? Set(A, "length", len, true)
1032 A["length"] = len;
1033 // 9. Return A.
1034 return A;
1035});
1036
1037// Array.prototype.fill
1038/* global CreateMethodProperty, Get, ToInteger, ToLength, ToObject, ToString */
1039// 22.1.3.6. Array.prototype.fill ( value [ , start [ , end ] ] )
1040CreateMethodProperty(Array.prototype, 'fill', function fill(value /* [ , start [ , end ] ] */) {
1041 var start = arguments[1];
1042 var end = arguments[2];
1043 // 1. Let O be ? ToObject(this value).
1044 var O = ToObject(this);
1045 // 2. Let len be ? ToLength(? Get(O, "length")).
1046 var len = ToLength(Get(O, "length"));
1047 // 3. Let relativeStart be ? ToInteger(start).
1048 var relativeStart = ToInteger(start);
1049 // 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be min(relativeStart, len)
1050 var k = relativeStart < 0 ? Math.max((len + relativeStart), 0) : Math.min(relativeStart, len);
1051 // 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
1052 var relativeEnd = end === undefined ? len : ToInteger(end);
1053 // 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
1054 var final = relativeEnd < 0 ? Math.max((len + relativeEnd), 0) : Math.min(relativeEnd, len);
1055 // 7. Repeat, while k < final
1056 while (k < final) {
1057 // a. Let Pk be ! ToString(k).
1058 var Pk = ToString(k);
1059 // b. Perform ? Set(O, Pk, value, true).
1060 O[Pk] = value;
1061 // c. Increase k by 1.
1062 k = k + 1;
1063 }
1064 // 8. Return O.
1065 return O;
1066});
1067
1068// DocumentFragment.prototype.append
1069DocumentFragment.prototype.append = function append() {
1070 this.appendChild(_mutation(arguments));
1071};
1072
1073// DocumentFragment.prototype.prepend
1074DocumentFragment.prototype.prepend = function prepend() {
1075 this.insertBefore(_mutation(arguments), this.firstChild);
1076};
1077
1078// DOMTokenList
1079(function (global) {
1080 var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
1081
1082 if (
1083 !nativeImpl ||
1084 (
1085 !!document.createElementNS &&
1086 !!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
1087 !(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
1088 )
1089 ) {
1090 global.DOMTokenList = _DOMTokenList;
1091 }
1092
1093 // Add second argument to native DOMTokenList.toggle() if necessary
1094 (function () {
1095 var e = document.createElement('span');
1096 if (!('classList' in e)) return;
1097 e.classList.toggle('x', false);
1098 if (!e.classList.contains('x')) return;
1099 e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
1100 var force = arguments[1];
1101 if (force === undefined) {
1102 var add = !this.contains(token);
1103 this[add ? 'add' : 'remove'](token);
1104 return add;
1105 }
1106 force = !!force;
1107 this[force ? 'add' : 'remove'](token);
1108 return force;
1109 };
1110 }());
1111
1112 // Add multiple arguments to native DOMTokenList.add() if necessary
1113 (function () {
1114 var e = document.createElement('span');
1115 if (!('classList' in e)) return;
1116 e.classList.add('a', 'b');
1117 if (e.classList.contains('b')) return;
1118 var native = e.classList.constructor.prototype.add;
1119 e.classList.constructor.prototype.add = function () {
1120 var args = arguments;
1121 var l = arguments.length;
1122 for (var i = 0; i < l; i++) {
1123 native.call(this, args[i]);
1124 }
1125 };
1126 }());
1127
1128 // Add multiple arguments to native DOMTokenList.remove() if necessary
1129 (function () {
1130 var e = document.createElement('span');
1131 if (!('classList' in e)) return;
1132 e.classList.add('a');
1133 e.classList.add('b');
1134 e.classList.remove('a', 'b');
1135 if (!e.classList.contains('b')) return;
1136 var native = e.classList.constructor.prototype.remove;
1137 e.classList.constructor.prototype.remove = function () {
1138 var args = arguments;
1139 var l = arguments.length;
1140 for (var i = 0; i < l; i++) {
1141 native.call(this, args[i]);
1142 }
1143 };
1144 }());
1145
1146}(this));
1147
1148// Element.prototype.after
1149Document.prototype.after = Element.prototype.after = function after() {
1150 if (this.parentNode) {
1151 var args = Array.prototype.slice.call(arguments),
1152 viableNextSibling = this.nextSibling,
1153 idx = viableNextSibling ? args.indexOf(viableNextSibling) : -1;
1154
1155 while (idx !== -1) {
1156 viableNextSibling = viableNextSibling.nextSibling;
1157 if (!viableNextSibling) {
1158 break;
1159 }
1160 idx = args.indexOf(viableNextSibling);
1161 }
1162
1163 this.parentNode.insertBefore(_mutation(arguments), viableNextSibling);
1164 }
1165};
1166
1167// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
1168// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
1169if ("Text" in this) {
1170 Text.prototype.after = Element.prototype.after;
1171}
1172
1173// Element.prototype.append
1174Document.prototype.append = Element.prototype.append = function append() {
1175 this.appendChild(_mutation(arguments));
1176};
1177
1178// Element.prototype.before
1179Document.prototype.before = Element.prototype.before = function before() {
1180 if (this.parentNode) {
1181 var args = Array.prototype.slice.call(arguments),
1182 viablePreviousSibling = this.previousSibling,
1183 idx = viablePreviousSibling ? args.indexOf(viablePreviousSibling) : -1;
1184
1185 while (idx !== -1) {
1186 viablePreviousSibling = viablePreviousSibling.previousSibling;
1187 if (!viablePreviousSibling) {
1188 break;
1189 }
1190 idx = args.indexOf(viablePreviousSibling);
1191 }
1192
1193 this.parentNode.insertBefore(
1194 _mutation(arguments),
1195 viablePreviousSibling ? viablePreviousSibling.nextSibling : this.parentNode.firstChild
1196 );
1197 }
1198};
1199
1200// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
1201// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
1202if ("Text" in this) {
1203 Text.prototype.before = Element.prototype.before;
1204}
1205
1206// Element.prototype.classList
1207/*
1208Copyright (c) 2016, John Gardner
1209
1210Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
1211
1212THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1213*/
1214(function (global) {
1215 var dpSupport = true;
1216 var defineGetter = function (object, name, fn, configurable) {
1217 if (Object.defineProperty)
1218 Object.defineProperty(object, name, {
1219 configurable: false === dpSupport ? true : !!configurable,
1220 get: fn
1221 });
1222
1223 else object.__defineGetter__(name, fn);
1224 };
1225 /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
1226 try {
1227 defineGetter({}, "support");
1228 }
1229 catch (e) {
1230 dpSupport = false;
1231 }
1232 /** Polyfills a property with a DOMTokenList */
1233 var addProp = function (o, name, attr) {
1234
1235 defineGetter(o.prototype, name, function () {
1236 var tokenList;
1237
1238 var THIS = this,
1239
1240 /** Prevent this from firing twice for some reason. What the hell, IE. */
1241 gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
1242 if(THIS[gibberishProperty]) return tokenList;
1243 THIS[gibberishProperty] = true;
1244
1245 /**
1246 * IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
1247 *
1248 * What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
1249 * that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
1250 * element instead, this would conflict with element types which use indexed properties (such as forms and
1251 * select lists).
1252 */
1253 if (false === dpSupport) {
1254
1255 var visage;
1256 var mirror = addProp.mirror || document.createElement("div");
1257 var reflections = mirror.childNodes;
1258 var l = reflections.length;
1259
1260 for (var i = 0; i < l; ++i)
1261 if (reflections[i]._R === THIS) {
1262 visage = reflections[i];
1263 break;
1264 }
1265
1266 /** Couldn't find an element's reflection inside the mirror. Materialise one. */
1267 visage || (visage = mirror.appendChild(document.createElement("div")));
1268
1269 tokenList = DOMTokenList.call(visage, THIS, attr);
1270 } else tokenList = new DOMTokenList(THIS, attr);
1271
1272 defineGetter(THIS, name, function () {
1273 return tokenList;
1274 });
1275 delete THIS[gibberishProperty];
1276
1277 return tokenList;
1278 }, true);
1279 };
1280
1281 addProp(global.Element, "classList", "className");
1282 addProp(global.HTMLElement, "classList", "className");
1283 addProp(global.HTMLLinkElement, "relList", "rel");
1284 addProp(global.HTMLAnchorElement, "relList", "rel");
1285 addProp(global.HTMLAreaElement, "relList", "rel");
1286}(this));
1287
1288// Element.prototype.matches
1289Element.prototype.matches = Element.prototype.webkitMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || function matches(selector) {
1290
1291 var element = this;
1292 var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
1293 var index = 0;
1294
1295 while (elements[index] && elements[index] !== element) {
1296 ++index;
1297 }
1298
1299 return !!elements[index];
1300};
1301
1302// Element.prototype.closest
1303Element.prototype.closest = function closest(selector) {
1304 var node = this;
1305
1306 while (node) {
1307 if (node.matches(selector)) return node;
1308 else node = 'SVGElement' in window && node instanceof SVGElement ? node.parentNode : node.parentElement;
1309 }
1310
1311 return null;
1312};
1313
1314// Element.prototype.prepend
1315Document.prototype.prepend = Element.prototype.prepend = function prepend() {
1316 this.insertBefore(_mutation(arguments), this.firstChild);
1317};
1318
1319// Element.prototype.remove
1320Document.prototype.remove = Element.prototype.remove = function remove() {
1321 if (this.parentNode) {
1322 this.parentNode.removeChild(this);
1323 }
1324};
1325
1326// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
1327// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
1328if ("Text" in this) {
1329 Text.prototype.remove = Element.prototype.remove;
1330}
1331
1332// Element.prototype.replaceWith
1333Document.prototype.replaceWith = Element.prototype.replaceWith = function replaceWith() {
1334 if (this.parentNode) {
1335 this.parentNode.replaceChild(_mutation(arguments), this);
1336 }
1337};
1338
1339// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
1340// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
1341if ('Text' in this) {
1342 Text.prototype.replaceWith = Element.prototype.replaceWith;
1343}
1344
1345// Event
1346(function () {
1347 var unlistenableWindowEvents = {
1348 click: 1,
1349 dblclick: 1,
1350 keyup: 1,
1351 keypress: 1,
1352 keydown: 1,
1353 mousedown: 1,
1354 mouseup: 1,
1355 mousemove: 1,
1356 mouseover: 1,
1357 mouseenter: 1,
1358 mouseleave: 1,
1359 mouseout: 1,
1360 storage: 1,
1361 storagecommit: 1,
1362 textinput: 1
1363 };
1364
1365 // This polyfill depends on availability of `document` so will not run in a worker
1366 // However, we asssume there are no browsers with worker support that lack proper
1367 // support for `Event` within the worker
1368 if (typeof document === 'undefined' || typeof window === 'undefined') return;
1369
1370 function indexOf(array, element) {
1371 var
1372 index = -1,
1373 length = array.length;
1374
1375 while (++index < length) {
1376 if (index in array && array[index] === element) {
1377 return index;
1378 }
1379 }
1380
1381 return -1;
1382 }
1383
1384 var existingProto = (window.Event && window.Event.prototype) || null;
1385 function Event(type, eventInitDict) {
1386 if (!type) {
1387 throw new Error('Not enough arguments');
1388 }
1389
1390 var event;
1391 // Shortcut if browser supports createEvent
1392 if ('createEvent' in document) {
1393 event = document.createEvent('Event');
1394 var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
1395 var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
1396
1397 event.initEvent(type, bubbles, cancelable);
1398
1399 return event;
1400 }
1401
1402 event = document.createEventObject();
1403
1404 event.type = type;
1405 event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
1406 event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
1407
1408 return event;
1409 };
1410 Event.NONE = 0;
1411 Event.CAPTURING_PHASE = 1;
1412 Event.AT_TARGET = 2;
1413 Event.BUBBLING_PHASE = 3;
1414 window.Event = Window.prototype.Event = Event;
1415 if (existingProto) {
1416 Object.defineProperty(window.Event, 'prototype', {
1417 configurable: false,
1418 enumerable: false,
1419 writable: true,
1420 value: existingProto
1421 });
1422 }
1423
1424 if (!('createEvent' in document)) {
1425 window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
1426 var
1427 element = this,
1428 type = arguments[0],
1429 listener = arguments[1];
1430
1431 if (element === window && type in unlistenableWindowEvents) {
1432 throw new Error('In IE8 the event: ' + type + ' is not available on the window object. Please see https://github.com/Financial-Times/polyfill-service/issues/317 for more information.');
1433 }
1434
1435 if (!element._events) {
1436 element._events = {};
1437 }
1438
1439 if (!element._events[type]) {
1440 element._events[type] = function (event) {
1441 var
1442 list = element._events[event.type].list,
1443 events = list.slice(),
1444 index = -1,
1445 length = events.length,
1446 eventElement;
1447
1448 event.preventDefault = function preventDefault() {
1449 if (event.cancelable !== false) {
1450 event.returnValue = false;
1451 }
1452 };
1453
1454 event.stopPropagation = function stopPropagation() {
1455 event.cancelBubble = true;
1456 };
1457
1458 event.stopImmediatePropagation = function stopImmediatePropagation() {
1459 event.cancelBubble = true;
1460 event.cancelImmediate = true;
1461 };
1462
1463 event.currentTarget = element;
1464 event.relatedTarget = event.fromElement || null;
1465 event.target = event.target || event.srcElement || element;
1466 event.timeStamp = new Date().getTime();
1467
1468 if (event.clientX) {
1469 event.pageX = event.clientX + document.documentElement.scrollLeft;
1470 event.pageY = event.clientY + document.documentElement.scrollTop;
1471 }
1472
1473 while (++index < length && !event.cancelImmediate) {
1474 if (index in events) {
1475 eventElement = events[index];
1476
1477 if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
1478 eventElement.call(element, event);
1479 }
1480 }
1481 }
1482 };
1483
1484 element._events[type].list = [];
1485
1486 if (element.attachEvent) {
1487 element.attachEvent('on' + type, element._events[type]);
1488 }
1489 }
1490
1491 element._events[type].list.push(listener);
1492 };
1493
1494 window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
1495 var
1496 element = this,
1497 type = arguments[0],
1498 listener = arguments[1],
1499 index;
1500
1501 if (element._events && element._events[type] && element._events[type].list) {
1502 index = indexOf(element._events[type].list, listener);
1503
1504 if (index !== -1) {
1505 element._events[type].list.splice(index, 1);
1506
1507 if (!element._events[type].list.length) {
1508 if (element.detachEvent) {
1509 element.detachEvent('on' + type, element._events[type]);
1510 }
1511 delete element._events[type];
1512 }
1513 }
1514 }
1515 };
1516
1517 window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
1518 if (!arguments.length) {
1519 throw new Error('Not enough arguments');
1520 }
1521
1522 if (!event || typeof event.type !== 'string') {
1523 throw new Error('DOM Events Exception 0');
1524 }
1525
1526 var element = this, type = event.type;
1527
1528 try {
1529 if (!event.bubbles) {
1530 event.cancelBubble = true;
1531
1532 var cancelBubbleEvent = function (event) {
1533 event.cancelBubble = true;
1534
1535 (element || window).detachEvent('on' + type, cancelBubbleEvent);
1536 };
1537
1538 this.attachEvent('on' + type, cancelBubbleEvent);
1539 }
1540
1541 this.fireEvent('on' + type, event);
1542 } catch (error) {
1543 event.target = element;
1544
1545 do {
1546 event.currentTarget = element;
1547
1548 if ('_events' in element && typeof element._events[type] === 'function') {
1549 element._events[type].call(element, event);
1550 }
1551
1552 if (typeof element['on' + type] === 'function') {
1553 element['on' + type].call(element, event);
1554 }
1555
1556 element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
1557 } while (element && !event.cancelBubble);
1558 }
1559
1560 return true;
1561 };
1562
1563 // Add the DOMContentLoaded Event
1564 document.attachEvent('onreadystatechange', function() {
1565 if (document.readyState === 'complete') {
1566 document.dispatchEvent(new Event('DOMContentLoaded', {
1567 bubbles: true
1568 }));
1569 }
1570 });
1571 }
1572}());
1573
1574// CustomEvent
1575this.CustomEvent = function CustomEvent(type, eventInitDict) {
1576 if (!type) {
1577 throw Error('TypeError: Failed to construct "CustomEvent": An event name must be provided.');
1578 }
1579
1580 var event;
1581 eventInitDict = eventInitDict || {bubbles: false, cancelable: false, detail: null};
1582
1583 if ('createEvent' in document) {
1584 try {
1585 event = document.createEvent('CustomEvent');
1586 event.initCustomEvent(type, eventInitDict.bubbles, eventInitDict.cancelable, eventInitDict.detail);
1587 } catch (error) {
1588 // for browsers which don't support CustomEvent at all, we use a regular event instead
1589 event = document.createEvent('Event');
1590 event.initEvent(type, eventInitDict.bubbles, eventInitDict.cancelable);
1591 event.detail = eventInitDict.detail;
1592 }
1593 } else {
1594
1595 // IE8
1596 event = new Event(type, eventInitDict);
1597 event.detail = eventInitDict && eventInitDict.detail || null;
1598 }
1599 return event;
1600};
1601
1602CustomEvent.prototype = Event.prototype;
1603
1604// Node.prototype.contains
1605(function() {
1606
1607 function contains(node) {
1608 if (!(0 in arguments)) {
1609 throw new TypeError('1 argument is required');
1610 }
1611
1612 do {
1613 if (this === node) {
1614 return true;
1615 }
1616 } while (node = node && node.parentNode);
1617
1618 return false;
1619 }
1620
1621 // IE
1622 if ('HTMLElement' in this && 'contains' in HTMLElement.prototype) {
1623 try {
1624 delete HTMLElement.prototype.contains;
1625 } catch (e) {}
1626 }
1627
1628 if ('Node' in this) {
1629 Node.prototype.contains = contains;
1630 } else {
1631 document.contains = Element.prototype.contains = contains;
1632 }
1633
1634}());
1635
1636// Number.isNaN
1637/* global CreateMethodProperty, Type */
1638(function () {
1639 var that = this;
1640 // 20.1.2.4. Number.isNaN ( number )
1641 CreateMethodProperty(Number, 'isNaN', function isNaN(number) {
1642 // 1. If Type(number) is not Number, return false.
1643 if (Type(number) !== 'number') {
1644 return false;
1645 }
1646 // 2. If number is NaN, return true.
1647 if (that.isNaN(number)) {
1648 return true;
1649 }
1650 // 3. Otherwise, return false.
1651 return false;
1652 });
1653}());
1654
1655// Object.assign
1656/* global CreateMethodProperty, Get, ToObject */
1657// 19.1.2.1 Object.assign ( target, ...sources )
1658CreateMethodProperty(Object, 'assign', function assign(target, source) { // eslint-disable-line no-unused-vars
1659 // 1. Let to be ? ToObject(target).
1660 var to = ToObject(target);
1661
1662 // 2. If only one argument was passed, return to.
1663 if (arguments.length === 1) {
1664 return to;
1665 }
1666
1667 // 3. Let sources be the List of argument values starting with the second argument
1668 var sources = Array.prototype.slice.call(arguments, 1);
1669
1670 // 4. For each element nextSource of sources, in ascending index order, do
1671 var index1;
1672 var index2;
1673 var keys;
1674 var from;
1675 for (index1 = 0; index1 < sources.length; index1++) {
1676 var nextSource = sources[index1];
1677 // a. If nextSource is undefined or null, let keys be a new empty List.
1678 if (nextSource === undefined || nextSource === null) {
1679 keys = [];
1680 // b. Else,
1681 } else {
1682 // i. Let from be ! ToObject(nextSource).
1683 from = ToObject(nextSource);
1684 // ii. Let keys be ? from.[[OwnPropertyKeys]]().
1685 /*
1686 This step in our polyfill is not complying with the specification.
1687 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
1688 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
1689 */
1690 keys = Object.keys(from);
1691 }
1692
1693 // c. For each element nextKey of keys in List order, do
1694 for (index2 = 0; index2 < keys.length; index2++) {
1695 var nextKey = keys[index2];
1696 var enumerable;
1697 try {
1698 // i. Let desc be ? from.[[GetOwnProperty]](nextKey).
1699 var desc = Object.getOwnPropertyDescriptor(from, nextKey);
1700 // ii. If desc is not undefined and desc.[[Enumerable]] is true, then
1701 enumerable = desc !== undefined && desc.enumerable === true;
1702 } catch (e) {
1703 // Polyfill.io - We use Object.prototype.propertyIsEnumerable as a fallback
1704 // because `Object.getOwnPropertyDescriptor(window.location, 'hash')` causes Internet Explorer 11 to crash.
1705 enumerable = Object.prototype.propertyIsEnumerable.call(from, nextKey);
1706 }
1707 if (enumerable) {
1708 // 1. Let propValue be ? Get(from, nextKey).
1709 var propValue = Get(from, nextKey);
1710 // 2. Perform ? Set(to, nextKey, propValue, true).
1711 to[nextKey] = propValue;
1712 }
1713 }
1714 }
1715 // 5. Return to.
1716 return to;
1717});
1718
1719// Promise
1720!function(n){function t(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var e={};t.m=n,t.c=e,t.i=function(n){return n},t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:r})},t.n=function(n){var e=n&&n.__esModule?function(){return n["default"]}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},t.p="",t(t.s=100)}({100:/*!***********************!*\
1721 !*** ./src/global.js ***!
1722 \***********************/
1723function(n,t,e){(function(n){var t=e(/*! ./yaku */5);try{n.Promise=t,window.Promise=t}catch(r){}}).call(t,e(/*! ./../~/webpack/buildin/global.js */2))},2:/*!***********************************!*\
1724 !*** (webpack)/buildin/global.js ***!
1725 \***********************************/
1726function(n,t){var e;e=function(){return this}();try{e=e||Function("return this")()||(0,eval)("this")}catch(r){"object"==typeof window&&(e=window)}n.exports=e},5:/*!*********************!*\
1727 !*** ./src/yaku.js ***!
1728 \*********************/
1729function(n,t,e){(function(t){!function(){"use strict";function e(){return rn[q][B]||D}function r(n){return n&&"object"==typeof n}function o(n){return"function"==typeof n}function i(n,t){return n instanceof t}function u(n){return i(n,M)}function c(n,t,e){if(!t(n))throw h(e)}function f(){try{return R.apply(S,arguments)}catch(n){return nn.e=n,nn}}function s(n,t){return R=n,S=t,f}function a(n,t){function e(){for(var e=0;e<o;)t(r[e],r[e+1]),r[e++]=P,r[e++]=P;o=0,r.length>n&&(r.length=n)}var r=A(n),o=0;return function(n,t){r[o++]=n,r[o++]=t,2===o&&rn.nextTick(e)}}function l(n,t){var e,r,u,c,f=0;if(!n)throw h(Q);var a=n[rn[q][z]];if(o(a))r=a.call(n);else{if(!o(n.next)){if(i(n,A)){for(e=n.length;f<e;)t(n[f],f++);return f}throw h(Q)}r=n}for(;!(u=r.next()).done;)if((c=s(t)(u.value,f++))===nn)throw o(r[G])&&r[G](),c.e;return f}function h(n){return new TypeError(n)}function v(n){return(n?"":V)+(new M).stack}function _(n,t){var e="on"+n.toLowerCase(),r=O[e];H&&H.listeners(n).length?n===Z?H.emit(n,t._v,t):H.emit(n,t):r?r({reason:t._v,promise:t}):rn[n](t._v,t)}function p(n){return n&&n._s}function d(n){if(p(n))return new n(tn);var t,e,r;return t=new n(function(n,o){if(t)throw h();e=n,r=o}),c(e,o),c(r,o),t}function w(n,t){var e=!1;return function(r){e||(e=!0,L&&(n[N]=v(!0)),t===Y?k(n,r):x(n,t,r))}}function y(n,t,e,r){return o(e)&&(t._onFulfilled=e),o(r)&&(n[J]&&_(X,n),t._onRejected=r),L&&(t._p=n),n[n._c++]=t,n._s!==$&&on(n,t),t}function m(n){if(n._umark)return!0;n._umark=!0;for(var t,e=0,r=n._c;e<r;)if(t=n[e++],t._onRejected||m(t))return!0}function j(n,t){function e(n){return r.push(n.replace(/^\s+|\s+$/g,""))}var r=[];return L&&(t[N]&&e(t[N]),function o(n){n&&K in n&&(o(n._next),e(n[K]+""),o(n._p))}(t)),(n&&n.stack?n.stack:n)+("\n"+r.join("\n")).replace(en,"")}function g(n,t){return n(t)}function x(n,t,e){var r=0,o=n._c;if(n._s===$)for(n._s=t,n._v=e,t===U&&(L&&u(e)&&(e.longStack=j(e,n)),un(n));r<o;)on(n,n[r++]);return n}function k(n,t){if(t===n&&t)return x(n,U,h(W)),n;if(t!==C&&(o(t)||r(t))){var e=s(b)(t);if(e===nn)return x(n,U,e.e),n;o(e)?(L&&p(t)&&(n._next=t),p(t)?T(n,t,e):rn.nextTick(function(){T(n,t,e)})):x(n,Y,t)}else x(n,Y,t);return n}function b(n){return n.then}function T(n,t,e){var r=s(e,t)(function(e){t&&(t=C,k(n,e))},function(e){t&&(t=C,x(n,U,e))});r===nn&&t&&(x(n,U,r.e),t=C)}var P,R,S,C=null,F="object"==typeof self,O=F?self:t,E=O.Promise,H=O.process,I=O.console,L=!1,A=Array,M=Error,U=1,Y=2,$=3,q="Symbol",z="iterator",B="species",D=q+"("+B+")",G="return",J="_uh",K="_pt",N="_st",Q="Invalid argument",V="\nFrom previous ",W="Chaining cycle detected for promise",X="rejectionHandled",Z="unhandledRejection",nn={e:C},tn=function(){},en=/^.+\/node_modules\/yaku\/.+\n?/gm,rn=function(n){var t,e=this;if(!r(e)||e._s!==P)throw h("Invalid this");if(e._s=$,L&&(e[K]=v()),n!==tn){if(!o(n))throw h(Q);t=s(n)(w(e,Y),w(e,U)),t===nn&&x(e,U,t.e)}};rn["default"]=rn,function(n,t){for(var e in t)n[e]=t[e]}(rn.prototype,{then:function(n,t){if(this._s===undefined)throw h();return y(this,d(rn.speciesConstructor(this,rn)),n,t)},"catch":function(n){return this.then(P,n)},"finally":function(n){return this.then(function(t){return rn.resolve(n()).then(function(){return t})},function(t){return rn.resolve(n()).then(function(){throw t})})},_c:0,_p:C}),rn.resolve=function(n){return p(n)?n:k(d(this),n)},rn.reject=function(n){return x(d(this),U,n)},rn.race=function(n){var t=this,e=d(t),r=function(n){x(e,Y,n)},o=function(n){x(e,U,n)},i=s(l)(n,function(n){t.resolve(n).then(r,o)});return i===nn?t.reject(i.e):e},rn.all=function(n){function t(n){x(o,U,n)}var e,r=this,o=d(r),i=[];return(e=s(l)(n,function(n,u){r.resolve(n).then(function(n){i[u]=n,--e||x(o,Y,i)},t)}))===nn?r.reject(e.e):(e||x(o,Y,[]),o)},rn.Symbol=O[q]||{},s(function(){Object.defineProperty(rn,e(),{get:function(){return this}})})(),rn.speciesConstructor=function(n,t){var r=n.constructor;return r?r[e()]||t:t},rn.unhandledRejection=function(n,t){I&&I.error("Uncaught (in promise)",L?t.longStack:j(n,t))},rn.rejectionHandled=tn,rn.enableLongStackTrace=function(){L=!0},rn.nextTick=F?function(n){E?new E(function(n){n()}).then(n):setTimeout(n)}:H.nextTick,rn._s=1;var on=a(999,function(n,t){var e,r;return(r=n._s!==U?t._onFulfilled:t._onRejected)===P?void x(t,n._s,n._v):(e=s(g)(r,n._v))===nn?void x(t,U,e.e):void k(t,e)}),un=a(9,function(n){m(n)||(n[J]=1,_(Z,n))});try{n.exports=rn}catch(cn){O.Yaku=rn}}()}).call(t,e(/*! ./../~/webpack/buildin/global.js */2))}});
1730// String.prototype.endsWith
1731/* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
1732// 21.1.3.6. String.prototype.endsWith ( searchString [ , endPosition ] )
1733CreateMethodProperty(String.prototype, 'endsWith', function endsWith(searchString /* [ , endPosition ] */) {
1734 'use strict';
1735 var endPosition = arguments.length > 1 ? arguments[1] : undefined;
1736 // 1. Let O be ? RequireObjectCoercible(this value).
1737 var O = RequireObjectCoercible(this);
1738 // 2. Let S be ? ToString(O).
1739 var S = ToString(O);
1740 // 3. Let isRegExp be ? IsRegExp(searchString).
1741 var isRegExp = IsRegExp(searchString);
1742 // 4. If isRegExp is true, throw a TypeError exception.
1743 if (isRegExp) {
1744 throw new TypeError('First argument to String.prototype.endsWith must not be a regular expression');
1745 }
1746 // 5. Let searchStr be ? ToString(searchString).
1747 var searchStr = ToString(searchString);
1748 // 6. Let len be the length of S.
1749 var len = S.length;
1750 // 7. If endPosition is undefined, let pos be len, else let pos be ? ToInteger(endPosition).
1751 var pos = endPosition === undefined ? len : ToInteger(endPosition);
1752 // 8. Let end be min(max(pos, 0), len).
1753 var end = Math.min(Math.max(pos, 0), len);
1754 // 9. Let searchLength be the length of searchStr.
1755 var searchLength = searchStr.length;
1756 // 10. Let start be end - searchLength.
1757 var start = end - searchLength;
1758 // 11. If start is less than 0, return false.
1759 if (start < 0) {
1760 return false;
1761 }
1762 // 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.
1763 if (S.substr(start, searchLength) === searchStr) {
1764 return true;
1765 }
1766 // 13. Otherwise, return false.
1767 return false;
1768});
1769
1770// String.prototype.includes
1771/* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
1772// 21.1.3.7. String.prototype.includes ( searchString [ , position ] )
1773CreateMethodProperty(String.prototype, 'includes', function includes(searchString /* [ , position ] */) {
1774 'use strict';
1775 var position = arguments.length > 1 ? arguments[1] : undefined;
1776 // 1. Let O be ? RequireObjectCoercible(this value).
1777 var O = RequireObjectCoercible(this);
1778 // 2. Let S be ? ToString(O).
1779 var S = ToString(O);
1780 // 3. Let isRegExp be ? IsRegExp(searchString).
1781 var isRegExp = IsRegExp(searchString);
1782 // 4. If isRegExp is true, throw a TypeError exception.
1783 if (isRegExp) {
1784 throw new TypeError('First argument to String.prototype.includes must not be a regular expression');
1785 }
1786 // 5. Let searchStr be ? ToString(searchString).
1787 var searchStr = ToString(searchString);
1788 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
1789 var pos = ToInteger(position);
1790 // 7. Let len be the length of S.
1791 var len = S.length;
1792 // 8. Let start be min(max(pos, 0), len).
1793 var start = Math.min(Math.max(pos, 0), len);
1794 // 9. Let searchLen be the length of searchStr.
1795 // var searchLength = searchStr.length;
1796 // 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.
1797 return String.prototype.indexOf.call(S, searchStr, start) !== -1;
1798});
1799
1800// String.prototype.startsWith
1801/* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
1802// 21.1.3.20. String.prototype.startsWith ( searchString [ , position ] )
1803CreateMethodProperty(String.prototype, 'startsWith', function startsWith(searchString /* [ , position ] */) {
1804 'use strict';
1805 var position = arguments.length > 1 ? arguments[1] : undefined;
1806 // 1. Let O be ? RequireObjectCoercible(this value).
1807 var O = RequireObjectCoercible(this);
1808 // 2. Let S be ? ToString(O).
1809 var S = ToString(O);
1810 // 3. Let isRegExp be ? IsRegExp(searchString).
1811 var isRegExp = IsRegExp(searchString);
1812 // 4. If isRegExp is true, throw a TypeError exception.
1813 if (isRegExp) {
1814 throw new TypeError('First argument to String.prototype.startsWith must not be a regular expression');
1815 }
1816 // 5. Let searchStr be ? ToString(searchString).
1817 var searchStr = ToString(searchString);
1818 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
1819 var pos = ToInteger(position);
1820 // 7. Let len be the length of S.
1821 var len = S.length;
1822 // 8. Let start be min(max(pos, 0), len).
1823 var start = Math.min(Math.max(pos, 0), len);
1824 // 9. Let searchLength be the length of searchStr.
1825 var searchLength = searchStr.length;
1826 // 10. If searchLength+start is greater than len, return false.
1827 if (searchLength + start > len) {
1828 return false;
1829 }
1830 // 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.
1831 if (S.substr(start).indexOf(searchString) === 0) {
1832 return true;
1833 }
1834 // 12. Otherwise, return false.
1835 return false;
1836});
1837
1838// Symbol
1839// A modification of https://github.com/WebReflection/get-own-property-symbols
1840// (C) Andrea Giammarchi - MIT Licensed
1841
1842(function (Object, GOPS, global) {
1843
1844 var setDescriptor;
1845 var id = 0;
1846 var random = '' + Math.random();
1847 var prefix = '__\x01symbol:';
1848 var prefixLength = prefix.length;
1849 var internalSymbol = '__\x01symbol@@' + random;
1850 var DP = 'defineProperty';
1851 var DPies = 'defineProperties';
1852 var GOPN = 'getOwnPropertyNames';
1853 var GOPD = 'getOwnPropertyDescriptor';
1854 var PIE = 'propertyIsEnumerable';
1855 var ObjectProto = Object.prototype;
1856 var hOP = ObjectProto.hasOwnProperty;
1857 var pIE = ObjectProto[PIE];
1858 var toString = ObjectProto.toString;
1859 var concat = Array.prototype.concat;
1860 var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : [];
1861 var nGOPN = Object[GOPN];
1862 var gOPN = function getOwnPropertyNames (obj) {
1863 if (toString.call(obj) === '[object Window]') {
1864 try {
1865 return nGOPN(obj);
1866 } catch (e) {
1867 // IE bug where layout engine calls userland gOPN for cross-domain `window` objects
1868 return concat.call([], cachedWindowNames);
1869 }
1870 }
1871 return nGOPN(obj);
1872 };
1873 var gOPD = Object[GOPD];
1874 var create = Object.create;
1875 var keys = Object.keys;
1876 var freeze = Object.freeze || Object;
1877 var defineProperty = Object[DP];
1878 var $defineProperties = Object[DPies];
1879 var descriptor = gOPD(Object, GOPN);
1880 var addInternalIfNeeded = function (o, uid, enumerable) {
1881 if (!hOP.call(o, internalSymbol)) {
1882 try {
1883 defineProperty(o, internalSymbol, {
1884 enumerable: false,
1885 configurable: false,
1886 writable: false,
1887 value: {}
1888 });
1889 } catch (e) {
1890 o[internalSymbol] = {};
1891 }
1892 }
1893 o[internalSymbol]['@@' + uid] = enumerable;
1894 };
1895 var createWithSymbols = function (proto, descriptors) {
1896 var self = create(proto);
1897 gOPN(descriptors).forEach(function (key) {
1898 if (propertyIsEnumerable.call(descriptors, key)) {
1899 $defineProperty(self, key, descriptors[key]);
1900 }
1901 });
1902 return self;
1903 };
1904 var copyAsNonEnumerable = function (descriptor) {
1905 var newDescriptor = create(descriptor);
1906 newDescriptor.enumerable = false;
1907 return newDescriptor;
1908 };
1909 var get = function get(){};
1910 var onlyNonSymbols = function (name) {
1911 return name != internalSymbol &&
1912 !hOP.call(source, name);
1913 };
1914 var onlySymbols = function (name) {
1915 return name != internalSymbol &&
1916 hOP.call(source, name);
1917 };
1918 var propertyIsEnumerable = function propertyIsEnumerable(key) {
1919 var uid = '' + key;
1920 return onlySymbols(uid) ? (
1921 hOP.call(this, uid) &&
1922 this[internalSymbol]['@@' + uid]
1923 ) : pIE.call(this, key);
1924 };
1925 var setAndGetSymbol = function (uid) {
1926 var descriptor = {
1927 enumerable: false,
1928 configurable: true,
1929 get: get,
1930 set: function (value) {
1931 setDescriptor(this, uid, {
1932 enumerable: false,
1933 configurable: true,
1934 writable: true,
1935 value: value
1936 });
1937 addInternalIfNeeded(this, uid, true);
1938 }
1939 };
1940 try {
1941 defineProperty(ObjectProto, uid, descriptor);
1942 } catch (e) {
1943 ObjectProto[uid] = descriptor.value;
1944 }
1945 return freeze(source[uid] = defineProperty(
1946 Object(uid),
1947 'constructor',
1948 sourceConstructor
1949 ));
1950 };
1951 var Symbol = function Symbol() {
1952 var description = arguments[0];
1953 if (this instanceof Symbol) {
1954 throw new TypeError('Symbol is not a constructor');
1955 }
1956 return setAndGetSymbol(
1957 prefix.concat(description || '', random, ++id)
1958 );
1959 };
1960 var source = create(null);
1961 var sourceConstructor = {value: Symbol};
1962 var sourceMap = function (uid) {
1963 return source[uid];
1964 };
1965 var $defineProperty = function defineProp(o, key, descriptor) {
1966 var uid = '' + key;
1967 if (onlySymbols(uid)) {
1968 setDescriptor(o, uid, descriptor.enumerable ?
1969 copyAsNonEnumerable(descriptor) : descriptor);
1970 addInternalIfNeeded(o, uid, !!descriptor.enumerable);
1971 } else {
1972 defineProperty(o, key, descriptor);
1973 }
1974 return o;
1975 };
1976
1977 var onlyInternalSymbols = function (obj) {
1978 return function (name) {
1979 return hOP.call(obj, internalSymbol) && hOP.call(obj[internalSymbol], '@@' + name);
1980 };
1981 };
1982 var $getOwnPropertySymbols = function getOwnPropertySymbols(o) {
1983 return gOPN(o).filter(o === ObjectProto ? onlyInternalSymbols(o) : onlySymbols).map(sourceMap);
1984 }
1985 ;
1986
1987 descriptor.value = $defineProperty;
1988 defineProperty(Object, DP, descriptor);
1989
1990 descriptor.value = $getOwnPropertySymbols;
1991 defineProperty(Object, GOPS, descriptor);
1992
1993 descriptor.value = function getOwnPropertyNames(o) {
1994 return gOPN(o).filter(onlyNonSymbols);
1995 };
1996 defineProperty(Object, GOPN, descriptor);
1997
1998 descriptor.value = function defineProperties(o, descriptors) {
1999 var symbols = $getOwnPropertySymbols(descriptors);
2000 if (symbols.length) {
2001 keys(descriptors).concat(symbols).forEach(function (uid) {
2002 if (propertyIsEnumerable.call(descriptors, uid)) {
2003 $defineProperty(o, uid, descriptors[uid]);
2004 }
2005 });
2006 } else {
2007 $defineProperties(o, descriptors);
2008 }
2009 return o;
2010 };
2011 defineProperty(Object, DPies, descriptor);
2012
2013 descriptor.value = propertyIsEnumerable;
2014 defineProperty(ObjectProto, PIE, descriptor);
2015
2016 descriptor.value = Symbol;
2017 defineProperty(global, 'Symbol', descriptor);
2018
2019 // defining `Symbol.for(key)`
2020 descriptor.value = function (key) {
2021 var uid = prefix.concat(prefix, key, random);
2022 return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid);
2023 };
2024 defineProperty(Symbol, 'for', descriptor);
2025
2026 // defining `Symbol.keyFor(symbol)`
2027 descriptor.value = function (symbol) {
2028 if (onlyNonSymbols(symbol))
2029 throw new TypeError(symbol + ' is not a symbol');
2030 return hOP.call(source, symbol) ?
2031 symbol.slice(prefixLength * 2, -random.length) :
2032 void 0
2033 ;
2034 };
2035 defineProperty(Symbol, 'keyFor', descriptor);
2036
2037 descriptor.value = function getOwnPropertyDescriptor(o, key) {
2038 var descriptor = gOPD(o, key);
2039 if (descriptor && onlySymbols(key)) {
2040 descriptor.enumerable = propertyIsEnumerable.call(o, key);
2041 }
2042 return descriptor;
2043 };
2044 defineProperty(Object, GOPD, descriptor);
2045
2046 descriptor.value = function (proto, descriptors) {
2047 return arguments.length === 1 || typeof descriptors === "undefined" ?
2048 create(proto) :
2049 createWithSymbols(proto, descriptors);
2050 };
2051 defineProperty(Object, 'create', descriptor);
2052
2053 descriptor.value = function () {
2054 var str = toString.call(this);
2055 return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
2056 };
2057 defineProperty(ObjectProto, 'toString', descriptor);
2058
2059
2060 setDescriptor = function (o, key, descriptor) {
2061 var protoDescriptor = gOPD(ObjectProto, key);
2062 delete ObjectProto[key];
2063 defineProperty(o, key, descriptor);
2064 if (o !== ObjectProto) {
2065 defineProperty(ObjectProto, key, protoDescriptor);
2066 }
2067 };
2068
2069}(Object, 'getOwnPropertySymbols', this));
2070
2071// Symbol.iterator
2072/* global Symbol */
2073Object.defineProperty(Symbol, 'iterator', { value: Symbol('iterator') });
2074
2075// Symbol.species
2076/* global Symbol */
2077Object.defineProperty(Symbol, 'species', { value: Symbol('species') });
2078
2079// Map
2080/* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
2081(function (global) {
2082 var supportsGetters = (function () {
2083 try {
2084 var a = {};
2085 Object.defineProperty(a, 't', {
2086 configurable: true,
2087 enumerable: false,
2088 get: function () {
2089 return true;
2090 },
2091 set: undefined
2092 });
2093 return !!a.t;
2094 } catch (e) {
2095 return false;
2096 }
2097 }());
2098
2099 // 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.
2100 var undefMarker = Symbol('undef');
2101 // 23.1.1.1 Map ( [ iterable ] )
2102 var Map = function Map(/* iterable */) {
2103 // 1. If NewTarget is undefined, throw a TypeError exception.
2104 if (!(this instanceof Map)) {
2105 throw new TypeError('Constructor Map requires "new"');
2106 }
2107 // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%MapPrototype%", « [[MapData]] »).
2108 var map = OrdinaryCreateFromConstructor(this, Map.prototype, {
2109 _keys: [],
2110 _values: [],
2111 _size: 0,
2112 _es6Map: true
2113 });
2114
2115 // 3. Set map.[[MapData]] to a new empty List.
2116 // Polyfill.io - This step was done as part of step two.
2117
2118 // 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.
2119 if (!supportsGetters) {
2120 Object.defineProperty(map, 'size', {
2121 configurable: true,
2122 enumerable: false,
2123 writable: true,
2124 value: 0
2125 });
2126 }
2127
2128 // 4. If iterable is not present, let iterable be undefined.
2129 var iterable = arguments.length > 0 ? arguments[0] : undefined;
2130
2131 // 5. If iterable is either undefined or null, return map.
2132 if (iterable === null || iterable === undefined) {
2133 return map;
2134 }
2135
2136 // 6. Let adder be ? Get(map, "set").
2137 var adder = map.set;
2138
2139 // 7. If IsCallable(adder) is false, throw a TypeError exception.
2140 if (!IsCallable(adder)) {
2141 throw new TypeError("Map.prototype.set is not a function");
2142 }
2143
2144 // 8. Let iteratorRecord be ? GetIterator(iterable).
2145 try {
2146 var iteratorRecord = GetIterator(iterable);
2147 // 9. Repeat,
2148 while (true) {
2149 // a. Let next be ? IteratorStep(iteratorRecord).
2150 var next = IteratorStep(iteratorRecord);
2151 // b. If next is false, return map.
2152 if (next === false) {
2153 return map;
2154 }
2155 // c. Let nextItem be ? IteratorValue(next).
2156 var nextItem = IteratorValue(next);
2157 // d. If Type(nextItem) is not Object, then
2158 if (Type(nextItem) !== 'object') {
2159 // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
2160 try {
2161 throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
2162 } catch (error) {
2163 // ii. Return ? IteratorClose(iteratorRecord, error).
2164 return IteratorClose(iteratorRecord, error);
2165 }
2166 }
2167 try {
2168 // Polyfill.io - The try catch accounts for steps: f, h, and j.
2169
2170 // e. Let k be Get(nextItem, "0").
2171 var k = nextItem[0];
2172 // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
2173 // g. Let v be Get(nextItem, "1").
2174 var v = nextItem[1];
2175 // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
2176 // i. Let status be Call(adder, map, « k.[[Value]], v.[[Value]] »).
2177 adder.call(map, k, v);
2178 } catch (e) {
2179 // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
2180 return IteratorClose(iteratorRecord, e);
2181 }
2182 }
2183 } catch (e) {
2184 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
2185 if (Array.isArray(iterable) ||
2186 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
2187 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
2188 (!!iterable.callee)) {
2189 var index;
2190 var length = iterable.length;
2191 for (index = 0; index < length; index++) {
2192 adder.call(map, iterable[index][0], iterable[index][1]);
2193 }
2194 }
2195 }
2196 return map;
2197 };
2198
2199 // 23.1.2.1. Map.prototype
2200 // The initial value of Map.prototype is the intrinsic object %MapPrototype%.
2201 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
2202 Object.defineProperty(Map, 'prototype', {
2203 configurable: false,
2204 enumerable: false,
2205 writable: false,
2206 value: {}
2207 });
2208
2209 // 23.1.2.2 get Map [ @@species ]
2210 if (supportsGetters) {
2211 Object.defineProperty(Map, Symbol.species, {
2212 configurable: true,
2213 enumerable: false,
2214 get: function () {
2215 // 1. Return the this value.
2216 return this;
2217 },
2218 set: undefined
2219 });
2220 } else {
2221 CreateMethodProperty(Map, Symbol.species, Map);
2222 }
2223
2224 // 23.1.3.1 Map.prototype.clear ( )
2225 CreateMethodProperty(Map.prototype, 'clear', function clear() {
2226 // 1. Let M be the this value.
2227 var M = this;
2228 // 2. If Type(M) is not Object, throw a TypeError exception.
2229 if (Type(M) !== 'object') {
2230 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
2231 }
2232 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2233 if (M._es6Map !== true) {
2234 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
2235 }
2236 // 4. Let entries be the List that is M.[[MapData]].
2237 var entries = M._keys;
2238 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
2239 for (var i = 0; i < entries.length; i++) {
2240 // 5.a. Set p.[[Key]] to empty.
2241 M._keys[i] = undefMarker;
2242 // 5.b. Set p.[[Value]] to empty.
2243 M._values[i] = undefMarker;
2244 }
2245 this._size = 0;
2246 if (!supportsGetters) {
2247 this.size = this._size;
2248 }
2249 // 6. Return undefined.
2250 return undefined;
2251 }
2252 );
2253
2254 // 23.1.3.2. Map.prototype.constructor
2255 CreateMethodProperty(Map.prototype, 'constructor', Map);
2256
2257 // 23.1.3.3. Map.prototype.delete ( key )
2258 CreateMethodProperty(Map.prototype, 'delete', function (key) {
2259 // 1. Let M be the this value.
2260 var M = this;
2261 // 2. If Type(M) is not Object, throw a TypeError exception.
2262 if (Type(M) !== 'object') {
2263 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
2264 }
2265 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2266 if (M._es6Map !== true) {
2267 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
2268 }
2269 // 4. Let entries be the List that is M.[[MapData]].
2270 var entries = M._keys;
2271 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
2272 for (var i = 0; i < entries.length; i++) {
2273 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
2274 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
2275 // i. Set p.[[Key]] to empty.
2276 this._keys[i] = undefMarker;
2277 // ii. Set p.[[Value]] to empty.
2278 this._values[i] = undefMarker;
2279 this._size = --this._size;
2280 if (!supportsGetters) {
2281 this.size = this._size;
2282 }
2283 // iii. Return true.
2284 return true;
2285 }
2286 }
2287 // 6. Return false.
2288 return false;
2289 }
2290 );
2291
2292 // 23.1.3.4. Map.prototype.entries ( )
2293 CreateMethodProperty(Map.prototype, 'entries', function entries () {
2294 // 1. Let M be the this value.
2295 var M = this;
2296 // 2. Return ? CreateMapIterator(M, "key+value").
2297 return CreateMapIterator(M, 'key+value');
2298 }
2299 );
2300
2301 // 23.1.3.5. Map.prototype.forEach ( callbackfn [ , thisArg ] )
2302 CreateMethodProperty(Map.prototype, 'forEach', function (callbackFn) {
2303 // 1. Let M be the this value.
2304 var M = this;
2305 // 2. If Type(M) is not Object, throw a TypeError exception.
2306 if (Type(M) !== 'object') {
2307 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
2308 }
2309 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2310 if (M._es6Map !== true) {
2311 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
2312 }
2313 // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
2314 if (!IsCallable(callbackFn)) {
2315 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
2316 }
2317 // 5. If thisArg is present, let T be thisArg; else let T be undefined.
2318 if (arguments[1]) {
2319 var T = arguments[1];
2320 }
2321 // 6. Let entries be the List that is M.[[MapData]].
2322 var entries = M._keys;
2323 // 7. For each Record {[[Key]], [[Value]]} e that is an element of entries, in original key insertion order, do
2324 for (var i = 0; i < entries.length; i++) {
2325 // a. If e.[[Key]] is not empty, then
2326 if (M._keys[i] !== undefMarker && M._values[i] !== undefMarker ) {
2327 // i. Perform ? Call(callbackfn, T, « e.[[Value]], e.[[Key]], M »).
2328 callbackFn.call(T, M._values[i], M._keys[i], M);
2329 }
2330 }
2331 // 8. Return undefined.
2332 return undefined;
2333 }
2334 );
2335
2336 // 23.1.3.6. Map.prototype.get ( key )
2337 CreateMethodProperty(Map.prototype, 'get', function get(key) {
2338 // 1. Let M be the this value.
2339 var M = this;
2340 // 2. If Type(M) is not Object, throw a TypeError exception.
2341 if (Type(M) !== 'object') {
2342 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
2343 }
2344 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2345 if (M._es6Map !== true) {
2346 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
2347 }
2348 // 4. Let entries be the List that is M.[[MapData]].
2349 var entries = M._keys;
2350 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
2351 for (var i = 0; i < entries.length; i++) {
2352 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return p.[[Value]].
2353 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
2354 return M._values[i];
2355 }
2356 }
2357 // 6. Return undefined.
2358 return undefined;
2359 });
2360
2361 // 23.1.3.7. Map.prototype.has ( key )
2362 CreateMethodProperty(Map.prototype, 'has', function has (key) {
2363 // 1. Let M be the this value.
2364 var M = this;
2365 // 2. If Type(M) is not Object, throw a TypeError exception.
2366 if (typeof M !== 'object') {
2367 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
2368 }
2369 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2370 if (M._es6Map !== true) {
2371 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
2372 }
2373 // 4. Let entries be the List that is M.[[MapData]].
2374 var entries = M._keys;
2375 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
2376 for (var i = 0; i < entries.length; i++) {
2377 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return true.
2378 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
2379 return true;
2380 }
2381 }
2382 // 6. Return false.
2383 return false;
2384 });
2385
2386 // 23.1.3.8. Map.prototype.keys ( )
2387 CreateMethodProperty(Map.prototype, 'keys', function keys () {
2388 // 1. Let M be the this value.
2389 var M = this;
2390 // 2. Return ? CreateMapIterator(M, "key").
2391 return CreateMapIterator(M, "key");
2392 });
2393
2394 // 23.1.3.9. Map.prototype.set ( key, value )
2395 CreateMethodProperty(Map.prototype, 'set', function set(key, value) {
2396 // 1. Let M be the this value.
2397 var M = this;
2398 // 2. If Type(M) is not Object, throw a TypeError exception.
2399 if (Type(M) !== 'object') {
2400 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
2401 }
2402 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2403 if (M._es6Map !== true) {
2404 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
2405 }
2406 // 4. Let entries be the List that is M.[[MapData]].
2407 var entries = M._keys;
2408 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
2409 for (var i = 0; i < entries.length; i++) {
2410 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
2411 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
2412 // i. Set p.[[Value]] to value.
2413 M._values[i] = value;
2414 // Return M.
2415 return M;
2416 }
2417 }
2418 // 6. If key is -0, let key be +0.
2419 if (key === -0) {
2420 key = 0;
2421 }
2422 // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
2423 var p = {};
2424 p['[[Key]]'] = key;
2425 p['[[Value]]'] = value;
2426 // 8. Append p as the last element of entries.
2427 M._keys.push(p['[[Key]]']);
2428 M._values.push(p['[[Value]]']);
2429 ++M._size;
2430 if (!supportsGetters) {
2431 M.size = M._size;
2432 }
2433 // 9. Return M.
2434 return M;
2435 });
2436
2437 // 23.1.3.10. get Map.prototype.size
2438 if (supportsGetters) {
2439 Object.defineProperty(Map.prototype, 'size', {
2440 configurable: true,
2441 enumerable: false,
2442 get: function () {
2443 // 1. Let M be the this value.
2444 var M = this;
2445 // 2. If Type(M) is not Object, throw a TypeError exception.
2446 if (Type(M) !== 'object') {
2447 throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
2448 }
2449 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
2450 if (M._es6Map !== true) {
2451 throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
2452 }
2453 // 4. Let entries be the List that is M.[[MapData]].
2454 var entries = M._keys;
2455 // 5. Let count be 0.
2456 var count = 0;
2457 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
2458 for (var i = 0; i < entries.length; i++) {
2459 // a. If p.[[Key]] is not empty, set count to count+1.
2460 if (M._keys[i] !== undefMarker) {
2461 count = count + 1;
2462 }
2463 }
2464 // 7. Return count.
2465 return count;
2466 },
2467 set: undefined
2468 });
2469 }
2470
2471 // 23.1.3.11. Map.prototype.values ( )
2472 CreateMethodProperty(Map.prototype, 'values', function values () {
2473 // 1. Let M be the this value.
2474 var M = this;
2475 // 2. Return ? CreateMapIterator(M, "value").
2476 return CreateMapIterator(M, 'value');
2477 }
2478 );
2479
2480 // 23.1.3.12. Map.prototype [ @@iterator ] ( )
2481 // The initial value of the @@iterator property is the same function object as the initial value of the entries property.
2482 CreateMethodProperty(Map.prototype, Symbol.iterator, Map.prototype.entries);
2483
2484 // 23.1.3.13. Map.prototype [ @@toStringTag ]
2485 // The initial value of the @@toStringTag property is the String value "Map".
2486 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
2487
2488 // 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.
2489 if (!('name' in Map)) {
2490 // 19.2.4.2 name
2491 Object.defineProperty(Map, 'name', {
2492 configurable: true,
2493 enumerable: false,
2494 writable: false,
2495 value: 'Map'
2496 });
2497 }
2498
2499 // 23.1.5.1. CreateMapIterator ( map, kind )
2500 function CreateMapIterator(map, kind) {
2501 // 1. If Type(map) is not Object, throw a TypeError exception.
2502 if (Type(map) !== 'object') {
2503 throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
2504 }
2505 // 2. If map does not have a [[MapData]] internal slot, throw a TypeError exception.
2506 if (map._es6Map !== true) {
2507 throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
2508 }
2509 // 3. Let iterator be ObjectCreate(%MapIteratorPrototype%, « [[Map]], [[MapNextIndex]], [[MapIterationKind]] »).
2510 var iterator = Object.create(MapIteratorPrototype);
2511 // 4. Set iterator.[[Map]] to map.
2512 Object.defineProperty(iterator, '[[Map]]', {
2513 configurable: true,
2514 enumerable: false,
2515 writable: true,
2516 value: map
2517 });
2518 // 5. Set iterator.[[MapNextIndex]] to 0.
2519 Object.defineProperty(iterator, '[[MapNextIndex]]', {
2520 configurable: true,
2521 enumerable: false,
2522 writable: true,
2523 value: 0
2524 });
2525 // 6. Set iterator.[[MapIterationKind]] to kind.
2526 Object.defineProperty(iterator, '[[MapIterationKind]]', {
2527 configurable: true,
2528 enumerable: false,
2529 writable: true,
2530 value: kind
2531 });
2532 // 7. Return iterator.
2533 return iterator;
2534 }
2535
2536 // 23.1.5.2. The %MapIteratorPrototype% Object
2537 var MapIteratorPrototype = {};
2538 // Polyfill.io - We use this as a quick way to check if an object is a Map Iterator instance.
2539 Object.defineProperty(MapIteratorPrototype, 'isMapIterator', {
2540 configurable: false,
2541 enumerable: false,
2542 writable: false,
2543 value: true
2544 });
2545
2546 // 23.1.5.2.1. %MapIteratorPrototype%.next ( )
2547 CreateMethodProperty(MapIteratorPrototype, 'next', function next() {
2548 // 1. Let O be the this value.
2549 var O = this;
2550 // 2. If Type(O) is not Object, throw a TypeError exception.
2551 if (Type(O) !== 'object') {
2552 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
2553 }
2554 // 3. If O does not have all of the internal slots of a Map Iterator Instance (23.1.5.3), throw a TypeError exception.
2555 if (!O.isMapIterator) {
2556 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
2557 }
2558 // 4. Let m be O.[[Map]].
2559 var m = O['[[Map]]'];
2560 // 5. Let index be O.[[MapNextIndex]].
2561 var index = O['[[MapNextIndex]]'];
2562 // 6. Let itemKind be O.[[MapIterationKind]].
2563 var itemKind = O['[[MapIterationKind]]'];
2564 // 7. If m is undefined, return CreateIterResultObject(undefined, true).
2565 if (m === undefined) {
2566 return CreateIterResultObject(undefined, true);
2567 }
2568 // 8. Assert: m has a [[MapData]] internal slot.
2569 if (!m._es6Map) {
2570 throw new Error(Object.prototype.toString.call(m) + ' has a [[MapData]] internal slot.');
2571 }
2572 // 9. Let entries be the List that is m.[[MapData]].
2573 var entries = m._keys;
2574 // 10. Let numEntries be the number of elements of entries.
2575 var numEntries = entries.length;
2576 // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
2577 // 12. Repeat, while index is less than numEntries,
2578 while (index < numEntries) {
2579 // a. Let e be the Record {[[Key]], [[Value]]} that is the value of entries[index].
2580 var e = Object.create(null);
2581 e['[[Key]]'] = m._keys[index];
2582 e['[[Value]]'] = m._values[index];
2583 // b. Set index to index+1.
2584 index = index + 1;
2585 // c. Set O.[[MapNextIndex]] to index.
2586 O['[[MapNextIndex]]'] = index;
2587 // d. If e.[[Key]] is not empty, then
2588 if (e['[[Key]]'] !== undefMarker) {
2589 // i. If itemKind is "key", let result be e.[[Key]].
2590 if (itemKind === 'key') {
2591 var result = e['[[Key]]'];
2592 // ii. Else if itemKind is "value", let result be e.[[Value]].
2593 } else if (itemKind === 'value') {
2594 result = e['[[Value]]'];
2595 // iii. Else,
2596 } else {
2597 // 1. Assert: itemKind is "key+value".
2598 if (itemKind !== 'key+value') {
2599 throw new Error();
2600 }
2601 // 2. Let result be CreateArrayFromList(« e.[[Key]], e.[[Value]] »).
2602 result = [
2603 e['[[Key]]'],
2604 e['[[Value]]']
2605 ];
2606 }
2607 // iv. Return CreateIterResultObject(result, false).
2608 return CreateIterResultObject(result, false);
2609 }
2610 }
2611 // 13. Set O.[[Map]] to undefined.
2612 O['[[Map]]'] = undefined;
2613 // 14. Return CreateIterResultObject(undefined, true).
2614 return CreateIterResultObject(undefined, true);
2615 }
2616 );
2617
2618 // 23.1.5.2.2 %MapIteratorPrototype% [ @@toStringTag ]
2619 // The initial value of the @@toStringTag property is the String value "Map Iterator".
2620 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
2621
2622 CreateMethodProperty(MapIteratorPrototype, Symbol.iterator, function iterator() {
2623 return this;
2624 }
2625 );
2626
2627 // Export the object
2628 try {
2629 CreateMethodProperty(global, 'Map', Map);
2630 } catch (e) {
2631 // IE8 throws an error here if we set enumerable to false.
2632 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
2633 global['Map'] = Map;
2634 }
2635}(this));
2636
2637// Set
2638/* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Symbol */
2639(function (global) {
2640 var supportsGetters = (function () {
2641 try {
2642 var a = {};
2643 Object.defineProperty(a, 't', {
2644 configurable: true,
2645 enumerable: false,
2646 get: function () {
2647 return true;
2648 },
2649 set: undefined
2650 });
2651 return !!a.t;
2652 } catch (e) {
2653 return false;
2654 }
2655 }());
2656
2657 // 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.
2658 var undefMarker = Symbol('undef');
2659 // 23.2.1.1. Set ( [ iterable ] )
2660 var Set = function Set(/* iterable */) {
2661 // 1. If NewTarget is undefined, throw a TypeError exception.
2662 if (!(this instanceof Set)) {
2663 throw new TypeError('Constructor Set requires "new"');
2664 }
2665 // 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%SetPrototype%", « [[SetData]] »).
2666 var set = OrdinaryCreateFromConstructor(this, Set.prototype, {
2667 _values: [],
2668 _size: 0,
2669 _es6Set: true
2670 });
2671
2672 // 3. Set set.[[SetData]] to a new empty List.
2673 // Polyfill.io - This step was done as part of step two.
2674
2675 // 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.
2676 if (!supportsGetters) {
2677 Object.defineProperty(set, 'size', {
2678 configurable: true,
2679 enumerable: false,
2680 writable: true,
2681 value: 0
2682 });
2683 }
2684
2685 // 4. If iterable is not present, let iterable be undefined.
2686 var iterable = arguments.length > 0 ? arguments[0] : undefined;
2687
2688 // 5. If iterable is either undefined or null, return set.
2689 if (iterable === null || iterable === undefined) {
2690 return set;
2691 }
2692
2693 // 6. Let adder be ? Get(set, "add").
2694 var adder = set.add;
2695 // 7. If IsCallable(adder) is false, throw a TypeError exception.
2696 if (!IsCallable(adder)) {
2697 throw new TypeError("Set.prototype.add is not a function");
2698 }
2699
2700 try {
2701 // 8. Let iteratorRecord be ? GetIterator(iterable).
2702 var iteratorRecord = GetIterator(iterable);
2703 // 9. Repeat,
2704 while (true) {
2705 // a. Let next be ? IteratorStep(iteratorRecord).
2706 var next = IteratorStep(iteratorRecord);
2707 // b. If next is false, return set.
2708 if (next === false) {
2709 return set;
2710 }
2711 // c. Let nextValue be ? IteratorValue(next).
2712 var nextValue = IteratorValue(next);
2713 // d. Let status be Call(adder, set, « nextValue.[[Value]] »).
2714 try {
2715 adder.call(set, nextValue);
2716 } catch (e) {
2717 // e. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
2718 return IteratorClose(iteratorRecord, e);
2719 }
2720 }
2721 } catch (e) {
2722 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
2723 if (Array.isArray(iterable) ||
2724 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
2725 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
2726 (!!iterable.callee)) {
2727 var index;
2728 var length = iterable.length;
2729 for (index = 0; index < length; index++) {
2730 adder.call(set, iterable[index]);
2731 }
2732 } else {
2733 throw (e);
2734 }
2735 }
2736 return set;
2737 };
2738
2739 // 23.2.2.1. Set.prototype
2740 // The initial value of Set.prototype is the intrinsic %SetPrototype% object.
2741 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
2742 Object.defineProperty(Set, 'prototype', {
2743 configurable: false,
2744 enumerable: false,
2745 writable: false,
2746 value: {}
2747 });
2748
2749 // 23.2.2.2 get Set [ @@species ]
2750 if (supportsGetters) {
2751 Object.defineProperty(Set, Symbol.species, {
2752 configurable: true,
2753 enumerable: false,
2754 get: function () {
2755 // 1. Return the this value.
2756 return this;
2757 },
2758 set: undefined
2759 });
2760 } else {
2761 CreateMethodProperty(Set, Symbol.species, Set);
2762 }
2763
2764 // 23.2.3.1. Set.prototype.add ( value )
2765 CreateMethodProperty(Set.prototype, 'add', function add(value) {
2766 // 1. Let S be the this value.
2767 var S = this;
2768 // 2. If Type(S) is not Object, throw a TypeError exception.
2769 if (typeof S !== 'object') {
2770 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
2771 }
2772 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
2773 if (S._es6Set !== true) {
2774 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
2775 }
2776 // 4. Let entries be the List that is S.[[SetData]].
2777 var entries = S._values;
2778 // 5. For each e that is an element of entries, do
2779 for (var i = 0; i < entries.length; i++) {
2780 var e = entries[i];
2781 // a. If e is not empty and SameValueZero(e, value) is true, then
2782 if (e !== undefMarker && SameValueZero(e, value)) {
2783 // i. Return S.
2784 return S;
2785 }
2786 }
2787 // 6. If value is -0, let value be +0.
2788 if (1/value === -Infinity) {
2789 value = 0;
2790 }
2791 // 7. Append value as the last element of entries.
2792 S._values.push(value);
2793
2794 this._size = ++this._size;
2795 if (!supportsGetters) {
2796 this.size = this._size;
2797 }
2798 // 8. Return S.
2799 return S;
2800 });
2801
2802 // 23.2.3.2. Set.prototype.clear ( )
2803 CreateMethodProperty(Set.prototype, 'clear', function clear() {
2804 // 1. Let S be the this value.
2805 var S = this;
2806 // 2. If Type(S) is not Object, throw a TypeError exception.
2807 if (typeof S !== 'object') {
2808 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
2809 }
2810 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
2811 if (S._es6Set !== true) {
2812 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
2813 }
2814 // 4. Let entries be the List that is S.[[SetData]].
2815 var entries = S._values;
2816 // 5. For each e that is an element of entries, do
2817 for (var i = 0; i < entries.length; i++) {
2818 // a. Replace the element of entries whose value is e with an element whose value is empty.
2819 entries[i] = undefMarker;
2820 }
2821 this._size = 0;
2822 if (!supportsGetters) {
2823 this.size = this._size;
2824 }
2825 // 6. Return undefined.
2826 return undefined;
2827 });
2828
2829 // 23.2.3.3. Set.prototype.constructor
2830 CreateMethodProperty(Set.prototype, 'constructor', Set);
2831
2832 // 23.2.3.4. Set.prototype.delete ( value )
2833 CreateMethodProperty(Set.prototype, 'delete', function (value) {
2834 // 1. Let S be the this value.
2835 var S = this;
2836 // 2. If Type(S) is not Object, throw a TypeError exception.
2837 if (typeof S !== 'object') {
2838 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
2839 }
2840 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
2841 if (S._es6Set !== true) {
2842 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
2843 }
2844 // 4. Let entries be the List that is S.[[SetData]].
2845 var entries = S._values;
2846 // 5. For each e that is an element of entries, do
2847 for (var i = 0; i < entries.length; i++) {
2848 var e = entries[i];
2849 // a. If e is not empty and SameValueZero(e, value) is true, then
2850 if (e !== undefMarker && SameValueZero(e, value)) {
2851 // i. Replace the element of entries whose value is e with an element whose value is empty.
2852 entries[i] = undefMarker;
2853
2854 this._size = --this._size;
2855 if (!supportsGetters) {
2856 this.size = this._size;
2857 }
2858 // ii. Return true.
2859 return true;
2860 }
2861 }
2862 // 6. Return false.
2863 return false;
2864 }
2865 );
2866
2867 // 23.2.3.5. Set.prototype.entries ( )
2868 CreateMethodProperty(Set.prototype, 'entries', function entries() {
2869 // 1. Let S be the this value.
2870 var S = this;
2871 // 2. Return ? CreateSetIterator(S, "key+value").
2872 return CreateSetIterator(S, 'key+value');
2873 }
2874 );
2875
2876 // 23.2.3.6. Set.prototype.forEach ( callbackfn [ , thisArg ] )
2877 CreateMethodProperty(Set.prototype, 'forEach', function forEach(callbackFn /*[ , thisArg ]*/) {
2878 // 1. Let S be the this value.
2879 var S = this;
2880 // 2. If Type(S) is not Object, throw a TypeError exception.
2881 if (typeof S !== 'object') {
2882 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
2883 }
2884 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
2885 if (S._es6Set !== true) {
2886 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
2887 }
2888 // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
2889 if (!IsCallable(callbackFn)) {
2890 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
2891 }
2892 // 5. If thisArg is present, let T be thisArg; else let T be undefined.
2893 if (arguments[1]) {
2894 var T = arguments[1];
2895 }
2896 // 6. Let entries be the List that is S.[[SetData]].
2897 var entries = S._values;
2898 // 7. For each e that is an element of entries, in original insertion order, do
2899 for (var i = 0; i < entries.length; i++) {
2900 var e = entries[i];
2901 // a. If e is not empty, then
2902 if (e !== undefMarker) {
2903 // i. Perform ? Call(callbackfn, T, « e, e, S »).
2904 callbackFn.call(T, e, e, S);
2905 }
2906 }
2907 // 8. Return undefined.
2908 return undefined;
2909 }
2910 );
2911
2912 // 23.2.3.7. Set.prototype.has ( value )
2913 CreateMethodProperty(Set.prototype, 'has', function has(value) {
2914 // 1. Let S be the this value.
2915 var S = this;
2916 // 2. If Type(S) is not Object, throw a TypeError exception.
2917 if (typeof S !== 'object') {
2918 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
2919 }
2920 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
2921 if (S._es6Set !== true) {
2922 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
2923 }
2924 // 4. Let entries be the List that is S.[[SetData]].
2925 var entries = S._values;
2926 // 5. For each e that is an element of entries, do
2927 for (var i = 0; i < entries.length; i++) {
2928 var e = entries[i];
2929 // a. If e is not empty and SameValueZero(e, value) is true, return true.
2930 if (e !== undefMarker && SameValueZero(e, value)) {
2931 return true;
2932 }
2933 }
2934 // 6. Return false.
2935 return false;
2936 }
2937 );
2938
2939 // Polyfill.io - We need to define Set.prototype.values before Set.prototype.keys because keys is a reference to values.
2940 // 23.2.3.10. Set.prototype.values()
2941 var values = function values() {
2942 // 1. Let S be the this value.
2943 var S = this;
2944 // 2. Return ? CreateSetIterator(S, "value").
2945 return CreateSetIterator(S, "value");
2946 };
2947 CreateMethodProperty(Set.prototype, 'values', values);
2948
2949 // 23.2.3.8 Set.prototype.keys ( )
2950 // The initial value of the keys property is the same function object as the initial value of the values property.
2951 CreateMethodProperty(Set.prototype, 'keys', values);
2952
2953 // 23.2.3.9. get Set.prototype.size
2954 if (supportsGetters) {
2955 Object.defineProperty(Set.prototype, 'size', {
2956 configurable: true,
2957 enumerable: false,
2958 get: function () {
2959 // 1. Let S be the this value.
2960 var S = this;
2961 // 2. If Type(S) is not Object, throw a TypeError exception.
2962 if (typeof S !== 'object') {
2963 throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
2964 }
2965 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
2966 if (S._es6Set !== true) {
2967 throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
2968 }
2969 // 4. Let entries be the List that is S.[[SetData]].
2970 var entries = S._values;
2971 // 5. Let count be 0.
2972 var count = 0;
2973 // 6. For each e that is an element of entries, do
2974 for (var i = 0; i < entries.length; i++) {
2975 var e = entries[i];
2976 // a. If e is not empty, set count to count+1.
2977 if (e !== undefMarker) {
2978 count = count + 1;
2979 }
2980 }
2981 // 7. Return count.
2982 return count;
2983 },
2984 set: undefined
2985 });
2986 }
2987
2988 // 23.2.3.11. Set.prototype [ @@iterator ] ( )
2989 // The initial value of the @@iterator property is the same function object as the initial value of the values property.
2990 CreateMethodProperty(Set.prototype, Symbol.iterator, values);
2991
2992 // 23.2.3.12. Set.prototype [ @@toStringTag ]
2993 // The initial value of the @@toStringTag property is the String value "Set".
2994 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
2995
2996 // 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.
2997 if (!('name' in Set)) {
2998 // 19.2.4.2 name
2999 Object.defineProperty(Set, 'name', {
3000 configurable: true,
3001 enumerable: false,
3002 writable: false,
3003 value: 'Set'
3004 });
3005 }
3006
3007 // 23.2.5.1. CreateSetIterator ( set, kind )
3008 function CreateSetIterator(set, kind) {
3009 // 1. If Type(set) is not Object, throw a TypeError exception.
3010 if (typeof set !== 'object') {
3011 throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
3012 }
3013 // 2. If set does not have a [[SetData]] internal slot, throw a TypeError exception.
3014 if (set._es6Set !== true) {
3015 throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
3016 }
3017 // 3. Let iterator be ObjectCreate(%SetIteratorPrototype%, « [[IteratedSet]], [[SetNextIndex]], [[SetIterationKind]] »).
3018 var iterator = Object.create(SetIteratorPrototype);
3019 // 4. Set iterator.[[IteratedSet]] to set.
3020 Object.defineProperty(iterator, '[[IteratedSet]]', {
3021 configurable: true,
3022 enumerable: false,
3023 writable: true,
3024 value: set
3025 });
3026 // 5. Set iterator.[[SetNextIndex]] to 0.
3027 Object.defineProperty(iterator, '[[SetNextIndex]]', {
3028 configurable: true,
3029 enumerable: false,
3030 writable: true,
3031 value: 0
3032 });
3033 // 6. Set iterator.[[SetIterationKind]] to kind.
3034 Object.defineProperty(iterator, '[[SetIterationKind]]', {
3035 configurable: true,
3036 enumerable: false,
3037 writable: true,
3038 value: kind
3039 });
3040 // 7. Return iterator.
3041 return iterator;
3042 }
3043
3044 // 23.2.5.2. The %SetIteratorPrototype% Object
3045 var SetIteratorPrototype = {};
3046 //Polyfill.io - We add this property to help us identify what is a set iterator.
3047 Object.defineProperty(SetIteratorPrototype, 'isSetIterator', {
3048 configurable: false,
3049 enumerable: false,
3050 writable: false,
3051 value: true
3052 });
3053
3054 // 23.2.5.2.1. %SetIteratorPrototype%.next ( )
3055 CreateMethodProperty(SetIteratorPrototype, 'next', function next() {
3056 // 1. Let O be the this value.
3057 var O = this;
3058 // 2. If Type(O) is not Object, throw a TypeError exception.
3059 if (typeof O !== 'object') {
3060 throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
3061 }
3062 // 3. If O does not have all of the internal slots of a Set Iterator Instance (23.2.5.3), throw a TypeError exception.
3063 if (!O.isSetIterator) {
3064 throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
3065 }
3066 // 4. Let s be O.[[IteratedSet]].
3067 var s = O['[[IteratedSet]]'];
3068 // 5. Let index be O.[[SetNextIndex]].
3069 var index = O['[[SetNextIndex]]'];
3070 // 6. Let itemKind be O.[[SetIterationKind]].
3071 var itemKind = O['[[SetIterationKind]]'];
3072 // 7. If s is undefined, return CreateIterResultObject(undefined, true).
3073 if (s === undefined) {
3074 return CreateIterResultObject(undefined, true);
3075 }
3076 // 8. Assert: s has a [[SetData]] internal slot.
3077 if (!s._es6Set) {
3078 throw new Error(Object.prototype.toString.call(s) + ' does not have [[SetData]] internal slot.');
3079 }
3080 // 9. Let entries be the List that is s.[[SetData]].
3081 var entries = s._values;
3082 // 10. Let numEntries be the number of elements of entries.
3083 var numEntries = entries.length;
3084 // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
3085 // 12. Repeat, while index is less than numEntries,
3086 while (index < numEntries) {
3087 // a. Let e be entries[index].
3088 var e = entries[index];
3089 // b. Set index to index+1.
3090 index = index + 1;
3091 // c. Set O.[[SetNextIndex]] to index.
3092 O['[[SetNextIndex]]'] = index;
3093 // d. If e is not empty, then
3094 if (e !== undefMarker) {
3095 // i. If itemKind is "key+value", then
3096 if (itemKind === 'key+value') {
3097 // 1. Return CreateIterResultObject(CreateArrayFromList(« e, e »), false).
3098 return CreateIterResultObject([e, e], false);
3099 }
3100 // ii. Return CreateIterResultObject(e, false).
3101 return CreateIterResultObject(e, false);
3102 }
3103 }
3104 // 13. Set O.[[IteratedSet]] to undefined.
3105 O['[[IteratedSet]]'] = undefined;
3106 // 14. Return CreateIterResultObject(undefined, true).
3107 return CreateIterResultObject(undefined, true);
3108 });
3109
3110 // 23.2.5.2.2. %SetIteratorPrototype% [ @@toStringTag ]
3111 // The initial value of the @@toStringTag property is the String value "Set Iterator".
3112 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
3113
3114 CreateMethodProperty(SetIteratorPrototype, Symbol.iterator, function iterator() {
3115 return this;
3116 }
3117 );
3118
3119 // Export the object
3120 try {
3121 CreateMethodProperty(global, 'Set', Set);
3122 } catch (e) {
3123 // IE8 throws an error here if we set enumerable to false.
3124 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
3125 global['Set'] = Set;
3126 }
3127
3128}(this));
3129
3130// Array.from
3131/* globals
3132 IsCallable, GetMethod, Symbol, IsConstructor, Construct, ArrayCreate, GetIterator, IteratorClose,
3133 ToString, IteratorStep, IteratorValue, Call, CreateDataPropertyOrThrow, ToObject, ToLength, Get, CreateMethodProperty
3134*/
3135(function () {
3136 var toString = Object.prototype.toString;
3137 var stringMatch = String.prototype.match;
3138 // A cross-realm friendly way to detect if a value is a String object or literal.
3139 function isString(value) {
3140 if (typeof value === 'string') { return true; }
3141 if (typeof value !== 'object') { return false; }
3142 return toString.call(value) === '[object String]';
3143 }
3144
3145 // 22.1.2.1. Array.from ( items [ , mapfn [ , thisArg ] ] )
3146 CreateMethodProperty(Array, 'from', function from(items /* [ , mapfn [ , thisArg ] ] */) { // eslint-disable-line no-undef
3147 // 1. Let C be the this value.
3148 var C = this;
3149 // 2. If mapfn is undefined, let mapping be false.
3150 var mapfn = arguments.length > 1 ? arguments[1] : undefined;
3151 if (mapfn === undefined) {
3152 var mapping = false;
3153 // 3. Else,
3154 } else {
3155 // a. If IsCallable(mapfn) is false, throw a TypeError exception.
3156 if (IsCallable(mapfn) === false) {
3157 throw new TypeError(Object.prototype.toString.call(mapfn) + ' is not a function.');
3158 }
3159 // b. If thisArg is present, let T be thisArg; else let T be undefined.
3160 var thisArg = arguments.length > 2 ? arguments[2] : undefined;
3161 if (thisArg !== undefined) {
3162 var T = thisArg;
3163 } else {
3164 T = undefined;
3165 }
3166 // c. Let mapping be true.
3167 mapping = true;
3168
3169 }
3170 // 4. Let usingIterator be ? GetMethod(items, @@iterator).
3171 var usingIterator = GetMethod(items, Symbol.iterator);
3172 // 5. If usingIterator is not undefined, then
3173 if (usingIterator !== undefined) {
3174 // a. If IsConstructor(C) is true, then
3175 if (IsConstructor(C)) {
3176 // i. Let A be ? Construct(C).
3177 var A = Construct(C);
3178 // b. Else,
3179 } else {
3180 // i. Let A be ! ArrayCreate(0).
3181 A = ArrayCreate(0);
3182 }
3183 // c. Let iteratorRecord be ? GetIterator(items, usingIterator).
3184 var iteratorRecord = GetIterator(items, usingIterator);
3185 // d. Let k be 0.
3186 var k = 0;
3187 // e. Repeat,
3188 while (true) {
3189 // i. If k ≥ 2^53-1, then
3190 if (k >= (Math.pow(2, 53) - 1)) {
3191 // 1. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
3192 var error = new TypeError('Iteration count can not be greater than or equal 9007199254740991.');
3193 // 2. Return ? IteratorClose(iteratorRecord, error).
3194 return IteratorClose(iteratorRecord, error);
3195 }
3196 // ii. Let Pk be ! ToString(k).
3197 var Pk = ToString(k);
3198 // iii. Let next be ? IteratorStep(iteratorRecord).
3199 var next = IteratorStep(iteratorRecord);
3200 // iv. If next is false, then
3201 if (next === false) {
3202 // 1. Perform ? Set(A, "length", k, true).
3203 A["length"] = k;
3204 // 2. Return A.
3205 return A;
3206 }
3207 // v. Let nextValue be ? IteratorValue(next).
3208 var nextValue = IteratorValue(next);
3209 // vi. If mapping is true, then
3210 if (mapping) {
3211 try {
3212 // Polyfill.io - The try catch accounts for step 2.
3213 // 1. Let mappedValue be Call(mapfn, T, « nextValue, k »).
3214 var mappedValue = Call(mapfn, T, [nextValue, k]);
3215 // 2. If mappedValue is an abrupt completion, return ? IteratorClose(iteratorRecord, mappedValue).
3216 // 3. Let mappedValue be mappedValue.[[Value]].
3217 } catch (e) {
3218 return IteratorClose(iteratorRecord, e);
3219 }
3220
3221 // vii. Else, let mappedValue be nextValue.
3222 } else {
3223 mappedValue = nextValue;
3224 }
3225 try {
3226 // Polyfill.io - The try catch accounts for step ix.
3227 // viii. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, mappedValue).
3228 CreateDataPropertyOrThrow(A, Pk, mappedValue);
3229 // ix. If defineStatus is an abrupt completion, return ? IteratorClose(iteratorRecord, defineStatus).
3230 } catch (e) {
3231 return IteratorClose(iteratorRecord, e);
3232 }
3233 // x. Increase k by 1.
3234 k = k + 1;
3235 }
3236 }
3237 // 6. NOTE: items is not an Iterable so assume it is an array-like object.
3238 // 7. Let arrayLike be ! ToObject(items).
3239 // Polyfill.io - For Strings we need to split astral symbols into surrogate pairs.
3240 if (isString(items)) {
3241 var arrayLike = stringMatch.call(items, /[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g) || [];
3242 } else {
3243 arrayLike = ToObject(items);
3244 }
3245 // 8. Let len be ? ToLength(? Get(arrayLike, "length")).
3246 var len = ToLength(Get(arrayLike, "length"));
3247 // 9. If IsConstructor(C) is true, then
3248 if (IsConstructor(C)) {
3249 // a. Let A be ? Construct(C, « len »).
3250 A = Construct(C, [len]);
3251 // 10. Else,
3252 } else {
3253 // a. Let A be ? ArrayCreate(len).
3254 A = ArrayCreate(len);
3255 }
3256 // 11. Let k be 0.
3257 k = 0;
3258 // 12. Repeat, while k < len
3259 while (k < len) {
3260 // a. Let Pk be ! ToString(k).
3261 Pk = ToString(k);
3262 // b. Let kValue be ? Get(arrayLike, Pk).
3263 var kValue = Get(arrayLike, Pk);
3264 // c. If mapping is true, then
3265 if (mapping === true) {
3266 // i. Let mappedValue be ? Call(mapfn, T, « kValue, k »).
3267 mappedValue = Call(mapfn, T, [kValue, k]);
3268 // d. Else, let mappedValue be kValue.
3269 } else {
3270 mappedValue = kValue;
3271 }
3272 // e. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
3273 CreateDataPropertyOrThrow(A, Pk, mappedValue);
3274 // f. Increase k by 1.
3275 k = k + 1;
3276 }
3277 // 13. Perform ? Set(A, "length", len, true).
3278 A["length"] = len;
3279 // 14. Return A.
3280 return A;
3281 });
3282}());
3283
3284// URL
3285/* global Symbol */
3286// URL Polyfill
3287// Draft specification: https://url.spec.whatwg.org
3288
3289// Notes:
3290// - Primarily useful for parsing URLs and modifying query parameters
3291// - Should work in IE8+ and everything more modern, with es5.js polyfills
3292
3293(function (global) {
3294 'use strict';
3295
3296 function isSequence(o) {
3297 if (!o) return false;
3298 if ('Symbol' in global && 'iterator' in global.Symbol &&
3299 typeof o[Symbol.iterator] === 'function') return true;
3300 if (Array.isArray(o)) return true;
3301 return false;
3302 }
3303
3304 function toArray(iter) {
3305 return ('from' in Array) ? Array.from(iter) : Array.prototype.slice.call(iter);
3306 }
3307
3308 (function() {
3309
3310 // Browsers may have:
3311 // * No global URL object
3312 // * URL with static methods only - may have a dummy constructor
3313 // * URL with members except searchParams
3314 // * Full URL API support
3315 var origURL = global.URL;
3316 var nativeURL;
3317 try {
3318 if (origURL) {
3319 nativeURL = new global.URL('http://example.com');
3320 if ('searchParams' in nativeURL) {
3321 var url = new URL('http://example.com');
3322 url.search = 'a=1&b=2';
3323 if (url.href === 'http://example.com/?a=1&b=2') {
3324 url.search = '';
3325 if (url.href === 'http://example.com/') {
3326 return;
3327 }
3328 }
3329 }
3330 if (!('href' in nativeURL)) {
3331 nativeURL = undefined;
3332 }
3333 nativeURL = undefined;
3334 }
3335 } catch (_) {}
3336
3337 // NOTE: Doesn't do the encoding/decoding dance
3338 function urlencoded_serialize(pairs) {
3339 var output = '', first = true;
3340 pairs.forEach(function (pair) {
3341 var name = encodeURIComponent(pair.name);
3342 var value = encodeURIComponent(pair.value);
3343 if (!first) output += '&';
3344 output += name + '=' + value;
3345 first = false;
3346 });
3347 return output.replace(/%20/g, '+');
3348 }
3349
3350 // NOTE: Doesn't do the encoding/decoding dance
3351 function urlencoded_parse(input, isindex) {
3352 var sequences = input.split('&');
3353 if (isindex && sequences[0].indexOf('=') === -1)
3354 sequences[0] = '=' + sequences[0];
3355 var pairs = [];
3356 sequences.forEach(function (bytes) {
3357 if (bytes.length === 0) return;
3358 var index = bytes.indexOf('=');
3359 if (index !== -1) {
3360 var name = bytes.substring(0, index);
3361 var value = bytes.substring(index + 1);
3362 } else {
3363 name = bytes;
3364 value = '';
3365 }
3366 name = name.replace(/\+/g, ' ');
3367 value = value.replace(/\+/g, ' ');
3368 pairs.push({ name: name, value: value });
3369 });
3370 var output = [];
3371 pairs.forEach(function (pair) {
3372 output.push({
3373 name: decodeURIComponent(pair.name),
3374 value: decodeURIComponent(pair.value)
3375 });
3376 });
3377 return output;
3378 }
3379
3380 function URLUtils(url) {
3381 if (nativeURL)
3382 return new origURL(url);
3383 var anchor = document.createElement('a');
3384 anchor.href = url;
3385 return anchor;
3386 }
3387
3388 function URLSearchParams(init) {
3389 var $this = this;
3390 this._list = [];
3391
3392 if (init === undefined || init === null) {
3393 // no-op
3394 } else if (init instanceof URLSearchParams) {
3395 // In ES6 init would be a sequence, but special case for ES5.
3396 this._list = urlencoded_parse(String(init));
3397 } else if (typeof init === 'object' && isSequence(init)) {
3398 toArray(init).forEach(function(e) {
3399 if (!isSequence(e)) throw TypeError();
3400 var nv = toArray(e);
3401 if (nv.length !== 2) throw TypeError();
3402 $this._list.push({name: String(nv[0]), value: String(nv[1])});
3403 });
3404 } else if (typeof init === 'object' && init) {
3405 Object.keys(init).forEach(function(key) {
3406 $this._list.push({name: String(key), value: String(init[key])});
3407 });
3408 } else {
3409 init = String(init);
3410 if (init.substring(0, 1) === '?')
3411 init = init.substring(1);
3412 this._list = urlencoded_parse(init);
3413 }
3414
3415 this._url_object = null;
3416 this._setList = function (list) { if (!updating) $this._list = list; };
3417
3418 var updating = false;
3419 this._update_steps = function() {
3420 if (updating) return;
3421 updating = true;
3422
3423 if (!$this._url_object) return;
3424
3425 // Partial workaround for IE issue with 'about:'
3426 if ($this._url_object.protocol === 'about:' &&
3427 $this._url_object.pathname.indexOf('?') !== -1) {
3428 $this._url_object.pathname = $this._url_object.pathname.split('?')[0];
3429 }
3430
3431 $this._url_object.search = urlencoded_serialize($this._list);
3432
3433 updating = false;
3434 };
3435 }
3436
3437
3438 Object.defineProperties(URLSearchParams.prototype, {
3439 append: {
3440 value: function (name, value) {
3441 this._list.push({ name: name, value: value });
3442 this._update_steps();
3443 }, writable: true, enumerable: true, configurable: true
3444 },
3445
3446 'delete': {
3447 value: function (name) {
3448 for (var i = 0; i < this._list.length;) {
3449 if (this._list[i].name === name)
3450 this._list.splice(i, 1);
3451 else
3452 ++i;
3453 }
3454 this._update_steps();
3455 }, writable: true, enumerable: true, configurable: true
3456 },
3457
3458 get: {
3459 value: function (name) {
3460 for (var i = 0; i < this._list.length; ++i) {
3461 if (this._list[i].name === name)
3462 return this._list[i].value;
3463 }
3464 return null;
3465 }, writable: true, enumerable: true, configurable: true
3466 },
3467
3468 getAll: {
3469 value: function (name) {
3470 var result = [];
3471 for (var i = 0; i < this._list.length; ++i) {
3472 if (this._list[i].name === name)
3473 result.push(this._list[i].value);
3474 }
3475 return result;
3476 }, writable: true, enumerable: true, configurable: true
3477 },
3478
3479 has: {
3480 value: function (name) {
3481 for (var i = 0; i < this._list.length; ++i) {
3482 if (this._list[i].name === name)
3483 return true;
3484 }
3485 return false;
3486 }, writable: true, enumerable: true, configurable: true
3487 },
3488
3489 set: {
3490 value: function (name, value) {
3491 var found = false;
3492 for (var i = 0; i < this._list.length;) {
3493 if (this._list[i].name === name) {
3494 if (!found) {
3495 this._list[i].value = value;
3496 found = true;
3497 ++i;
3498 } else {
3499 this._list.splice(i, 1);
3500 }
3501 } else {
3502 ++i;
3503 }
3504 }
3505
3506 if (!found)
3507 this._list.push({ name: name, value: value });
3508
3509 this._update_steps();
3510 }, writable: true, enumerable: true, configurable: true
3511 },
3512
3513 entries: {
3514 value: function() { return new Iterator(this._list, 'key+value'); },
3515 writable: true, enumerable: true, configurable: true
3516 },
3517
3518 keys: {
3519 value: function() { return new Iterator(this._list, 'key'); },
3520 writable: true, enumerable: true, configurable: true
3521 },
3522
3523 values: {
3524 value: function() { return new Iterator(this._list, 'value'); },
3525 writable: true, enumerable: true, configurable: true
3526 },
3527
3528 forEach: {
3529 value: function(callback) {
3530 var thisArg = (arguments.length > 1) ? arguments[1] : undefined;
3531 this._list.forEach(function(pair) {
3532 callback.call(thisArg, pair.value, pair.name);
3533 });
3534
3535 }, writable: true, enumerable: true, configurable: true
3536 },
3537
3538 toString: {
3539 value: function () {
3540 return urlencoded_serialize(this._list);
3541 }, writable: true, enumerable: false, configurable: true
3542 }
3543 });
3544
3545 function Iterator(source, kind) {
3546 var index = 0;
3547 this['next'] = function() {
3548 if (index >= source.length)
3549 return {done: true, value: undefined};
3550 var pair = source[index++];
3551 return {done: false, value:
3552 kind === 'key' ? pair.name :
3553 kind === 'value' ? pair.value :
3554 [pair.name, pair.value]};
3555 };
3556 }
3557
3558 if ('Symbol' in global && 'iterator' in global.Symbol) {
3559 Object.defineProperty(URLSearchParams.prototype, global.Symbol.iterator, {
3560 value: URLSearchParams.prototype.entries,
3561 writable: true, enumerable: true, configurable: true});
3562 Object.defineProperty(Iterator.prototype, global.Symbol.iterator, {
3563 value: function() { return this; },
3564 writable: true, enumerable: true, configurable: true});
3565 }
3566
3567 function URL(url, base) {
3568 if (!(this instanceof global.URL))
3569 throw new TypeError("Failed to construct 'URL': Please use the 'new' operator.");
3570
3571 if (base) {
3572 url = (function () {
3573 if (nativeURL) return new origURL(url, base).href;
3574 var iframe;
3575 try {
3576 var doc;
3577 // Use another document/base tag/anchor for relative URL resolution, if possible
3578 if (Object.prototype.toString.call(window.operamini) === "[object OperaMini]") {
3579 iframe = document.createElement('iframe');
3580 iframe.style.display = 'none';
3581 document.documentElement.appendChild(iframe);
3582 doc = iframe.contentWindow.document;
3583 } else if (document.implementation && document.implementation.createHTMLDocument) {
3584 doc = document.implementation.createHTMLDocument('');
3585 } else if (document.implementation && document.implementation.createDocument) {
3586 doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);
3587 doc.documentElement.appendChild(doc.createElement('head'));
3588 doc.documentElement.appendChild(doc.createElement('body'));
3589 } else if (window.ActiveXObject) {
3590 doc = new window.ActiveXObject('htmlfile');
3591 doc.write('<head><\/head><body><\/body>');
3592 doc.close();
3593 }
3594
3595 if (!doc) throw Error('base not supported');
3596
3597 var baseTag = doc.createElement('base');
3598 baseTag.href = base;
3599 doc.getElementsByTagName('head')[0].appendChild(baseTag);
3600 var anchor = doc.createElement('a');
3601 anchor.href = url;
3602 return anchor.href;
3603 } finally {
3604 if (iframe)
3605 iframe.parentNode.removeChild(iframe);
3606 }
3607 }());
3608 }
3609
3610 // An inner object implementing URLUtils (either a native URL
3611 // object or an HTMLAnchorElement instance) is used to perform the
3612 // URL algorithms. With full ES5 getter/setter support, return a
3613 // regular object For IE8's limited getter/setter support, a
3614 // different HTMLAnchorElement is returned with properties
3615 // overridden
3616
3617 var instance = URLUtils(url || '');
3618
3619 // Detect for ES5 getter/setter support
3620 // (an Object.defineProperties polyfill that doesn't support getters/setters may throw)
3621 var ES5_GET_SET = (function() {
3622 if (!('defineProperties' in Object)) return false;
3623 try {
3624 var obj = {};
3625 Object.defineProperties(obj, { prop: { 'get': function () { return true; } } });
3626 return obj.prop;
3627 } catch (_) {
3628 return false;
3629 }
3630 }());
3631
3632 var self = ES5_GET_SET ? this : document.createElement('a');
3633
3634
3635
3636 var query_object = new URLSearchParams(
3637 instance.search ? instance.search.substring(1) : null);
3638 query_object._url_object = self;
3639
3640 Object.defineProperties(self, {
3641 href: {
3642 get: function () { return instance.href; },
3643 set: function (v) { instance.href = v; tidy_instance(); update_steps(); },
3644 enumerable: true, configurable: true
3645 },
3646 origin: {
3647 get: function () {
3648 if ('origin' in instance) return instance.origin;
3649 return this.protocol + '//' + this.host;
3650 },
3651 enumerable: true, configurable: true
3652 },
3653 protocol: {
3654 get: function () { return instance.protocol; },
3655 set: function (v) { instance.protocol = v; },
3656 enumerable: true, configurable: true
3657 },
3658 username: {
3659 get: function () { return instance.username; },
3660 set: function (v) { instance.username = v; },
3661 enumerable: true, configurable: true
3662 },
3663 password: {
3664 get: function () { return instance.password; },
3665 set: function (v) { instance.password = v; },
3666 enumerable: true, configurable: true
3667 },
3668 host: {
3669 get: function () {
3670 // IE returns default port in |host|
3671 var re = {'http:': /:80$/, 'https:': /:443$/, 'ftp:': /:21$/}[instance.protocol];
3672 return re ? instance.host.replace(re, '') : instance.host;
3673 },
3674 set: function (v) { instance.host = v; },
3675 enumerable: true, configurable: true
3676 },
3677 hostname: {
3678 get: function () { return instance.hostname; },
3679 set: function (v) { instance.hostname = v; },
3680 enumerable: true, configurable: true
3681 },
3682 port: {
3683 get: function () { return instance.port; },
3684 set: function (v) { instance.port = v; },
3685 enumerable: true, configurable: true
3686 },
3687 pathname: {
3688 get: function () {
3689 // IE does not include leading '/' in |pathname|
3690 if (instance.pathname.charAt(0) !== '/') return '/' + instance.pathname;
3691 return instance.pathname;
3692 },
3693 set: function (v) { instance.pathname = v; },
3694 enumerable: true, configurable: true
3695 },
3696 search: {
3697 get: function () { return instance.search; },
3698 set: function (v) {
3699 if (instance.search === v) return;
3700 instance.search = v; tidy_instance(); update_steps();
3701 },
3702 enumerable: true, configurable: true
3703 },
3704 searchParams: {
3705 get: function () { return query_object; },
3706 enumerable: true, configurable: true
3707 },
3708 hash: {
3709 get: function () { return instance.hash; },
3710 set: function (v) { instance.hash = v; tidy_instance(); },
3711 enumerable: true, configurable: true
3712 },
3713 toString: {
3714 value: function() { return instance.toString(); },
3715 enumerable: false, configurable: true
3716 },
3717 valueOf: {
3718 value: function() { return instance.valueOf(); },
3719 enumerable: false, configurable: true
3720 }
3721 });
3722
3723 function tidy_instance() {
3724 var href = instance.href.replace(/#$|\?$|\?(?=#)/g, '');
3725 if (instance.href !== href)
3726 instance.href = href;
3727 }
3728
3729 function update_steps() {
3730 query_object._setList(instance.search ? urlencoded_parse(instance.search.substring(1)) : []);
3731 query_object._update_steps();
3732 }
3733
3734 return self;
3735 }
3736
3737 if (origURL) {
3738 for (var i in origURL) {
3739 if (origURL.hasOwnProperty(i) && typeof origURL[i] === 'function')
3740 URL[i] = origURL[i];
3741 }
3742 }
3743
3744 global.URL = URL;
3745 global.URLSearchParams = URLSearchParams;
3746 }());
3747
3748 // Patch native URLSearchParams constructor to handle sequences/records
3749 // if necessary.
3750 (function() {
3751 if (new global.URLSearchParams([['a', 1]]).get('a') === '1' &&
3752 new global.URLSearchParams({a: 1}).get('a') === '1')
3753 return;
3754 var orig = global.URLSearchParams;
3755 global.URLSearchParams = function(init) {
3756 if (init && typeof init === 'object' && isSequence(init)) {
3757 var o = new orig();
3758 toArray(init).forEach(function(e) {
3759 if (!isSequence(e)) throw TypeError();
3760 var nv = toArray(e);
3761 if (nv.length !== 2) throw TypeError();
3762 o.append(nv[0], nv[1]);
3763 });
3764 return o;
3765 } else if (init && typeof init === 'object') {
3766 o = new orig();
3767 Object.keys(init).forEach(function(key) {
3768 o.set(key, init[key]);
3769 });
3770 return o;
3771 } else {
3772 return new orig(init);
3773 }
3774 };
3775 }());
3776
3777}(self));
3778})
3779.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});