PageSourceSearch

https://nsdcarena.com/vendor/es6-shim/es6-shim.js

js nsdcarena.com collected 2026-10-02 16:03:21 UTC 134,906 bytes, 3,777 lines download raw bytes

vendor: 9,848 bytes, lines 1-266
1 /*!
2  * https://github.com/paulmillr/es6-shim
3  * @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com)
4  *   and contributors,  MIT License
5  * es6-shim: v0.35.1
6  * see https://github.com/paulmillr/es6-shim/blob/0.35.1/LICENSE
7  * Details and documentation:
8  * https://github.com/paulmillr/es6-shim/
9  */
10
11// UMD (Universal Module Definition)
12// see https://github.com/umdjs/umd/blob/master/returnExports.js
13(function (root, factory) {
14  /*global define, module, exports */
15  if (typeof define === 'function' && define.amd) {
16    // AMD. Register as an anonymous module.
17    define(factory);
18  } else if (typeof exports === 'object') {
19    // Node. Does not work with strict CommonJS, but
20    // only CommonJS-like environments that support module.exports,
21    // like Node.
22    module.exports = factory();
23  } else {
24    // Browser globals (root is window)
25    root.returnExports = factory();
26  }
27}(this, function () {
28  'use strict';
29
30  var _apply = Function.call.bind(Function.apply);
31  var _call = Function.call.bind(Function.call);
32  var isArray = Array.isArray;
33  var keys = Object.keys;
34
35  var not = function notThunker(func) {
36    return function notThunk() {
37      return !_apply(func, this, arguments);
38    };
39  };
40  var throwsError = function (func) {
41    try {
42      func();
43      return false;
44    } catch (e) {
45      return true;
46    }
47  };
48  var valueOrFalseIfThrows = function valueOrFalseIfThrows(func) {
49    try {
50      return func();
51    } catch (e) {
52      return false;
53    }
54  };
55
56  var isCallableWithoutNew = not(throwsError);
57  var arePropertyDescriptorsSupported = function () {
58    // if Object.defineProperty exists but throws, it's IE 8
59    return !throwsError(function () {
60      Object.defineProperty({}, 'x', { get: function () {} });
61    });
62  };
63  var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
64  var functionsHaveNames = (function foo() {}).name === 'foo'; // eslint-disable-line no-extra-parens
65
66  var _forEach = Function.call.bind(Array.prototype.forEach);
67  var _reduce = Function.call.bind(Array.prototype.reduce);
68  var _filter = Function.call.bind(Array.prototype.filter);
69  var _some = Function.call.bind(Array.prototype.some);
70
71  var defineProperty = function (object, name, value, force) {
72    if (!force && name in object) { return; }
73    if (supportsDescriptors) {
74      Object.defineProperty(object, name, {
75        configurable: true,
76        enumerable: false,
77        writable: true,
78        value: value
79      });
80    } else {
81      object[name] = value;
82    }
83  };
84
85  // Define configurable, writable and non-enumerable props
86  // if they don’t exist.
87  var defineProperties = function (object, map, forceOverride) {
88    _forEach(keys(map), function (name) {
89      var method = map[name];
90      defineProperty(object, name, method, !!forceOverride);
91    });
92  };
93
94  var _toString = Function.call.bind(Object.prototype.toString);
95  var isCallable = typeof /abc/ === 'function' ? function IsCallableSlow(x) {
96    // Some old browsers (IE, FF) say that typeof /abc/ === 'function'
97    return typeof x === 'function' && _toString(x) === '[object Function]';
98  } : function IsCallableFast(x) { return typeof x === 'function'; };
99
100  var Value = {
101    getter: function (object, name, getter) {
102      if (!supportsDescriptors) {
103        throw new TypeError('getters require true ES5 support');
104      }
105      Object.defineProperty(object, name, {
106        configurable: true,
107        enumerable: false,
108        get: getter
109      });
110    },
111    proxy: function (originalObject, key, targetObject) {
112      if (!supportsDescriptors) {
113        throw new TypeError('getters require true ES5 support');
114      }
115      var originalDescriptor = Object.getOwnPropertyDescriptor(originalObject, key);
116      Object.defineProperty(targetObject, key, {
117        configurable: originalDescriptor.configurable,
118        enumerable: originalDescriptor.enumerable,
119        get: function getKey() { return originalObject[key]; },
120        set: function setKey(value) { originalObject[key] = value; }
121      });
122    },
123    redefine: function (object, property, newValue) {
124      if (supportsDescriptors) {
125        var descriptor = Object.getOwnPropertyDescriptor(object, property);
126        descriptor.value = newValue;
127        Object.defineProperty(object, property, descriptor);
128      } else {
129        object[property] = newValue;
130      }
131    },
132    defineByDescriptor: function (object, property, descriptor) {
133      if (supportsDescriptors) {
134        Object.defineProperty(object, property, descriptor);
135      } else if ('value' in descriptor) {
136        object[property] = descriptor.value;
137      }
138    },
139    preserveToString: function (target, source) {
140      if (source && isCallable(source.toString)) {
141        defineProperty(target, 'toString', source.toString.bind(source), true);
142      }
143    }
144  };
145
146  // Simple shim for Object.create on ES3 browsers
147  // (unlike real shim, no attempt to support `prototype === null`)
148  var create = Object.create || function (prototype, properties) {
149    var Prototype = function Prototype() {};
150    Prototype.prototype = prototype;
151    var object = new Prototype();
152    if (typeof properties !== 'undefined') {
153      keys(properties).forEach(function (key) {
154        Value.defineByDescriptor(object, key, properties[key]);
155      });
156    }
157    return object;
158  };
159
160  var supportsSubclassing = function (C, f) {
161    if (!Object.setPrototypeOf) { return false; /* skip test on IE < 11 */ }
162    return valueOrFalseIfThrows(function () {
163      var Sub = function Subclass(arg) {
164        var o = new C(arg);
165        Object.setPrototypeOf(o, Subclass.prototype);
166        return o;
167      };
168      Object.setPrototypeOf(Sub, C);
169      Sub.prototype = create(C.prototype, {
170        constructor: { value: Sub }
171      });
172      return f(Sub);
173    });
174  };
175
176  var getGlobal = function () {
177    /* global self, window, global */
178    // the only reliable means to get the global object is
179    // `Function('return this')()`
180    // However, this causes CSP violations in Chrome apps.
181    if (typeof self !== 'undefined') { return self; }
182    if (typeof window !== 'undefined') { return window; }
183    if (typeof global !== 'undefined') { return global; }
184    throw new Error('unable to locate global object');
185  };
186
187  var globals = getGlobal();
188  var globalIsFinite = globals.isFinite;
189  var _indexOf = Function.call.bind(String.prototype.indexOf);
190  var _arrayIndexOfApply = Function.apply.bind(Array.prototype.indexOf);
191  var _concat = Function.call.bind(Array.prototype.concat);
192  // var _sort = Function.call.bind(Array.prototype.sort);
193  var _strSlice = Function.call.bind(String.prototype.slice);
194  var _push = Function.call.bind(Array.prototype.push);
195  var _pushApply = Function.apply.bind(Array.prototype.push);
196  var _shift = Function.call.bind(Array.prototype.shift);
197  var _max = Math.max;
198  var _min = Math.min;
199  var _floor = Math.floor;
200  var _abs = Math.abs;
201  var _exp = Math.exp;
202  var _log = Math.log;
203  var _sqrt = Math.sqrt;
204  var _hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty);
205  var ArrayIterator; // make our implementation private
206  var noop = function () {};
207
208  var Symbol = globals.Symbol || {};
209  var symbolSpecies = Symbol.species || '@@species';
210
211  var numberIsNaN = Number.isNaN || function isNaN(value) {
212    // NaN !== NaN, but they are identical.
213    // NaNs are the only non-reflexive value, i.e., if x !== x,
214    // then x is NaN.
215    // isNaN is broken: it converts its argument to number, so
216    // isNaN('foo') => true
217    return value !== value;
218  };
219  var numberIsFinite = Number.isFinite || function isFinite(value) {
220    return typeof value === 'number' && globalIsFinite(value);
221  };
222  var _sign = isCallable(Math.sign) ? Math.sign : function sign(value) {
223    var number = Number(value);
224    if (number === 0) { return number; }
225    if (numberIsNaN(number)) { return number; }
226    return number < 0 ? -1 : 1;
227  };
228
229  // taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js
230  // can be replaced with require('is-arguments') if we ever use a build process instead
231  var isStandardArguments = function isArguments(value) {
232    return _toString(value) === '[object Arguments]';
233  };
234  var isLegacyArguments = function isArguments(value) {
235    return value !== null &&
236      typeof value === 'object' &&
237      typeof value.length === 'number' &&
238      value.length >= 0 &&
239      _toString(value) !== '[object Array]' &&
240      _toString(value.callee) === '[object Function]';
241  };
242  var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments;
243
244  var Type = {
245    primitive: function (x) { return x === null || (typeof x !== 'function' && typeof x !== 'object'); },
246    string: function (x) { return _toString(x) === '[object String]'; },
247    regex: function (x) { return _toString(x) === '[object RegExp]'; },
248    symbol: function (x) {
249      return typeof globals.Symbol === 'function' && typeof x === 'symbol';
250    }
251  };
252
253  var overrideNative = function overrideNative(object, property, replacement) {
254    var original = object[property];
255    defineProperty(object, property, replacement, true);
256    Value.preserveToString(object[property], original);
257  };
258
259  var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && Type.symbol(Symbol());
260
261  // This is a private name in the es6 spec, equal to '[Symbol.iterator]'
262  // we're going to use an arbitrary _-prefixed name to make our shims
263  // work properly with each other, even though we don't have full Iterator
264  // support.  That is, `Array.from(map.keys())` will work, but we don't
265  // pretend to export a "real" Iterator interface.
266  var $iterator$ = Type.symbol(Symbol.iterator) ? Symbol.iterator : '_es6-shim iterator_';
vendor: 20,587 bytes, lines 267-855
267  // Firefox ships a partial implementation using the name @@iterator.
268  // https://bugzilla.mozilla.org/show_bug.cgi?id=907077#c14
269  // So use that name if we detect it.
270  if (globals.Set && typeof new globals.Set()['@@iterator'] === 'function') {
271    $iterator$ = '@@iterator';
272  }
273
274  // Reflect
275  if (!globals.Reflect) {
276    defineProperty(globals, 'Reflect', {}, true);
277  }
278  var Reflect = globals.Reflect;
279
280  var $String = String;
281
282  var ES = {
283    // http://www.ecma-international.org/ecma-262/6.0/#sec-call
284    Call: function Call(F, V) {
285      var args = arguments.length > 2 ? arguments[2] : [];
286      if (!ES.IsCallable(F)) {
287        throw new TypeError(F + ' is not a function');
288      }
289      return _apply(F, V, args);
290    },
291
292    RequireObjectCoercible: function (x, optMessage) {
293      /* jshint eqnull:true */
294      if (x == null) {
295        throw new TypeError(optMessage || 'Cannot call method on ' + x);
296      }
297      return x;
298    },
299
300    // This might miss the "(non-standard exotic and does not implement
301    // [[Call]])" case from
302    // http://www.ecma-international.org/ecma-262/6.0/#sec-typeof-operator-runtime-semantics-evaluation
303    // but we can't find any evidence these objects exist in practice.
304    // If we find some in the future, you could test `Object(x) === x`,
305    // which is reliable according to
306    // http://www.ecma-international.org/ecma-262/6.0/#sec-toobject
307    // but is not well optimized by runtimes and creates an object
308    // whenever it returns false, and thus is very slow.
309    TypeIsObject: function (x) {
310      if (x === void 0 || x === null || x === true || x === false) {
311        return false;
312      }
313      return typeof x === 'function' || typeof x === 'object';
314    },
315
316    ToObject: function (o, optMessage) {
317      return Object(ES.RequireObjectCoercible(o, optMessage));
318    },
319
320    IsCallable: isCallable,
321
322    IsConstructor: function (x) {
323      // We can't tell callables from constructors in ES5
324      return ES.IsCallable(x);
325    },
326
327    ToInt32: function (x) {
328      return ES.ToNumber(x) >> 0;
329    },
330
331    ToUint32: function (x) {
332      return ES.ToNumber(x) >>> 0;
333    },
334
335    ToNumber: function (value) {
336      if (_toString(value) === '[object Symbol]') {
337        throw new TypeError('Cannot convert a Symbol value to a number');
338      }
339      return +value;
340    },
341
342    ToInteger: function (value) {
343      var number = ES.ToNumber(value);
344      if (numberIsNaN(number)) { return 0; }
345      if (number === 0 || !numberIsFinite(number)) { return number; }
346      return (number > 0 ? 1 : -1) * _floor(_abs(number));
347    },
348
349    ToLength: function (value) {
350      var len = ES.ToInteger(value);
351      if (len <= 0) { return 0; } // includes converting -0 to +0
352      if (len > Number.MAX_SAFE_INTEGER) { return Number.MAX_SAFE_INTEGER; }
353      return len;
354    },
355
356    SameValue: function (a, b) {
357      if (a === b) {
358        // 0 === -0, but they are not identical.
359        if (a === 0) { return 1 / a === 1 / b; }
360        return true;
361      }
362      return numberIsNaN(a) && numberIsNaN(b);
363    },
364
365    SameValueZero: function (a, b) {
366      // same as SameValue except for SameValueZero(+0, -0) == true
367      return (a === b) || (numberIsNaN(a) && numberIsNaN(b));
368    },
369
370    IsIterable: function (o) {
371      return ES.TypeIsObject(o) && (typeof o[$iterator$] !== 'undefined' || isArguments(o));
372    },
373
374    GetIterator: function (o) {
375      if (isArguments(o)) {
376        // special case support for `arguments`
377        return new ArrayIterator(o, 'value');
378      }
379      var itFn = ES.GetMethod(o, $iterator$);
380      if (!ES.IsCallable(itFn)) {
381        // Better diagnostics if itFn is null or undefined
382        throw new TypeError('value is not an iterable');
383      }
384      var it = ES.Call(itFn, o);
385      if (!ES.TypeIsObject(it)) {
386        throw new TypeError('bad iterator');
387      }
388      return it;
389    },
390
391    GetMethod: function (o, p) {
392      var func = ES.ToObject(o)[p];
393      if (func === void 0 || func === null) {
394        return void 0;
395      }
396      if (!ES.IsCallable(func)) {
397        throw new TypeError('Method not callable: ' + p);
398      }
399      return func;
400    },
401
402    IteratorComplete: function (iterResult) {
403      return !!iterResult.done;
404    },
405
406    IteratorClose: function (iterator, completionIsThrow) {
407      var returnMethod = ES.GetMethod(iterator, 'return');
408      if (returnMethod === void 0) {
409        return;
410      }
411      var innerResult, innerException;
412      try {
413        innerResult = ES.Call(returnMethod, iterator);
414      } catch (e) {
415        innerException = e;
416      }
417      if (completionIsThrow) {
418        return;
419      }
420      if (innerException) {
421        throw innerException;
422      }
423      if (!ES.TypeIsObject(innerResult)) {
424        throw new TypeError("Iterator's return method returned a non-object.");
425      }
426    },
427
428    IteratorNext: function (it) {
429      var result = arguments.length > 1 ? it.next(arguments[1]) : it.next();
430      if (!ES.TypeIsObject(result)) {
431        throw new TypeError('bad iterator');
432      }
433      return result;
434    },
435
436    IteratorStep: function (it) {
437      var result = ES.IteratorNext(it);
438      var done = ES.IteratorComplete(result);
439      return done ? false : result;
440    },
441
442    Construct: function (C, args, newTarget, isES6internal) {
443      var target = typeof newTarget === 'undefined' ? C : newTarget;
444
445      if (!isES6internal && Reflect.construct) {
446        // Try to use Reflect.construct if available
447        return Reflect.construct(C, args, target);
448      }
449      // OK, we have to fake it.  This will only work if the
450      // C.[[ConstructorKind]] == "base" -- but that's the only
451      // kind we can make in ES5 code anyway.
452
453      // OrdinaryCreateFromConstructor(target, "%ObjectPrototype%")
454      var proto = target.prototype;
455      if (!ES.TypeIsObject(proto)) {
456        proto = Object.prototype;
457      }
458      var obj = create(proto);
459      // Call the constructor.
460      var result = ES.Call(C, obj, args);
461      return ES.TypeIsObject(result) ? result : obj;
462    },
463
464    SpeciesConstructor: function (O, defaultConstructor) {
465      var C = O.constructor;
466      if (C === void 0) {
467        return defaultConstructor;
468      }
469      if (!ES.TypeIsObject(C)) {
470        throw new TypeError('Bad constructor');
471      }
472      var S = C[symbolSpecies];
473      if (S === void 0 || S === null) {
474        return defaultConstructor;
475      }
476      if (!ES.IsConstructor(S)) {
477        throw new TypeError('Bad @@species');
478      }
479      return S;
480    },
481
482    CreateHTML: function (string, tag, attribute, value) {
483      var S = ES.ToString(string);
484      var p1 = '<' + tag;
485      if (attribute !== '') {
486        var V = ES.ToString(value);
487        var escapedV = V.replace(/"/g, '&quot;');
488        p1 += ' ' + attribute + '="' + escapedV + '"';
489      }
490      var p2 = p1 + '>';
491      var p3 = p2 + S;
492      return p3 + '</' + tag + '>';
493    },
494
495    IsRegExp: function IsRegExp(argument) {
496      if (!ES.TypeIsObject(argument)) {
497        return false;
498      }
499      var isRegExp = argument[Symbol.match];
500      if (typeof isRegExp !== 'undefined') {
501        return !!isRegExp;
502      }
503      return Type.regex(argument);
504    },
505
506    ToString: function ToString(string) {
507      return $String(string);
508    }
509  };
510
511  // Well-known Symbol shims
512  if (supportsDescriptors && hasSymbols) {
513    var defineWellKnownSymbol = function defineWellKnownSymbol(name) {
514      if (Type.symbol(Symbol[name])) {
515        return Symbol[name];
516      }
517      var sym = Symbol['for']('Symbol.' + name);
518      Object.defineProperty(Symbol, name, {
519        configurable: false,
520        enumerable: false,
521        writable: false,
522        value: sym
523      });
524      return sym;
525    };
526    if (!Type.symbol(Symbol.search)) {
527      var symbolSearch = defineWellKnownSymbol('search');
528      var originalSearch = String.prototype.search;
529      defineProperty(RegExp.prototype, symbolSearch, function search(string) {
530        return ES.Call(originalSearch, string, [this]);
531      });
532      var searchShim = function search(regexp) {
533        var O = ES.RequireObjectCoercible(this);
534        if (regexp !== null && typeof regexp !== 'undefined') {
535          var searcher = ES.GetMethod(regexp, symbolSearch);
536          if (typeof searcher !== 'undefined') {
537            return ES.Call(searcher, regexp, [O]);
538          }
539        }
540        return ES.Call(originalSearch, O, [ES.ToString(regexp)]);
541      };
542      overrideNative(String.prototype, 'search', searchShim);
543    }
544    if (!Type.symbol(Symbol.replace)) {
545      var symbolReplace = defineWellKnownSymbol('replace');
546      var originalReplace = String.prototype.replace;
547      defineProperty(RegExp.prototype, symbolReplace, function replace(string, replaceValue) {
548        return ES.Call(originalReplace, string, [this, replaceValue]);
549      });
550      var replaceShim = function replace(searchValue, replaceValue) {
551        var O = ES.RequireObjectCoercible(this);
552        if (searchValue !== null && typeof searchValue !== 'undefined') {
553          var replacer = ES.GetMethod(searchValue, symbolReplace);
554          if (typeof replacer !== 'undefined') {
555            return ES.Call(replacer, searchValue, [O, replaceValue]);
556          }
557        }
558        return ES.Call(originalReplace, O, [ES.ToString(searchValue), replaceValue]);
559      };
560      overrideNative(String.prototype, 'replace', replaceShim);
561    }
562    if (!Type.symbol(Symbol.split)) {
563      var symbolSplit = defineWellKnownSymbol('split');
564      var originalSplit = String.prototype.split;
565      defineProperty(RegExp.prototype, symbolSplit, function split(string, limit) {
566        return ES.Call(originalSplit, string, [this, limit]);
567      });
568      var splitShim = function split(separator, limit) {
569        var O = ES.RequireObjectCoercible(this);
570        if (separator !== null && typeof separator !== 'undefined') {
571          var splitter = ES.GetMethod(separator, symbolSplit);
572          if (typeof splitter !== 'undefined') {
573            return ES.Call(splitter, separator, [O, limit]);
574          }
575        }
576        return ES.Call(originalSplit, O, [ES.ToString(separator), limit]);
577      };
578      overrideNative(String.prototype, 'split', splitShim);
579    }
580    var symbolMatchExists = Type.symbol(Symbol.match);
581    var stringMatchIgnoresSymbolMatch = symbolMatchExists && (function () {
582      // Firefox 41, through Nightly 45 has Symbol.match, but String#match ignores it.
583      // Firefox 40 and below have Symbol.match but String#match works fine.
584      var o = {};
585      o[Symbol.match] = function () { return 42; };
586      return 'a'.match(o) !== 42;
587    }());
588    if (!symbolMatchExists || stringMatchIgnoresSymbolMatch) {
589      var symbolMatch = defineWellKnownSymbol('match');
590
591      var originalMatch = String.prototype.match;
592      defineProperty(RegExp.prototype, symbolMatch, function match(string) {
593        return ES.Call(originalMatch, string, [this]);
594      });
595
596      var matchShim = function match(regexp) {
597        var O = ES.RequireObjectCoercible(this);
598        if (regexp !== null && typeof regexp !== 'undefined') {
599          var matcher = ES.GetMethod(regexp, symbolMatch);
600          if (typeof matcher !== 'undefined') {
601            return ES.Call(matcher, regexp, [O]);
602          }
603        }
604        return ES.Call(originalMatch, O, [ES.ToString(regexp)]);
605      };
606      overrideNative(String.prototype, 'match', matchShim);
607    }
608  }
609
610  var wrapConstructor = function wrapConstructor(original, replacement, keysToSkip) {
611    Value.preserveToString(replacement, original);
612    if (Object.setPrototypeOf) {
613      // sets up proper prototype chain where possible
614      Object.setPrototypeOf(original, replacement);
615    }
616    if (supportsDescriptors) {
617      _forEach(Object.getOwnPropertyNames(original), function (key) {
618        if (key in noop || keysToSkip[key]) { return; }
619        Value.proxy(original, key, replacement);
620      });
621    } else {
622      _forEach(Object.keys(original), function (key) {
623        if (key in noop || keysToSkip[key]) { return; }
624        replacement[key] = original[key];
625      });
626    }
627    replacement.prototype = original.prototype;
628    Value.redefine(original.prototype, 'constructor', replacement);
629  };
630
631  var defaultSpeciesGetter = function () { return this; };
632  var addDefaultSpecies = function (C) {
633    if (supportsDescriptors && !_hasOwnProperty(C, symbolSpecies)) {
634      Value.getter(C, symbolSpecies, defaultSpeciesGetter);
635    }
636  };
637
638  var addIterator = function (prototype, impl) {
639    var implementation = impl || function iterator() { return this; };
640    defineProperty(prototype, $iterator$, implementation);
641    if (!prototype[$iterator$] && Type.symbol($iterator$)) {
642      // implementations are buggy when $iterator$ is a Symbol
643      prototype[$iterator$] = implementation;
644    }
645  };
646
647  var createDataProperty = function createDataProperty(object, name, value) {
648    if (supportsDescriptors) {
649      Object.defineProperty(object, name, {
650        configurable: true,
651        enumerable: true,
652        writable: true,
653        value: value
654      });
655    } else {
656      object[name] = value;
657    }
658  };
659  var createDataPropertyOrThrow = function createDataPropertyOrThrow(object, name, value) {
660    createDataProperty(object, name, value);
661    if (!ES.SameValue(object[name], value)) {
662      throw new TypeError('property is nonconfigurable');
663    }
664  };
665
666  var emulateES6construct = function (o, defaultNewTarget, defaultProto, slots) {
667    // This is an es5 approximation to es6 construct semantics.  in es6,
668    // 'new Foo' invokes Foo.[[Construct]] which (for almost all objects)
669    // just sets the internal variable NewTarget (in es6 syntax `new.target`)
670    // to Foo and then returns Foo().
671
672    // Many ES6 object then have constructors of the form:
673    // 1. If NewTarget is undefined, throw a TypeError exception
674    // 2. Let xxx by OrdinaryCreateFromConstructor(NewTarget, yyy, zzz)
675
676    // So we're going to emulate those first two steps.
677    if (!ES.TypeIsObject(o)) {
678      throw new TypeError('Constructor requires `new`: ' + defaultNewTarget.name);
679    }
680    var proto = defaultNewTarget.prototype;
681    if (!ES.TypeIsObject(proto)) {
682      proto = defaultProto;
683    }
684    var obj = create(proto);
685    for (var name in slots) {
686      if (_hasOwnProperty(slots, name)) {
687        var value = slots[name];
688        defineProperty(obj, name, value, true);
689      }
690    }
691    return obj;
692  };
693
694  // Firefox 31 reports this function's length as 0
695  // https://bugzilla.mozilla.org/show_bug.cgi?id=1062484
696  if (String.fromCodePoint && String.fromCodePoint.length !== 1) {
697    var originalFromCodePoint = String.fromCodePoint;
698    overrideNative(String, 'fromCodePoint', function fromCodePoint(codePoints) {
699      return ES.Call(originalFromCodePoint, this, arguments);
700    });
701  }
702
703  var StringShims = {
704    fromCodePoint: function fromCodePoint(codePoints) {
705      var result = [];
706      var next;
707      for (var i = 0, length = arguments.length; i < length; i++) {
708        next = Number(arguments[i]);
709        if (!ES.SameValue(next, ES.ToInteger(next)) || next < 0 || next > 0x10FFFF) {
710          throw new RangeError('Invalid code point ' + next);
711        }
712
713        if (next < 0x10000) {
714          _push(result, String.fromCharCode(next));
715        } else {
716          next -= 0x10000;
717          _push(result, String.fromCharCode((next >> 10) + 0xD800));
718          _push(result, String.fromCharCode((next % 0x400) + 0xDC00));
719        }
720      }
721      return result.join('');
722    },
723
724    raw: function raw(callSite) {
725      var cooked = ES.ToObject(callSite, 'bad callSite');
726      var rawString = ES.ToObject(cooked.raw, 'bad raw value');
727      var len = rawString.length;
728      var literalsegments = ES.ToLength(len);
729      if (literalsegments <= 0) {
730        return '';
731      }
732
733      var stringElements = [];
734      var nextIndex = 0;
735      var nextKey, next, nextSeg, nextSub;
736      while (nextIndex < literalsegments) {
737        nextKey = ES.ToString(nextIndex);
738        nextSeg = ES.ToString(rawString[nextKey]);
739        _push(stringElements, nextSeg);
740        if (nextIndex + 1 >= literalsegments) {
741          break;
742        }
743        next = nextIndex + 1 < arguments.length ? arguments[nextIndex + 1] : '';
744        nextSub = ES.ToString(next);
745        _push(stringElements, nextSub);
746        nextIndex += 1;
747      }
748      return stringElements.join('');
749    }
750  };
751  if (String.raw && String.raw({ raw: { 0: 'x', 1: 'y', length: 2 } }) !== 'xy') {
752    // IE 11 TP has a broken String.raw implementation
753    overrideNative(String, 'raw', StringShims.raw);
754  }
755  defineProperties(String, StringShims);
756
757  // Fast repeat, uses the `Exponentiation by squaring` algorithm.
758  // Perf: http://jsperf.com/string-repeat2/2
759  var stringRepeat = function repeat(s, times) {
760    if (times < 1) { return ''; }
761    if (times % 2) { return repeat(s, times - 1) + s; }
762    var half = repeat(s, times / 2);
763    return half + half;
764  };
765  var stringMaxLength = Infinity;
766
767  var StringPrototypeShims = {
768    repeat: function repeat(times) {
769      var thisStr = ES.ToString(ES.RequireObjectCoercible(this));
770      var numTimes = ES.ToInteger(times);
771      if (numTimes < 0 || numTimes >= stringMaxLength) {
772        throw new RangeError('repeat count must be less than infinity and not overflow maximum string size');
773      }
774      return stringRepeat(thisStr, numTimes);
775    },
776
777    startsWith: function startsWith(searchString) {
778      var S = ES.ToString(ES.RequireObjectCoercible(this));
779      if (ES.IsRegExp(searchString)) {
780        throw new TypeError('Cannot call method "startsWith" with a regex');
781      }
782      var searchStr = ES.ToString(searchString);
783      var position;
784      if (arguments.length > 1) {
785        position = arguments[1];
786      }
787      var start = _max(ES.ToInteger(position), 0);
788      return _strSlice(S, start, start + searchStr.length) === searchStr;
789    },
790
791    endsWith: function endsWith(searchString) {
792      var S = ES.ToString(ES.RequireObjectCoercible(this));
793      if (ES.IsRegExp(searchString)) {
794        throw new TypeError('Cannot call method "endsWith" with a regex');
795      }
796      var searchStr = ES.ToString(searchString);
797      var len = S.length;
798      var endPosition;
799      if (arguments.length > 1) {
800        endPosition = arguments[1];
801      }
802      var pos = typeof endPosition === 'undefined' ? len : ES.ToInteger(endPosition);
803      var end = _min(_max(pos, 0), len);
804      return _strSlice(S, end - searchStr.length, end) === searchStr;
805    },
806
807    includes: function includes(searchString) {
808      if (ES.IsRegExp(searchString)) {
809        throw new TypeError('"includes" does not accept a RegExp');
810      }
811      var searchStr = ES.ToString(searchString);
812      var position;
813      if (arguments.length > 1) {
814        position = arguments[1];
815      }
816      // Somehow this trick makes method 100% compat with the spec.
817      return _indexOf(this, searchStr, position) !== -1;
818    },
819
820    codePointAt: function codePointAt(pos) {
821      var thisStr = ES.ToString(ES.RequireObjectCoercible(this));
822      var position = ES.ToInteger(pos);
823      var length = thisStr.length;
824      if (position >= 0 && position < length) {
825        var first = thisStr.charCodeAt(position);
826        var isEnd = position + 1 === length;
827        if (first < 0xD800 || first > 0xDBFF || isEnd) { return first; }
828        var second = thisStr.charCodeAt(position + 1);
829        if (second < 0xDC00 || second > 0xDFFF) { return first; }
830        return ((first - 0xD800) * 1024) + (second - 0xDC00) + 0x10000;
831      }
832    }
833  };
834  if (String.prototype.includes && 'a'.includes('a', Infinity) !== false) {
835    overrideNative(String.prototype, 'includes', StringPrototypeShims.includes);
836  }
837
838  if (String.prototype.startsWith && String.prototype.endsWith) {
839    var startsWithRejectsRegex = throwsError(function () {
840      /* throws if spec-compliant */
841      '/a/'.startsWith(/a/);
842    });
843    var startsWithHandlesInfinity = valueOrFalseIfThrows(function () {
844      return 'abc'.startsWith('a', Infinity) === false;
845    });
846    if (!startsWithRejectsRegex || !startsWithHandlesInfinity) {
847      // Firefox (< 37?) and IE 11 TP have a noncompliant startsWith implementation
848      overrideNative(String.prototype, 'startsWith', StringPrototypeShims.startsWith);
849      overrideNative(String.prototype, 'endsWith', StringPrototypeShims.endsWith);
850    }
851  }
852  if (hasSymbols) {
853    var startsWithSupportsSymbolMatch = valueOrFalseIfThrows(function () {
854      var re = /a/;
855      re[Symbol.match] = false;
vendor: 4,648 bytes, lines 856-991
856      return '/a/'.startsWith(re);
857    });
858    if (!startsWithSupportsSymbolMatch) {
859      overrideNative(String.prototype, 'startsWith', StringPrototypeShims.startsWith);
860    }
861    var endsWithSupportsSymbolMatch = valueOrFalseIfThrows(function () {
862      var re = /a/;
863      re[Symbol.match] = false;
864      return '/a/'.endsWith(re);
865    });
866    if (!endsWithSupportsSymbolMatch) {
867      overrideNative(String.prototype, 'endsWith', StringPrototypeShims.endsWith);
868    }
869    var includesSupportsSymbolMatch = valueOrFalseIfThrows(function () {
870      var re = /a/;
871      re[Symbol.match] = false;
872      return '/a/'.includes(re);
873    });
874    if (!includesSupportsSymbolMatch) {
875      overrideNative(String.prototype, 'includes', StringPrototypeShims.includes);
876    }
877  }
878
879  defineProperties(String.prototype, StringPrototypeShims);
880
881  // whitespace from: http://es5.github.io/#x15.5.4.20
882  // implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324
883  var ws = [
884    '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003',
885    '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028',
886    '\u2029\uFEFF'
887  ].join('');
888  var trimRegexp = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
889  var trimShim = function trim() {
890    return ES.ToString(ES.RequireObjectCoercible(this)).replace(trimRegexp, '');
891  };
892  var nonWS = ['\u0085', '\u200b', '\ufffe'].join('');
893  var nonWSregex = new RegExp('[' + nonWS + ']', 'g');
894  var isBadHexRegex = /^[\-+]0x[0-9a-f]+$/i;
895  var hasStringTrimBug = nonWS.trim().length !== nonWS.length;
896  defineProperty(String.prototype, 'trim', trimShim, hasStringTrimBug);
897
898  // Given an argument x, it will return an IteratorResult object,
899  // with value set to x and done to false.
900  // Given no arguments, it will return an iterator completion object.
901  var iteratorResult = function (x) {
902    return { value: x, done: arguments.length === 0 };
903  };
904
905  // see http://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype-@@iterator
906  var StringIterator = function (s) {
907    ES.RequireObjectCoercible(s);
908    this._s = ES.ToString(s);
909    this._i = 0;
910  };
911  StringIterator.prototype.next = function () {
912    var s = this._s;
913    var i = this._i;
914    if (typeof s === 'undefined' || i >= s.length) {
915      this._s = void 0;
916      return iteratorResult();
917    }
918    var first = s.charCodeAt(i);
919    var second, len;
920    if (first < 0xD800 || first > 0xDBFF || (i + 1) === s.length) {
921      len = 1;
922    } else {
923      second = s.charCodeAt(i + 1);
924      len = (second < 0xDC00 || second > 0xDFFF) ? 1 : 2;
925    }
926    this._i = i + len;
927    return iteratorResult(s.substr(i, len));
928  };
929  addIterator(StringIterator.prototype);
930  addIterator(String.prototype, function () {
931    return new StringIterator(this);
932  });
933
934  var ArrayShims = {
935    from: function from(items) {
936      var C = this;
937      var mapFn;
938      if (arguments.length > 1) {
939        mapFn = arguments[1];
940      }
941      var mapping, T;
942      if (typeof mapFn === 'undefined') {
943        mapping = false;
944      } else {
945        if (!ES.IsCallable(mapFn)) {
946          throw new TypeError('Array.from: when provided, the second argument must be a function');
947        }
948        if (arguments.length > 2) {
949          T = arguments[2];
950        }
951        mapping = true;
952      }
953
954      // Note that that Arrays will use ArrayIterator:
955      // https://bugs.ecmascript.org/show_bug.cgi?id=2416
956      var usingIterator = typeof (isArguments(items) || ES.GetMethod(items, $iterator$)) !== 'undefined';
957
958      var length, result, i;
959      if (usingIterator) {
960        result = ES.IsConstructor(C) ? Object(new C()) : [];
961        var iterator = ES.GetIterator(items);
962        var next, nextValue;
963
964        i = 0;
965        while (true) {
966          next = ES.IteratorStep(iterator);
967          if (next === false) {
968            break;
969          }
970          nextValue = next.value;
971          try {
972            if (mapping) {
973              nextValue = typeof T === 'undefined' ? mapFn(nextValue, i) : _call(mapFn, T, nextValue, i);
974            }
975            result[i] = nextValue;
976          } catch (e) {
977            ES.IteratorClose(iterator, true);
978            throw e;
979          }
980          i += 1;
981        }
982        length = i;
983      } else {
984        var arrayLike = ES.ToObject(items);
985        length = ES.ToLength(arrayLike.length);
986        result = ES.IsConstructor(C) ? Object(new C(length)) : new Array(length);
987        var value;
988        for (i = 0; i < length; ++i) {
989          value = arrayLike[i];
990          if (mapping) {
991            value = typeof T === 'undefined' ? mapFn(value, i) : _
vendor: 7,922 bytes, lines 991-1241
991call(mapFn, T, value, i);
992          }
993          createDataPropertyOrThrow(result, i, value);
994        }
995      }
996
997      result.length = length;
998      return result;
999    },
1000
1001    of: function of() {
1002      var len = arguments.length;
1003      var C = this;
1004      var A = isArray(C) || !ES.IsCallable(C) ? new Array(len) : ES.Construct(C, [len]);
1005      for (var k = 0; k < len; ++k) {
1006        createDataPropertyOrThrow(A, k, arguments[k]);
1007      }
1008      A.length = len;
1009      return A;
1010    }
1011  };
1012  defineProperties(Array, ArrayShims);
1013  addDefaultSpecies(Array);
1014
1015  // Our ArrayIterator is private; see
1016  // https://github.com/paulmillr/es6-shim/issues/252
1017  ArrayIterator = function (array, kind) {
1018    this.i = 0;
1019    this.array = array;
1020    this.kind = kind;
1021  };
1022
1023  defineProperties(ArrayIterator.prototype, {
1024    next: function () {
1025      var i = this.i;
1026      var array = this.array;
1027      if (!(this instanceof ArrayIterator)) {
1028        throw new TypeError('Not an ArrayIterator');
1029      }
1030      if (typeof array !== 'undefined') {
1031        var len = ES.ToLength(array.length);
1032        for (; i < len; i++) {
1033          var kind = this.kind;
1034          var retval;
1035          if (kind === 'key') {
1036            retval = i;
1037          } else if (kind === 'value') {
1038            retval = array[i];
1039          } else if (kind === 'entry') {
1040            retval = [i, array[i]];
1041          }
1042          this.i = i + 1;
1043          return iteratorResult(retval);
1044        }
1045      }
1046      this.array = void 0;
1047      return iteratorResult();
1048    }
1049  });
1050  addIterator(ArrayIterator.prototype);
1051
1052/*
1053  var orderKeys = function orderKeys(a, b) {
1054    var aNumeric = String(ES.ToInteger(a)) === a;
1055    var bNumeric = String(ES.ToInteger(b)) === b;
1056    if (aNumeric && bNumeric) {
1057      return b - a;
1058    } else if (aNumeric && !bNumeric) {
1059      return -1;
1060    } else if (!aNumeric && bNumeric) {
1061      return 1;
1062    } else {
1063      return a.localeCompare(b);
1064    }
1065  };
1066
1067  var getAllKeys = function getAllKeys(object) {
1068    var ownKeys = [];
1069    var keys = [];
1070
1071    for (var key in object) {
1072      _push(_hasOwnProperty(object, key) ? ownKeys : keys, key);
1073    }
1074    _sort(ownKeys, orderKeys);
1075    _sort(keys, orderKeys);
1076
1077    return _concat(ownKeys, keys);
1078  };
1079  */
1080
1081  // note: this is positioned here because it depends on ArrayIterator
1082  var arrayOfSupportsSubclassing = Array.of === ArrayShims.of || (function () {
1083    // Detects a bug in Webkit nightly r181886
1084    var Foo = function Foo(len) { this.length = len; };
1085    Foo.prototype = [];
1086    var fooArr = Array.of.apply(Foo, [1, 2]);
1087    return fooArr instanceof Foo && fooArr.length === 2;
1088  }());
1089  if (!arrayOfSupportsSubclassing) {
1090    overrideNative(Array, 'of', ArrayShims.of);
1091  }
1092
1093  var ArrayPrototypeShims = {
1094    copyWithin: function copyWithin(target, start) {
1095      var o = ES.ToObject(this);
1096      var len = ES.ToLength(o.length);
1097      var relativeTarget = ES.ToInteger(target);
1098      var relativeStart = ES.ToInteger(start);
1099      var to = relativeTarget < 0 ? _max(len + relativeTarget, 0) : _min(relativeTarget, len);
1100      var from = relativeStart < 0 ? _max(len + relativeStart, 0) : _min(relativeStart, len);
1101      var end;
1102      if (arguments.length > 2) {
1103        end = arguments[2];
1104      }
1105      var relativeEnd = typeof end === 'undefined' ? len : ES.ToInteger(end);
1106      var finalItem = relativeEnd < 0 ? _max(len + relativeEnd, 0) : _min(relativeEnd, len);
1107      var count = _min(finalItem - from, len - to);
1108      var direction = 1;
1109      if (from < to && to < (from + count)) {
1110        direction = -1;
1111        from += count - 1;
1112        to += count - 1;
1113      }
1114      while (count > 0) {
1115        if (from in o) {
1116          o[to] = o[from];
1117        } else {
1118          delete o[to];
1119        }
1120        from += direction;
1121        to += direction;
1122        count -= 1;
1123      }
1124      return o;
1125    },
1126
1127    fill: function fill(value) {
1128      var start;
1129      if (arguments.length > 1) {
1130        start = arguments[1];
1131      }
1132      var end;
1133      if (arguments.length > 2) {
1134        end = arguments[2];
1135      }
1136      var O = ES.ToObject(this);
1137      var len = ES.ToLength(O.length);
1138      start = ES.ToInteger(typeof start === 'undefined' ? 0 : start);
1139      end = ES.ToInteger(typeof end === 'undefined' ? len : end);
1140
1141      var relativeStart = start < 0 ? _max(len + start, 0) : _min(start, len);
1142      var relativeEnd = end < 0 ? len + end : end;
1143
1144      for (var i = relativeStart; i < len && i < relativeEnd; ++i) {
1145        O[i] = value;
1146      }
1147      return O;
1148    },
1149
1150    find: function find(predicate) {
1151      var list = ES.ToObject(this);
1152      var length = ES.ToLength(list.length);
1153      if (!ES.IsCallable(predicate)) {
1154        throw new TypeError('Array#find: predicate must be a function');
1155      }
1156      var thisArg = arguments.length > 1 ? arguments[1] : null;
1157      for (var i = 0, value; i < length; i++) {
1158        value = list[i];
1159        if (thisArg) {
1160          if (_call(predicate, thisArg, value, i, list)) {
1161            return value;
1162          }
1163        } else if (predicate(value, i, list)) {
1164          return value;
1165        }
1166      }
1167    },
1168
1169    findIndex: function findIndex(predicate) {
1170      var list = ES.ToObject(this);
1171      var length = ES.ToLength(list.length);
1172      if (!ES.IsCallable(predicate)) {
1173        throw new TypeError('Array#findIndex: predicate must be a function');
1174      }
1175      var thisArg = arguments.length > 1 ? arguments[1] : null;
1176      for (var i = 0; i < length; i++) {
1177        if (thisArg) {
1178          if (_call(predicate, thisArg, list[i], i, list)) {
1179            return i;
1180          }
1181        } else if (predicate(list[i], i, list)) {
1182          return i;
1183        }
1184      }
1185      return -1;
1186    },
1187
1188    keys: function keys() {
1189      return new ArrayIterator(this, 'key');
1190    },
1191
1192    values: function values() {
1193      return new ArrayIterator(this, 'value');
1194    },
1195
1196    entries: function entries() {
1197      return new ArrayIterator(this, 'entry');
1198    }
1199  };
1200  // Safari 7.1 defines Array#keys and Array#entries natively,
1201  // but the resulting ArrayIterator objects don't have a "next" method.
1202  if (Array.prototype.keys && !ES.IsCallable([1].keys().next)) {
1203    delete Array.prototype.keys;
1204  }
1205  if (Array.prototype.entries && !ES.IsCallable([1].entries().next)) {
1206    delete Array.prototype.entries;
1207  }
1208
1209  // Chrome 38 defines Array#keys and Array#entries, and Array#@@iterator, but not Array#values
1210  if (Array.prototype.keys && Array.prototype.entries && !Array.prototype.values && Array.prototype[$iterator$]) {
1211    defineProperties(Array.prototype, {
1212      values: Array.prototype[$iterator$]
1213    });
1214    if (Type.symbol(Symbol.unscopables)) {
1215      Array.prototype[Symbol.unscopables].values = true;
1216    }
1217  }
1218  // Chrome 40 defines Array#values with the incorrect name, although Array#{keys,entries} have the correct name
1219  if (functionsHaveNames && Array.prototype.values && Array.prototype.values.name !== 'values') {
1220    var originalArrayPrototypeValues = Array.prototype.values;
1221    overrideNative(Array.prototype, 'values', function values() { return ES.Call(originalArrayPrototypeValues, this, arguments); });
1222    defineProperty(Array.prototype, $iterator$, Array.prototype.values, true);
1223  }
1224  defineProperties(Array.prototype, ArrayPrototypeShims);
1225
1226  if (1 / [true].indexOf(true, -0) < 0) {
1227    // indexOf when given a position arg of -0 should return +0.
1228    // https://github.com/tc39/ecma262/pull/316
1229    defineProperty(Array.prototype, 'indexOf', function indexOf(searchElement) {
1230      var value = _arrayIndexOfApply(this, arguments);
1231      if (value === 0 && (1 / value) < 0) {
1232        return 0;
1233      }
1234      return value;
1235    }, true);
1236  }
1237
1238  addIterator(Array.prototype, function () { return this.values(); });
1239  // Chrome defines keys/values/entries on Array, but doesn't give us
1240  // any way to identify its iterator.  So add our own shimmed field.
1241  if (Object.getPrototypeOf) {
vendor: 4,182 bytes, lines 1242-1341
1242    addIterator(Object.getPrototypeOf([].values()));
1243  }
1244
1245  // note: this is positioned here because it relies on Array#entries
1246  var arrayFromSwallowsNegativeLengths = (function () {
1247    // Detects a Firefox bug in v32
1248    // https://bugzilla.mozilla.org/show_bug.cgi?id=1063993
1249    return valueOrFalseIfThrows(function () {
1250      return Array.from({ length: -1 }).length === 0;
1251    });
1252  }());
1253  var arrayFromHandlesIterables = (function () {
1254    // Detects a bug in Webkit nightly r181886
1255    var arr = Array.from([0].entries());
1256    return arr.length === 1 && isArray(arr[0]) && arr[0][0] === 0 && arr[0][1] === 0;
1257  }());
1258  if (!arrayFromSwallowsNegativeLengths || !arrayFromHandlesIterables) {
1259    overrideNative(Array, 'from', ArrayShims.from);
1260  }
1261  var arrayFromHandlesUndefinedMapFunction = (function () {
1262    // Microsoft Edge v0.11 throws if the mapFn argument is *provided* but undefined,
1263    // but the spec doesn't care if it's provided or not - undefined doesn't throw.
1264    return valueOrFalseIfThrows(function () {
1265      return Array.from([0], void 0);
1266    });
1267  }());
1268  if (!arrayFromHandlesUndefinedMapFunction) {
1269    var origArrayFrom = Array.from;
1270    overrideNative(Array, 'from', function from(items) {
1271      if (arguments.length > 1 && typeof arguments[1] !== 'undefined') {
1272        return ES.Call(origArrayFrom, this, arguments);
1273      } else {
1274        return _call(origArrayFrom, this, items);
1275      }
1276    });
1277  }
1278
1279  var int32sAsOne = -(Math.pow(2, 32) - 1);
1280  var toLengthsCorrectly = function (method, reversed) {
1281    var obj = { length: int32sAsOne };
1282    obj[reversed ? (obj.length >>> 0) - 1 : 0] = true;
1283    return valueOrFalseIfThrows(function () {
1284      _call(method, obj, function () {
1285        // note: in nonconforming browsers, this will be called
1286        // -1 >>> 0 times, which is 4294967295, so the throw matters.
1287        throw new RangeError('should not reach here');
1288      }, []);
1289      return true;
1290    });
1291  };
1292  if (!toLengthsCorrectly(Array.prototype.forEach)) {
1293    var originalForEach = Array.prototype.forEach;
1294    overrideNative(Array.prototype, 'forEach', function forEach(callbackFn) {
1295      return ES.Call(originalForEach, this.length >= 0 ? this : [], arguments);
1296    }, true);
1297  }
1298  if (!toLengthsCorrectly(Array.prototype.map)) {
1299    var originalMap = Array.prototype.map;
1300    overrideNative(Array.prototype, 'map', function map(callbackFn) {
1301      return ES.Call(originalMap, this.length >= 0 ? this : [], arguments);
1302    }, true);
1303  }
1304  if (!toLengthsCorrectly(Array.prototype.filter)) {
1305    var originalFilter = Array.prototype.filter;
1306    overrideNative(Array.prototype, 'filter', function filter(callbackFn) {
1307      return ES.Call(originalFilter, this.length >= 0 ? this : [], arguments);
1308    }, true);
1309  }
1310  if (!toLengthsCorrectly(Array.prototype.some)) {
1311    var originalSome = Array.prototype.some;
1312    overrideNative(Array.prototype, 'some', function some(callbackFn) {
1313      return ES.Call(originalSome, this.length >= 0 ? this : [], arguments);
1314    }, true);
1315  }
1316  if (!toLengthsCorrectly(Array.prototype.every)) {
1317    var originalEvery = Array.prototype.every;
1318    overrideNative(Array.prototype, 'every', function every(callbackFn) {
1319      return ES.Call(originalEvery, this.length >= 0 ? this : [], arguments);
1320    }, true);
1321  }
1322  if (!toLengthsCorrectly(Array.prototype.reduce)) {
1323    var originalReduce = Array.prototype.reduce;
1324    overrideNative(Array.prototype, 'reduce', function reduce(callbackFn) {
1325      return ES.Call(originalReduce, this.length >= 0 ? this : [], arguments);
1326    }, true);
1327  }
1328  if (!toLengthsCorrectly(Array.prototype.reduceRight, true)) {
1329    var originalReduceRight = Array.prototype.reduceRight;
1330    overrideNative(Array.prototype, 'reduceRight', function reduceRight(callbackFn) {
1331      return ES.Call(originalReduceRight, this.length >= 0 ? this : [], arguments);
1332    }, true);
1333  }
1334
1335  var lacksOctalSupport = Number('0o10') !== 8;
1336  var lacksBinarySupport = Number('0b10') !== 2;
1337  var trimsNonWhitespace = _some(nonWS, function (c) {
1338    return Number(c + 0 + c) === 0;
1339  });
1340  if (lacksOctalSupport || lacksBinarySupport || trimsNonWhitespace) {
1341    var OrigNumber = Number;
vendor: 9,389 bytes, lines 1342-1592
1342    var binaryRegex = /^0b[01]+$/i;
1343    var octalRegex = /^0o[0-7]+$/i;
1344    // Note that in IE 8, RegExp.prototype.test doesn't seem to exist: ie, "test" is an own property of regexes. wtf.
1345    var isBinary = binaryRegex.test.bind(binaryRegex);
1346    var isOctal = octalRegex.test.bind(octalRegex);
1347    var toPrimitive = function (O) { // need to replace this with `es-to-primitive/es6`
1348      var result;
1349      if (typeof O.valueOf === 'function') {
1350        result = O.valueOf();
1351        if (Type.primitive(result)) {
1352          return result;
1353        }
1354      }
1355      if (typeof O.toString === 'function') {
1356        result = O.toString();
1357        if (Type.primitive(result)) {
1358          return result;
1359        }
1360      }
1361      throw new TypeError('No default value');
1362    };
1363    var hasNonWS = nonWSregex.test.bind(nonWSregex);
1364    var isBadHex = isBadHexRegex.test.bind(isBadHexRegex);
1365    var NumberShim = (function () {
1366      // this is wrapped in an IIFE because of IE 6-8's wacky scoping issues with named function expressions.
1367      var NumberShim = function Number(value) {
1368        var primValue;
1369        if (arguments.length > 0) {
1370          primValue = Type.primitive(value) ? value : toPrimitive(value, 'number');
1371        } else {
1372          primValue = 0;
1373        }
1374        if (typeof primValue === 'string') {
1375          primValue = ES.Call(trimShim, primValue);
1376          if (isBinary(primValue)) {
1377            primValue = parseInt(_strSlice(primValue, 2), 2);
1378          } else if (isOctal(primValue)) {
1379            primValue = parseInt(_strSlice(primValue, 2), 8);
1380          } else if (hasNonWS(primValue) || isBadHex(primValue)) {
1381            primValue = NaN;
1382          }
1383        }
1384        var receiver = this;
1385        var valueOfSucceeds = valueOrFalseIfThrows(function () {
1386          OrigNumber.prototype.valueOf.call(receiver);
1387          return true;
1388        });
1389        if (receiver instanceof NumberShim && !valueOfSucceeds) {
1390          return new OrigNumber(primValue);
1391        }
1392        /* jshint newcap: false */
1393        return OrigNumber(primValue);
1394        /* jshint newcap: true */
1395      };
1396      return NumberShim;
1397    }());
1398    wrapConstructor(OrigNumber, NumberShim, {});
1399    // this is necessary for ES3 browsers, where these properties are non-enumerable.
1400    defineProperties(NumberShim, {
1401      NaN: OrigNumber.NaN,
1402      MAX_VALUE: OrigNumber.MAX_VALUE,
1403      MIN_VALUE: OrigNumber.MIN_VALUE,
1404      NEGATIVE_INFINITY: OrigNumber.NEGATIVE_INFINITY,
1405      POSITIVE_INFINITY: OrigNumber.POSITIVE_INFINITY
1406    });
1407    /* globals Number: true */
1408    /* eslint-disable no-undef */
1409    /* jshint -W020 */
1410    Number = NumberShim;
1411    Value.redefine(globals, 'Number', NumberShim);
1412    /* jshint +W020 */
1413    /* eslint-enable no-undef */
1414    /* globals Number: false */
1415  }
1416
1417  var maxSafeInteger = Math.pow(2, 53) - 1;
1418  defineProperties(Number, {
1419    MAX_SAFE_INTEGER: maxSafeInteger,
1420    MIN_SAFE_INTEGER: -maxSafeInteger,
1421    EPSILON: 2.220446049250313e-16,
1422
1423    parseInt: globals.parseInt,
1424    parseFloat: globals.parseFloat,
1425
1426    isFinite: numberIsFinite,
1427
1428    isInteger: function isInteger(value) {
1429      return numberIsFinite(value) && ES.ToInteger(value) === value;
1430    },
1431
1432    isSafeInteger: function isSafeInteger(value) {
1433      return Number.isInteger(value) && _abs(value) <= Number.MAX_SAFE_INTEGER;
1434    },
1435
1436    isNaN: numberIsNaN
1437  });
1438  // Firefox 37 has a conforming Number.parseInt, but it's not === to the global parseInt (fixed in v40)
1439  defineProperty(Number, 'parseInt', globals.parseInt, Number.parseInt !== globals.parseInt);
1440
1441  // Work around bugs in Array#find and Array#findIndex -- early
1442  // implementations skipped holes in sparse arrays. (Note that the
1443  // implementations of find/findIndex indirectly use shimmed
1444  // methods of Number, so this test has to happen down here.)
1445  /*jshint elision: true */
1446  /* eslint-disable no-sparse-arrays */
1447  if (![, 1].find(function (item, idx) { return idx === 0; })) {
1448    overrideNative(Array.prototype, 'find', ArrayPrototypeShims.find);
1449  }
1450  if ([, 1].findIndex(function (item, idx) { return idx === 0; }) !== 0) {
1451    overrideNative(Array.prototype, 'findIndex', ArrayPrototypeShims.findIndex);
1452  }
1453  /* eslint-enable no-sparse-arrays */
1454  /*jshint elision: false */
1455
1456  var isEnumerableOn = Function.bind.call(Function.bind, Object.prototype.propertyIsEnumerable);
1457  var ensureEnumerable = function ensureEnumerable(obj, prop) {
1458    if (supportsDescriptors && isEnumerableOn(obj, prop)) {
1459      Object.defineProperty(obj, prop, { enumerable: false });
1460    }
1461  };
1462  var sliceArgs = function sliceArgs() {
1463    // per https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments
1464    // and https://gist.github.com/WebReflection/4327762cb87a8c634a29
1465    var initial = Number(this);
1466    var len = arguments.length;
1467    var desiredArgCount = len - initial;
1468    var args = new Array(desiredArgCount < 0 ? 0 : desiredArgCount);
1469    for (var i = initial; i < len; ++i) {
1470      args[i - initial] = arguments[i];
1471    }
1472    return args;
1473  };
1474  var assignTo = function assignTo(source) {
1475    return function assignToSource(target, key) {
1476      target[key] = source[key];
1477      return target;
1478    };
1479  };
1480  var assignReducer = function (target, source) {
1481    var sourceKeys = keys(Object(source));
1482    var symbols;
1483    if (ES.IsCallable(Object.getOwnPropertySymbols)) {
1484      symbols = _filter(Object.getOwnPropertySymbols(Object(source)), isEnumerableOn(source));
1485    }
1486    return _reduce(_concat(sourceKeys, symbols || []), assignTo(source), target);
1487  };
1488
1489  var ObjectShims = {
1490    // 19.1.3.1
1491    assign: function (target, source) {
1492      var to = ES.ToObject(target, 'Cannot convert undefined or null to object');
1493      return _reduce(ES.Call(sliceArgs, 1, arguments), assignReducer, to);
1494    },
1495
1496    // Added in WebKit in https://bugs.webkit.org/show_bug.cgi?id=143865
1497    is: function is(a, b) {
1498      return ES.SameValue(a, b);
1499    }
1500  };
1501  var assignHasPendingExceptions = Object.assign && Object.preventExtensions && (function () {
1502    // Firefox 37 still has "pending exception" logic in its Object.assign implementation,
1503    // which is 72% slower than our shim, and Firefox 40's native implementation.
1504    var thrower = Object.preventExtensions({ 1: 2 });
1505    try {
1506      Object.assign(thrower, 'xy');
1507    } catch (e) {
1508      return thrower[1] === 'y';
1509    }
1510  }());
1511  if (assignHasPendingExceptions) {
1512    overrideNative(Object, 'assign', ObjectShims.assign);
1513  }
1514  defineProperties(Object, ObjectShims);
1515
1516  if (supportsDescriptors) {
1517    var ES5ObjectShims = {
1518      // 19.1.3.9
1519      // shim from https://gist.github.com/WebReflection/5593554
1520      setPrototypeOf: (function (Object, magic) {
1521        var set;
1522
1523        var checkArgs = function (O, proto) {
1524          if (!ES.TypeIsObject(O)) {
1525            throw new TypeError('cannot set prototype on a non-object');
1526          }
1527          if (!(proto === null || ES.TypeIsObject(proto))) {
1528            throw new TypeError('can only set prototype to an object or null' + proto);
1529          }
1530        };
1531
1532        var setPrototypeOf = function (O, proto) {
1533          checkArgs(O, proto);
1534          _call(set, O, proto);
1535          return O;
1536        };
1537
1538        try {
1539          // this works already in Firefox and Safari
1540          set = Object.getOwnPropertyDescriptor(Object.prototype, magic).set;
1541          _call(set, {}, null);
1542        } catch (e) {
1543          if (Object.prototype !== {}[magic]) {
1544            // IE < 11 cannot be shimmed
1545            return;
1546          }
1547          // probably Chrome or some old Mobile stock browser
1548          set = function (proto) {
1549            this[magic] = proto;
1550          };
1551          // please note that this will **not** work
1552          // in those browsers that do not inherit
1553          // __proto__ by mistake from Object.prototype
1554          // in these cases we should probably throw an error
1555          // or at least be informed about the issue
1556          setPrototypeOf.polyfill = setPrototypeOf(
1557            setPrototypeOf({}, null),
1558            Object.prototype
1559          ) instanceof Object;
1560          // setPrototypeOf.polyfill === true means it works as meant
1561          // setPrototypeOf.polyfill === false means it's not 100% reliable
1562          // setPrototypeOf.polyfill === undefined
1563          // or
1564          // setPrototypeOf.polyfill ==  null means it's not a polyfill
1565          // which means it works as expected
1566          // we can even delete Object.prototype.__proto__;
1567        }
1568        return setPrototypeOf;
1569      }(Object, '__proto__'))
1570    };
1571
1572    defineProperties(Object, ES5ObjectShims);
1573  }
1574
1575  // Workaround bug in Opera 12 where setPrototypeOf(x, null) doesn't work,
1576  // but Object.create(null) does.
1577  if (Object.setPrototypeOf && Object.getPrototypeOf &&
1578      Object.getPrototypeOf(Object.setPrototypeOf({}, null)) !== null &&
1579      Object.getPrototypeOf(Object.create(null)) === null) {
1580    (function () {
1581      var FAKENULL = Object.create(null);
1582      var gpo = Object.getPrototypeOf;
1583      var spo = Object.setPrototypeOf;
1584      Object.getPrototypeOf = function (o) {
1585        var result = gpo(o);
1586        return result === FAKENULL ? null : result;
1587      };
1588      Object.setPrototypeOf = function (o, p) {
1589        var proto = p === null ? FAKENULL : p;
1590        return spo(o, proto);
1591      };
1592      Object.setPrototypeOf.polyfill = false;
vendor: 6,296 bytes, lines 1593-1757
1593    }());
1594  }
1595
1596  var objectKeysAcceptsPrimitives = !throwsError(function () { Object.keys('foo'); });
1597  if (!objectKeysAcceptsPrimitives) {
1598    var originalObjectKeys = Object.keys;
1599    overrideNative(Object, 'keys', function keys(value) {
1600      return originalObjectKeys(ES.ToObject(value));
1601    });
1602    keys = Object.keys;
1603  }
1604  var objectKeysRejectsRegex = throwsError(function () { Object.keys(/a/g); });
1605  if (objectKeysRejectsRegex) {
1606    var regexRejectingObjectKeys = Object.keys;
1607    overrideNative(Object, 'keys', function keys(value) {
1608      if (Type.regex(value)) {
1609        var regexKeys = [];
1610        for (var k in value) {
1611          if (_hasOwnProperty(value, k)) {
1612            _push(regexKeys, k);
1613          }
1614        }
1615        return regexKeys;
1616      }
1617      return regexRejectingObjectKeys(value);
1618    });
1619    keys = Object.keys;
1620  }
1621
1622  if (Object.getOwnPropertyNames) {
1623    var objectGOPNAcceptsPrimitives = !throwsError(function () { Object.getOwnPropertyNames('foo'); });
1624    if (!objectGOPNAcceptsPrimitives) {
1625      var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : [];
1626      var originalObjectGetOwnPropertyNames = Object.getOwnPropertyNames;
1627      overrideNative(Object, 'getOwnPropertyNames', function getOwnPropertyNames(value) {
1628        var val = ES.ToObject(value);
1629        if (_toString(val) === '[object Window]') {
1630          try {
1631            return originalObjectGetOwnPropertyNames(val);
1632          } catch (e) {
1633            // IE bug where layout engine calls userland gOPN for cross-domain `window` objects
1634            return _concat([], cachedWindowNames);
1635          }
1636        }
1637        return originalObjectGetOwnPropertyNames(val);
1638      });
1639    }
1640  }
1641  if (Object.getOwnPropertyDescriptor) {
1642    var objectGOPDAcceptsPrimitives = !throwsError(function () { Object.getOwnPropertyDescriptor('foo', 'bar'); });
1643    if (!objectGOPDAcceptsPrimitives) {
1644      var originalObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1645      overrideNative(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(value, property) {
1646        return originalObjectGetOwnPropertyDescriptor(ES.ToObject(value), property);
1647      });
1648    }
1649  }
1650  if (Object.seal) {
1651    var objectSealAcceptsPrimitives = !throwsError(function () { Object.seal('foo'); });
1652    if (!objectSealAcceptsPrimitives) {
1653      var originalObjectSeal = Object.seal;
1654      overrideNative(Object, 'seal', function seal(value) {
1655        if (!ES.TypeIsObject(value)) { return value; }
1656        return originalObjectSeal(value);
1657      });
1658    }
1659  }
1660  if (Object.isSealed) {
1661    var objectIsSealedAcceptsPrimitives = !throwsError(function () { Object.isSealed('foo'); });
1662    if (!objectIsSealedAcceptsPrimitives) {
1663      var originalObjectIsSealed = Object.isSealed;
1664      overrideNative(Object, 'isSealed', function isSealed(value) {
1665        if (!ES.TypeIsObject(value)) { return true; }
1666        return originalObjectIsSealed(value);
1667      });
1668    }
1669  }
1670  if (Object.freeze) {
1671    var objectFreezeAcceptsPrimitives = !throwsError(function () { Object.freeze('foo'); });
1672    if (!objectFreezeAcceptsPrimitives) {
1673      var originalObjectFreeze = Object.freeze;
1674      overrideNative(Object, 'freeze', function freeze(value) {
1675        if (!ES.TypeIsObject(value)) { return value; }
1676        return originalObjectFreeze(value);
1677      });
1678    }
1679  }
1680  if (Object.isFrozen) {
1681    var objectIsFrozenAcceptsPrimitives = !throwsError(function () { Object.isFrozen('foo'); });
1682    if (!objectIsFrozenAcceptsPrimitives) {
1683      var originalObjectIsFrozen = Object.isFrozen;
1684      overrideNative(Object, 'isFrozen', function isFrozen(value) {
1685        if (!ES.TypeIsObject(value)) { return true; }
1686        return originalObjectIsFrozen(value);
1687      });
1688    }
1689  }
1690  if (Object.preventExtensions) {
1691    var objectPreventExtensionsAcceptsPrimitives = !throwsError(function () { Object.preventExtensions('foo'); });
1692    if (!objectPreventExtensionsAcceptsPrimitives) {
1693      var originalObjectPreventExtensions = Object.preventExtensions;
1694      overrideNative(Object, 'preventExtensions', function preventExtensions(value) {
1695        if (!ES.TypeIsObject(value)) { return value; }
1696        return originalObjectPreventExtensions(value);
1697      });
1698    }
1699  }
1700  if (Object.isExtensible) {
1701    var objectIsExtensibleAcceptsPrimitives = !throwsError(function () { Object.isExtensible('foo'); });
1702    if (!objectIsExtensibleAcceptsPrimitives) {
1703      var originalObjectIsExtensible = Object.isExtensible;
1704      overrideNative(Object, 'isExtensible', function isExtensible(value) {
1705        if (!ES.TypeIsObject(value)) { return false; }
1706        return originalObjectIsExtensible(value);
1707      });
1708    }
1709  }
1710  if (Object.getPrototypeOf) {
1711    var objectGetProtoAcceptsPrimitives = !throwsError(function () { Object.getPrototypeOf('foo'); });
1712    if (!objectGetProtoAcceptsPrimitives) {
1713      var originalGetProto = Object.getPrototypeOf;
1714      overrideNative(Object, 'getPrototypeOf', function getPrototypeOf(value) {
1715        return originalGetProto(ES.ToObject(value));
1716      });
1717    }
1718  }
1719
1720  var hasFlags = supportsDescriptors && (function () {
1721    var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags');
1722    return desc && ES.IsCallable(desc.get);
1723  }());
1724  if (supportsDescriptors && !hasFlags) {
1725    var regExpFlagsGetter = function flags() {
1726      if (!ES.TypeIsObject(this)) {
1727        throw new TypeError('Method called on incompatible type: must be an object.');
1728      }
1729      var result = '';
1730      if (this.global) {
1731        result += 'g';
1732      }
1733      if (this.ignoreCase) {
1734        result += 'i';
1735      }
1736      if (this.multiline) {
1737        result += 'm';
1738      }
1739      if (this.unicode) {
1740        result += 'u';
1741      }
1742      if (this.sticky) {
1743        result += 'y';
1744      }
1745      return result;
1746    };
1747
1748    Value.getter(RegExp.prototype, 'flags', regExpFlagsGetter);
1749  }
1750
1751  var regExpSupportsFlagsWithRegex = supportsDescriptors && valueOrFalseIfThrows(function () {
1752    return String(new RegExp(/a/g, 'i')) === '/a/i';
1753  });
1754  var regExpNeedsToSupportSymbolMatch = hasSymbols && supportsDescriptors && (function () {
1755    // Edge 0.12 supports flags fully, but does not support Symbol.match
1756    var regex = /./;
1757    regex[Symbol.match] = false;
vendor: 9,519 bytes, lines 1758-2036
1758    return RegExp(regex) === regex;
1759  }());
1760
1761  var regexToStringIsGeneric = valueOrFalseIfThrows(function () {
1762    return RegExp.prototype.toString.call({ source: 'abc' }) === '/abc/';
1763  });
1764  var regexToStringSupportsGenericFlags = regexToStringIsGeneric && valueOrFalseIfThrows(function () {
1765    return RegExp.prototype.toString.call({ source: 'a', flags: 'b' }) === '/a/b';
1766  });
1767  if (!regexToStringIsGeneric || !regexToStringSupportsGenericFlags) {
1768    var origRegExpToString = RegExp.prototype.toString;
1769    defineProperty(RegExp.prototype, 'toString', function toString() {
1770      var R = ES.RequireObjectCoercible(this);
1771      if (Type.regex(R)) {
1772        return _call(origRegExpToString, R);
1773      }
1774      var pattern = $String(R.source);
1775      var flags = $String(R.flags);
1776      return '/' + pattern + '/' + flags;
1777    }, true);
1778    Value.preserveToString(RegExp.prototype.toString, origRegExpToString);
1779  }
1780
1781  if (supportsDescriptors && (!regExpSupportsFlagsWithRegex || regExpNeedsToSupportSymbolMatch)) {
1782    var flagsGetter = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get;
1783    var sourceDesc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source') || {};
1784    var legacySourceGetter = function () { return this.source; }; // prior to it being a getter, it's own + nonconfigurable
1785    var sourceGetter = ES.IsCallable(sourceDesc.get) ? sourceDesc.get : legacySourceGetter;
1786
1787    var OrigRegExp = RegExp;
1788    var RegExpShim = (function () {
1789      return function RegExp(pattern, flags) {
1790        var patternIsRegExp = ES.IsRegExp(pattern);
1791        var calledWithNew = this instanceof RegExp;
1792        if (!calledWithNew && patternIsRegExp && typeof flags === 'undefined' && pattern.constructor === RegExp) {
1793          return pattern;
1794        }
1795
1796        var P = pattern;
1797        var F = flags;
1798        if (Type.regex(pattern)) {
1799          P = ES.Call(sourceGetter, pattern);
1800          F = typeof flags === 'undefined' ? ES.Call(flagsGetter, pattern) : flags;
1801          return new RegExp(P, F);
1802        } else if (patternIsRegExp) {
1803          P = pattern.source;
1804          F = typeof flags === 'undefined' ? pattern.flags : flags;
1805        }
1806        return new OrigRegExp(pattern, flags);
1807      };
1808    }());
1809    wrapConstructor(OrigRegExp, RegExpShim, {
1810      $input: true // Chrome < v39 & Opera < 26 have a nonstandard "$input" property
1811    });
1812    /* globals RegExp: true */
1813    /* eslint-disable no-undef */
1814    /* jshint -W020 */
1815    RegExp = RegExpShim;
1816    Value.redefine(globals, 'RegExp', RegExpShim);
1817    /* jshint +W020 */
1818    /* eslint-enable no-undef */
1819    /* globals RegExp: false */
1820  }
1821
1822  if (supportsDescriptors) {
1823    var regexGlobals = {
1824      input: '$_',
1825      lastMatch: '$&',
1826      lastParen: '$+',
1827      leftContext: '$`',
1828      rightContext: '$\''
1829    };
1830    _forEach(keys(regexGlobals), function (prop) {
1831      if (prop in RegExp && !(regexGlobals[prop] in RegExp)) {
1832        Value.getter(RegExp, regexGlobals[prop], function get() {
1833          return RegExp[prop];
1834        });
1835      }
1836    });
1837  }
1838  addDefaultSpecies(RegExp);
1839
1840  var inverseEpsilon = 1 / Number.EPSILON;
1841  var roundTiesToEven = function roundTiesToEven(n) {
1842    // Even though this reduces down to `return n`, it takes advantage of built-in rounding.
1843    return (n + inverseEpsilon) - inverseEpsilon;
1844  };
1845  var BINARY_32_EPSILON = Math.pow(2, -23);
1846  var BINARY_32_MAX_VALUE = Math.pow(2, 127) * (2 - BINARY_32_EPSILON);
1847  var BINARY_32_MIN_VALUE = Math.pow(2, -126);
1848  var E = Math.E;
1849  var LOG2E = Math.LOG2E;
1850  var LOG10E = Math.LOG10E;
1851  var numberCLZ = Number.prototype.clz;
1852  delete Number.prototype.clz; // Safari 8 has Number#clz
1853
1854  var MathShims = {
1855    acosh: function acosh(value) {
1856      var x = Number(value);
1857      if (numberIsNaN(x) || value < 1) { return NaN; }
1858      if (x === 1) { return 0; }
1859      if (x === Infinity) { return x; }
1860      return _log(x / E + _sqrt(x + 1) * _sqrt(x - 1) / E) + 1;
1861    },
1862
1863    asinh: function asinh(value) {
1864      var x = Number(value);
1865      if (x === 0 || !globalIsFinite(x)) {
1866        return x;
1867      }
1868      return x < 0 ? -asinh(-x) : _log(x + _sqrt(x * x + 1));
1869    },
1870
1871    atanh: function atanh(value) {
1872      var x = Number(value);
1873      if (numberIsNaN(x) || x < -1 || x > 1) {
1874        return NaN;
1875      }
1876      if (x === -1) { return -Infinity; }
1877      if (x === 1) { return Infinity; }
1878      if (x === 0) { return x; }
1879      return 0.5 * _log((1 + x) / (1 - x));
1880    },
1881
1882    cbrt: function cbrt(value) {
1883      var x = Number(value);
1884      if (x === 0) { return x; }
1885      var negate = x < 0;
1886      var result;
1887      if (negate) { x = -x; }
1888      if (x === Infinity) {
1889        result = Infinity;
1890      } else {
1891        result = _exp(_log(x) / 3);
1892        // from http://en.wikipedia.org/wiki/Cube_root#Numerical_methods
1893        result = (x / (result * result) + (2 * result)) / 3;
1894      }
1895      return negate ? -result : result;
1896    },
1897
1898    clz32: function clz32(value) {
1899      // See https://bugs.ecmascript.org/show_bug.cgi?id=2465
1900      var x = Number(value);
1901      var number = ES.ToUint32(x);
1902      if (number === 0) {
1903        return 32;
1904      }
1905      return numberCLZ ? ES.Call(numberCLZ, number) : 31 - _floor(_log(number + 0.5) * LOG2E);
1906    },
1907
1908    cosh: function cosh(value) {
1909      var x = Number(value);
1910      if (x === 0) { return 1; } // +0 or -0
1911      if (numberIsNaN(x)) { return NaN; }
1912      if (!globalIsFinite(x)) { return Infinity; }
1913      if (x < 0) { x = -x; }
1914      if (x > 21) { return _exp(x) / 2; }
1915      return (_exp(x) + _exp(-x)) / 2;
1916    },
1917
1918    expm1: function expm1(value) {
1919      var x = Number(value);
1920      if (x === -Infinity) { return -1; }
1921      if (!globalIsFinite(x) || x === 0) { return x; }
1922      if (_abs(x) > 0.5) {
1923        return _exp(x) - 1;
1924      }
1925      // A more precise approximation using Taylor series expansion
1926      // from https://github.com/paulmillr/es6-shim/issues/314#issuecomment-70293986
1927      var t = x;
1928      var sum = 0;
1929      var n = 1;
1930      while (sum + t !== sum) {
1931        sum += t;
1932        n += 1;
1933        t *= x / n;
1934      }
1935      return sum;
1936    },
1937
1938    hypot: function hypot(x, y) {
1939      var result = 0;
1940      var largest = 0;
1941      for (var i = 0; i < arguments.length; ++i) {
1942        var value = _abs(Number(arguments[i]));
1943        if (largest < value) {
1944          result *= (largest / value) * (largest / value);
1945          result += 1;
1946          largest = value;
1947        } else {
1948          result += value > 0 ? (value / largest) * (value / largest) : value;
1949        }
1950      }
1951      return largest === Infinity ? Infinity : largest * _sqrt(result);
1952    },
1953
1954    log2: function log2(value) {
1955      return _log(value) * LOG2E;
1956    },
1957
1958    log10: function log10(value) {
1959      return _log(value) * LOG10E;
1960    },
1961
1962    log1p: function log1p(value) {
1963      var x = Number(value);
1964      if (x < -1 || numberIsNaN(x)) { return NaN; }
1965      if (x === 0 || x === Infinity) { return x; }
1966      if (x === -1) { return -Infinity; }
1967
1968      return (1 + x) - 1 === 0 ? x : x * (_log(1 + x) / ((1 + x) - 1));
1969    },
1970
1971    sign: _sign,
1972
1973    sinh: function sinh(value) {
1974      var x = Number(value);
1975      if (!globalIsFinite(x) || x === 0) { return x; }
1976
1977      if (_abs(x) < 1) {
1978        return (Math.expm1(x) - Math.expm1(-x)) / 2;
1979      }
1980      return (_exp(x - 1) - _exp(-x - 1)) * E / 2;
1981    },
1982
1983    tanh: function tanh(value) {
1984      var x = Number(value);
1985      if (numberIsNaN(x) || x === 0) { return x; }
1986      // can exit early at +-20 as JS loses precision for true value at this integer
1987      if (x >= 20) { return 1; }
1988      if (x <= -20) { return -1; }
1989
1990      return (Math.expm1(x) - Math.expm1(-x)) / (_exp(x) + _exp(-x));
1991    },
1992
1993    trunc: function trunc(value) {
1994      var x = Number(value);
1995      return x < 0 ? -_floor(-x) : _floor(x);
1996    },
1997
1998    imul: function imul(x, y) {
1999      // taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
2000      var a = ES.ToUint32(x);
2001      var b = ES.ToUint32(y);
2002      var ah = (a >>> 16) & 0xffff;
2003      var al = a & 0xffff;
2004      var bh = (b >>> 16) & 0xffff;
2005      var bl = b & 0xffff;
2006      // the shift by 0 fixes the sign on the high part
2007      // the final |0 converts the unsigned value into a signed value
2008      return (al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0;
2009    },
2010
2011    fround: function fround(x) {
2012      var v = Number(x);
2013      if (v === 0 || v === Infinity || v === -Infinity || numberIsNaN(v)) {
2014        return v;
2015      }
2016      var sign = _sign(v);
2017      var abs = _abs(v);
2018      if (abs < BINARY_32_MIN_VALUE) {
2019        return sign * roundTiesToEven(abs / BINARY_32_MIN_VALUE / BINARY_32_EPSILON) * BINARY_32_MIN_VALUE * BINARY_32_EPSILON;
2020      }
2021      // Veltkamp's splitting (?)
2022      var a = (1 + BINARY_32_EPSILON / Number.EPSILON) * abs;
2023      var result = a - (a - abs);
2024      if (result > BINARY_32_MAX_VALUE || numberIsNaN(result)) {
2025        return sign * Infinity;
2026      }
2027      return sign * result;
2028    }
2029  };
2030  defineProperties(Math, MathShims);
2031  // IE 11 TP has an imprecise log1p: reports Math.log1p(-1e-17) as 0
2032  defineProperty(Math, 'log1p', MathShims.log1p, Math.log1p(-1e-17) !== -1e-17);
2033  // IE 11 TP has an imprecise asinh: reports Math.asinh(-1e7) as not exactly equal to -Math.asinh(1e7)
2034  defineProperty(Math, 'asinh', MathShims.asinh, Math.asinh(-1e7) !== -Math.asinh(1e7));
2035  // Chrome 40 has an imprecise Math.tanh with very small numbers
2036  defineProperty(Math, 'tanh', MathShims.tanh, Math.tanh(-2e-17) !== -2e-17);
vendor: 5,607 bytes, lines 2037-2165
2037  // Chrome 40 loses Math.acosh precision with high numbers
2038  defineProperty(Math, 'acosh', MathShims.acosh, Math.acosh(Number.MAX_VALUE) === Infinity);
2039  // Firefox 38 on Windows
2040  defineProperty(Math, 'cbrt', MathShims.cbrt, Math.abs(1 - Math.cbrt(1e-300) / 1e-100) / Number.EPSILON > 8);
2041  // node 0.11 has an imprecise Math.sinh with very small numbers
2042  defineProperty(Math, 'sinh', MathShims.sinh, Math.sinh(-2e-17) !== -2e-17);
2043  // FF 35 on Linux reports 22025.465794806725 for Math.expm1(10)
2044  var expm1OfTen = Math.expm1(10);
2045  defineProperty(Math, 'expm1', MathShims.expm1, expm1OfTen > 22025.465794806719 || expm1OfTen < 22025.4657948067165168);
2046
2047  var origMathRound = Math.round;
2048  // breaks in e.g. Safari 8, Internet Explorer 11, Opera 12
2049  var roundHandlesBoundaryConditions = Math.round(0.5 - Number.EPSILON / 4) === 0 && Math.round(-0.5 + Number.EPSILON / 3.99) === 1;
2050
2051  // When engines use Math.floor(x + 0.5) internally, Math.round can be buggy for large integers.
2052  // This behavior should be governed by "round to nearest, ties to even mode"
2053  // see http://www.ecma-international.org/ecma-262/6.0/#sec-terms-and-definitions-number-type
2054  // These are the boundary cases where it breaks.
2055  var smallestPositiveNumberWhereRoundBreaks = inverseEpsilon + 1;
2056  var largestPositiveNumberWhereRoundBreaks = 2 * inverseEpsilon - 1;
2057  var roundDoesNotIncreaseIntegers = [smallestPositiveNumberWhereRoundBreaks, largestPositiveNumberWhereRoundBreaks].every(function (num) {
2058    return Math.round(num) === num;
2059  });
2060  defineProperty(Math, 'round', function round(x) {
2061    var floor = _floor(x);
2062    var ceil = floor === -1 ? -0 : floor + 1;
2063    return x - floor < 0.5 ? floor : ceil;
2064  }, !roundHandlesBoundaryConditions || !roundDoesNotIncreaseIntegers);
2065  Value.preserveToString(Math.round, origMathRound);
2066
2067  var origImul = Math.imul;
2068  if (Math.imul(0xffffffff, 5) !== -5) {
2069    // Safari 6.1, at least, reports "0" for this value
2070    Math.imul = MathShims.imul;
2071    Value.preserveToString(Math.imul, origImul);
2072  }
2073  if (Math.imul.length !== 2) {
2074    // Safari 8.0.4 has a length of 1
2075    // fixed in https://bugs.webkit.org/show_bug.cgi?id=143658
2076    overrideNative(Math, 'imul', function imul(x, y) {
2077      return ES.Call(origImul, Math, arguments);
2078    });
2079  }
2080
2081  // Promises
2082  // Simplest possible implementation; use a 3rd-party library if you
2083  // want the best possible speed and/or long stack traces.
2084  var PromiseShim = (function () {
2085    var setTimeout = globals.setTimeout;
2086    // some environments don't have setTimeout - no way to shim here.
2087    if (typeof setTimeout !== 'function' && typeof setTimeout !== 'object') { return; }
2088
2089    ES.IsPromise = function (promise) {
2090      if (!ES.TypeIsObject(promise)) {
2091        return false;
2092      }
2093      if (typeof promise._promise === 'undefined') {
2094        return false; // uninitialized, or missing our hidden field.
2095      }
2096      return true;
2097    };
2098
2099    // "PromiseCapability" in the spec is what most promise implementations
2100    // call a "deferred".
2101    var PromiseCapability = function (C) {
2102      if (!ES.IsConstructor(C)) {
2103        throw new TypeError('Bad promise constructor');
2104      }
2105      var capability = this;
2106      var resolver = function (resolve, reject) {
2107        if (capability.resolve !== void 0 || capability.reject !== void 0) {
2108          throw new TypeError('Bad Promise implementation!');
2109        }
2110        capability.resolve = resolve;
2111        capability.reject = reject;
2112      };
2113      // Initialize fields to inform optimizers about the object shape.
2114      capability.resolve = void 0;
2115      capability.reject = void 0;
2116      capability.promise = new C(resolver);
2117      if (!(ES.IsCallable(capability.resolve) && ES.IsCallable(capability.reject))) {
2118        throw new TypeError('Bad promise constructor');
2119      }
2120    };
2121
2122    // find an appropriate setImmediate-alike
2123    var makeZeroTimeout;
2124    /*global window */
2125    if (typeof window !== 'undefined' && ES.IsCallable(window.postMessage)) {
2126      makeZeroTimeout = function () {
2127        // from http://dbaron.org/log/20100309-faster-timeouts
2128        var timeouts = [];
2129        var messageName = 'zero-timeout-message';
2130        var setZeroTimeout = function (fn) {
2131          _push(timeouts, fn);
2132          window.postMessage(messageName, '*');
2133        };
2134        var handleMessage = function (event) {
2135          if (event.source === window && event.data === messageName) {
2136            event.stopPropagation();
2137            if (timeouts.length === 0) { return; }
2138            var fn = _shift(timeouts);
2139            fn();
2140          }
2141        };
2142        window.addEventListener('message', handleMessage, true);
2143        return setZeroTimeout;
2144      };
2145    }
2146    var makePromiseAsap = function () {
2147      // An efficient task-scheduler based on a pre-existing Promise
2148      // implementation, which we can use even if we override the
2149      // global Promise below (in order to workaround bugs)
2150      // https://github.com/Raynos/observ-hash/issues/2#issuecomment-35857671
2151      var P = globals.Promise;
2152      var pr = P && P.resolve && P.resolve();
2153      return pr && function (task) {
2154        return pr.then(task);
2155      };
2156    };
2157    /*global process */
2158    /* jscs:disable disallowMultiLineTernary */
2159    var enqueue = ES.IsCallable(globals.setImmediate) ?
2160      globals.setImmediate :
2161      typeof process === 'object' && process.nextTick ? process.nextTick :
2162      makePromiseAsap() ||
2163      (ES.IsCallable(makeZeroTimeout) ? makeZeroTimeout() :
2164      function (task) { setTimeout(task, 0); }); // fallback
2165    /* jscs:enable disallowMultiLineTernary */
vendor: 7,922 bytes, lines 2165-2392
2165
2166
2167    // Constants for Promise implementation
2168    var PROMISE_IDENTITY = function (x) { return x; };
2169    var PROMISE_THROWER = function (e) { throw e; };
2170    var PROMISE_PENDING = 0;
2171    var PROMISE_FULFILLED = 1;
2172    var PROMISE_REJECTED = 2;
2173    // We store fulfill/reject handlers and capabilities in a single array.
2174    var PROMISE_FULFILL_OFFSET = 0;
2175    var PROMISE_REJECT_OFFSET = 1;
2176    var PROMISE_CAPABILITY_OFFSET = 2;
2177    // This is used in an optimization for chaining promises via then.
2178    var PROMISE_FAKE_CAPABILITY = {};
2179
2180    var enqueuePromiseReactionJob = function (handler, capability, argument) {
2181      enqueue(function () {
2182        promiseReactionJob(handler, capability, argument);
2183      });
2184    };
2185
2186    var promiseReactionJob = function (handler, promiseCapability, argument) {
2187      var handlerResult, f;
2188      if (promiseCapability === PROMISE_FAKE_CAPABILITY) {
2189        // Fast case, when we don't actually need to chain through to a
2190        // (real) promiseCapability.
2191        return handler(argument);
2192      }
2193      try {
2194        handlerResult = handler(argument);
2195        f = promiseCapability.resolve;
2196      } catch (e) {
2197        handlerResult = e;
2198        f = promiseCapability.reject;
2199      }
2200      f(handlerResult);
2201    };
2202
2203    var fulfillPromise = function (promise, value) {
2204      var _promise = promise._promise;
2205      var length = _promise.reactionLength;
2206      if (length > 0) {
2207        enqueuePromiseReactionJob(
2208          _promise.fulfillReactionHandler0,
2209          _promise.reactionCapability0,
2210          value
2211        );
2212        _promise.fulfillReactionHandler0 = void 0;
2213        _promise.rejectReactions0 = void 0;
2214        _promise.reactionCapability0 = void 0;
2215        if (length > 1) {
2216          for (var i = 1, idx = 0; i < length; i++, idx += 3) {
2217            enqueuePromiseReactionJob(
2218              _promise[idx + PROMISE_FULFILL_OFFSET],
2219              _promise[idx + PROMISE_CAPABILITY_OFFSET],
2220              value
2221            );
2222            promise[idx + PROMISE_FULFILL_OFFSET] = void 0;
2223            promise[idx + PROMISE_REJECT_OFFSET] = void 0;
2224            promise[idx + PROMISE_CAPABILITY_OFFSET] = void 0;
2225          }
2226        }
2227      }
2228      _promise.result = value;
2229      _promise.state = PROMISE_FULFILLED;
2230      _promise.reactionLength = 0;
2231    };
2232
2233    var rejectPromise = function (promise, reason) {
2234      var _promise = promise._promise;
2235      var length = _promise.reactionLength;
2236      if (length > 0) {
2237        enqueuePromiseReactionJob(
2238          _promise.rejectReactionHandler0,
2239          _promise.reactionCapability0,
2240          reason
2241        );
2242        _promise.fulfillReactionHandler0 = void 0;
2243        _promise.rejectReactions0 = void 0;
2244        _promise.reactionCapability0 = void 0;
2245        if (length > 1) {
2246          for (var i = 1, idx = 0; i < length; i++, idx += 3) {
2247            enqueuePromiseReactionJob(
2248              _promise[idx + PROMISE_REJECT_OFFSET],
2249              _promise[idx + PROMISE_CAPABILITY_OFFSET],
2250              reason
2251            );
2252            promise[idx + PROMISE_FULFILL_OFFSET] = void 0;
2253            promise[idx + PROMISE_REJECT_OFFSET] = void 0;
2254            promise[idx + PROMISE_CAPABILITY_OFFSET] = void 0;
2255          }
2256        }
2257      }
2258      _promise.result = reason;
2259      _promise.state = PROMISE_REJECTED;
2260      _promise.reactionLength = 0;
2261    };
2262
2263    var createResolvingFunctions = function (promise) {
2264      var alreadyResolved = false;
2265      var resolve = function (resolution) {
2266        var then;
2267        if (alreadyResolved) { return; }
2268        alreadyResolved = true;
2269        if (resolution === promise) {
2270          return rejectPromise(promise, new TypeError('Self resolution'));
2271        }
2272        if (!ES.TypeIsObject(resolution)) {
2273          return fulfillPromise(promise, resolution);
2274        }
2275        try {
2276          then = resolution.then;
2277        } catch (e) {
2278          return rejectPromise(promise, e);
2279        }
2280        if (!ES.IsCallable(then)) {
2281          return fulfillPromise(promise, resolution);
2282        }
2283        enqueue(function () {
2284          promiseResolveThenableJob(promise, resolution, then);
2285        });
2286      };
2287      var reject = function (reason) {
2288        if (alreadyResolved) { return; }
2289        alreadyResolved = true;
2290        return rejectPromise(promise, reason);
2291      };
2292      return { resolve: resolve, reject: reject };
2293    };
2294
2295    var optimizedThen = function (then, thenable, resolve, reject) {
2296      // Optimization: since we discard the result, we can pass our
2297      // own then implementation a special hint to let it know it
2298      // doesn't have to create it.  (The PROMISE_FAKE_CAPABILITY
2299      // object is local to this implementation and unforgeable outside.)
2300      if (then === Promise$prototype$then) {
2301        _call(then, thenable, resolve, reject, PROMISE_FAKE_CAPABILITY);
2302      } else {
2303        _call(then, thenable, resolve, reject);
2304      }
2305    };
2306    var promiseResolveThenableJob = function (promise, thenable, then) {
2307      var resolvingFunctions = createResolvingFunctions(promise);
2308      var resolve = resolvingFunctions.resolve;
2309      var reject = resolvingFunctions.reject;
2310      try {
2311        optimizedThen(then, thenable, resolve, reject);
2312      } catch (e) {
2313        reject(e);
2314      }
2315    };
2316
2317    var Promise$prototype, Promise$prototype$then;
2318    var Promise = (function () {
2319      var PromiseShim = function Promise(resolver) {
2320        if (!(this instanceof PromiseShim)) {
2321          throw new TypeError('Constructor Promise requires "new"');
2322        }
2323        if (this && this._promise) {
2324          throw new TypeError('Bad construction');
2325        }
2326        // see https://bugs.ecmascript.org/show_bug.cgi?id=2482
2327        if (!ES.IsCallable(resolver)) {
2328          throw new TypeError('not a valid resolver');
2329        }
2330        var promise = emulateES6construct(this, PromiseShim, Promise$prototype, {
2331          _promise: {
2332            result: void 0,
2333            state: PROMISE_PENDING,
2334            // The first member of the "reactions" array is inlined here,
2335            // since most promises only have one reaction.
2336            // We've also exploded the 'reaction' object to inline the
2337            // "handler" and "capability" fields, since both fulfill and
2338            // reject reactions share the same capability.
2339            reactionLength: 0,
2340            fulfillReactionHandler0: void 0,
2341            rejectReactionHandler0: void 0,
2342            reactionCapability0: void 0
2343          }
2344        });
2345        var resolvingFunctions = createResolvingFunctions(promise);
2346        var reject = resolvingFunctions.reject;
2347        try {
2348          resolver(resolvingFunctions.resolve, reject);
2349        } catch (e) {
2350          reject(e);
2351        }
2352        return promise;
2353      };
2354      return PromiseShim;
2355    }());
2356    Promise$prototype = Promise.prototype;
2357
2358    var _promiseAllResolver = function (index, values, capability, remaining) {
2359      var alreadyCalled = false;
2360      return function (x) {
2361        if (alreadyCalled) { return; }
2362        alreadyCalled = true;
2363        values[index] = x;
2364        if ((--remaining.count) === 0) {
2365          var resolve = capability.resolve;
2366          resolve(values); // call w/ this===undefined
2367        }
2368      };
2369    };
2370
2371    var performPromiseAll = function (iteratorRecord, C, resultCapability) {
2372      var it = iteratorRecord.iterator;
2373      var values = [];
2374      var remaining = { count: 1 };
2375      var next, nextValue;
2376      var index = 0;
2377      while (true) {
2378        try {
2379          next = ES.IteratorStep(it);
2380          if (next === false) {
2381            iteratorRecord.done = true;
2382            break;
2383          }
2384          nextValue = next.value;
2385        } catch (e) {
2386          iteratorRecord.done = true;
2387          throw e;
2388        }
2389        values[index] = void 0;
2390        var nextPromise = C.resolve(nextValue);
2391        var resolveElement = _promiseAllResolver(
2392          index,
vendor: 12,178 bytes, lines 2392-2714
2392 values, resultCapability, remaining
2393        );
2394        remaining.count += 1;
2395        optimizedThen(nextPromise.then, nextPromise, resolveElement, resultCapability.reject);
2396        index += 1;
2397      }
2398      if ((--remaining.count) === 0) {
2399        var resolve = resultCapability.resolve;
2400        resolve(values); // call w/ this===undefined
2401      }
2402      return resultCapability.promise;
2403    };
2404
2405    var performPromiseRace = function (iteratorRecord, C, resultCapability) {
2406      var it = iteratorRecord.iterator;
2407      var next, nextValue, nextPromise;
2408      while (true) {
2409        try {
2410          next = ES.IteratorStep(it);
2411          if (next === false) {
2412            // NOTE: If iterable has no items, resulting promise will never
2413            // resolve; see:
2414            // https://github.com/domenic/promises-unwrapping/issues/75
2415            // https://bugs.ecmascript.org/show_bug.cgi?id=2515
2416            iteratorRecord.done = true;
2417            break;
2418          }
2419          nextValue = next.value;
2420        } catch (e) {
2421          iteratorRecord.done = true;
2422          throw e;
2423        }
2424        nextPromise = C.resolve(nextValue);
2425        optimizedThen(nextPromise.then, nextPromise, resultCapability.resolve, resultCapability.reject);
2426      }
2427      return resultCapability.promise;
2428    };
2429
2430    defineProperties(Promise, {
2431      all: function all(iterable) {
2432        var C = this;
2433        if (!ES.TypeIsObject(C)) {
2434          throw new TypeError('Promise is not object');
2435        }
2436        var capability = new PromiseCapability(C);
2437        var iterator, iteratorRecord;
2438        try {
2439          iterator = ES.GetIterator(iterable);
2440          iteratorRecord = { iterator: iterator, done: false };
2441          return performPromiseAll(iteratorRecord, C, capability);
2442        } catch (e) {
2443          var exception = e;
2444          if (iteratorRecord && !iteratorRecord.done) {
2445            try {
2446              ES.IteratorClose(iterator, true);
2447            } catch (ee) {
2448              exception = ee;
2449            }
2450          }
2451          var reject = capability.reject;
2452          reject(exception);
2453          return capability.promise;
2454        }
2455      },
2456
2457      race: function race(iterable) {
2458        var C = this;
2459        if (!ES.TypeIsObject(C)) {
2460          throw new TypeError('Promise is not object');
2461        }
2462        var capability = new PromiseCapability(C);
2463        var iterator, iteratorRecord;
2464        try {
2465          iterator = ES.GetIterator(iterable);
2466          iteratorRecord = { iterator: iterator, done: false };
2467          return performPromiseRace(iteratorRecord, C, capability);
2468        } catch (e) {
2469          var exception = e;
2470          if (iteratorRecord && !iteratorRecord.done) {
2471            try {
2472              ES.IteratorClose(iterator, true);
2473            } catch (ee) {
2474              exception = ee;
2475            }
2476          }
2477          var reject = capability.reject;
2478          reject(exception);
2479          return capability.promise;
2480        }
2481      },
2482
2483      reject: function reject(reason) {
2484        var C = this;
2485        if (!ES.TypeIsObject(C)) {
2486          throw new TypeError('Bad promise constructor');
2487        }
2488        var capability = new PromiseCapability(C);
2489        var rejectFunc = capability.reject;
2490        rejectFunc(reason); // call with this===undefined
2491        return capability.promise;
2492      },
2493
2494      resolve: function resolve(v) {
2495        // See https://esdiscuss.org/topic/fixing-promise-resolve for spec
2496        var C = this;
2497        if (!ES.TypeIsObject(C)) {
2498          throw new TypeError('Bad promise constructor');
2499        }
2500        if (ES.IsPromise(v)) {
2501          var constructor = v.constructor;
2502          if (constructor === C) {
2503            return v;
2504          }
2505        }
2506        var capability = new PromiseCapability(C);
2507        var resolveFunc = capability.resolve;
2508        resolveFunc(v); // call with this===undefined
2509        return capability.promise;
2510      }
2511    });
2512
2513    defineProperties(Promise$prototype, {
2514      'catch': function (onRejected) {
2515        return this.then(null, onRejected);
2516      },
2517
2518      then: function then(onFulfilled, onRejected) {
2519        var promise = this;
2520        if (!ES.IsPromise(promise)) { throw new TypeError('not a promise'); }
2521        var C = ES.SpeciesConstructor(promise, Promise);
2522        var resultCapability;
2523        var returnValueIsIgnored = arguments.length > 2 && arguments[2] === PROMISE_FAKE_CAPABILITY;
2524        if (returnValueIsIgnored && C === Promise) {
2525          resultCapability = PROMISE_FAKE_CAPABILITY;
2526        } else {
2527          resultCapability = new PromiseCapability(C);
2528        }
2529        // PerformPromiseThen(promise, onFulfilled, onRejected, resultCapability)
2530        // Note that we've split the 'reaction' object into its two
2531        // components, "capabilities" and "handler"
2532        // "capabilities" is always equal to `resultCapability`
2533        var fulfillReactionHandler = ES.IsCallable(onFulfilled) ? onFulfilled : PROMISE_IDENTITY;
2534        var rejectReactionHandler = ES.IsCallable(onRejected) ? onRejected : PROMISE_THROWER;
2535        var _promise = promise._promise;
2536        var value;
2537        if (_promise.state === PROMISE_PENDING) {
2538          if (_promise.reactionLength === 0) {
2539            _promise.fulfillReactionHandler0 = fulfillReactionHandler;
2540            _promise.rejectReactionHandler0 = rejectReactionHandler;
2541            _promise.reactionCapability0 = resultCapability;
2542          } else {
2543            var idx = 3 * (_promise.reactionLength - 1);
2544            _promise[idx + PROMISE_FULFILL_OFFSET] = fulfillReactionHandler;
2545            _promise[idx + PROMISE_REJECT_OFFSET] = rejectReactionHandler;
2546            _promise[idx + PROMISE_CAPABILITY_OFFSET] = resultCapability;
2547          }
2548          _promise.reactionLength += 1;
2549        } else if (_promise.state === PROMISE_FULFILLED) {
2550          value = _promise.result;
2551          enqueuePromiseReactionJob(
2552            fulfillReactionHandler, resultCapability, value
2553          );
2554        } else if (_promise.state === PROMISE_REJECTED) {
2555          value = _promise.result;
2556          enqueuePromiseReactionJob(
2557            rejectReactionHandler, resultCapability, value
2558          );
2559        } else {
2560          throw new TypeError('unexpected Promise state');
2561        }
2562        return resultCapability.promise;
2563      }
2564    });
2565    // This helps the optimizer by ensuring that methods which take
2566    // capabilities aren't polymorphic.
2567    PROMISE_FAKE_CAPABILITY = new PromiseCapability(Promise);
2568    Promise$prototype$then = Promise$prototype.then;
2569
2570    return Promise;
2571  }());
2572
2573  // Chrome's native Promise has extra methods that it shouldn't have. Let's remove them.
2574  if (globals.Promise) {
2575    delete globals.Promise.accept;
2576    delete globals.Promise.defer;
2577    delete globals.Promise.prototype.chain;
2578  }
2579
2580  if (typeof PromiseShim === 'function') {
2581    // export the Promise constructor.
2582    defineProperties(globals, { Promise: PromiseShim });
2583    // In Chrome 33 (and thereabouts) Promise is defined, but the
2584    // implementation is buggy in a number of ways.  Let's check subclassing
2585    // support to see if we have a buggy implementation.
2586    var promiseSupportsSubclassing = supportsSubclassing(globals.Promise, function (S) {
2587      return S.resolve(42).then(function () {}) instanceof S;
2588    });
2589    var promiseIgnoresNonFunctionThenCallbacks = !throwsError(function () { globals.Promise.reject(42).then(null, 5).then(null, noop); });
2590    var promiseRequiresObjectContext = throwsError(function () { globals.Promise.call(3, noop); });
2591    // Promise.resolve() was errata'ed late in the ES6 process.
2592    // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1170742
2593    //      https://code.google.com/p/v8/issues/detail?id=4161
2594    // It serves as a proxy for a number of other bugs in early Promise
2595    // implementations.
2596    var promiseResolveBroken = (function (Promise) {
2597      var p = Promise.resolve(5);
2598      p.constructor = {};
2599      var p2 = Promise.resolve(p);
2600      try {
2601        p2.then(null, noop).then(null, noop); // avoid "uncaught rejection" warnings in console
2602      } catch (e) {
2603        return true; // v8 native Promises break here https://code.google.com/p/chromium/issues/detail?id=575314
2604      }
2605      return p === p2; // This *should* be false!
2606    }(globals.Promise));
2607
2608    // Chrome 46 (probably older too) does not retrieve a thenable's .then synchronously
2609    var getsThenSynchronously = supportsDescriptors && (function () {
2610      var count = 0;
2611      var thenable = Object.defineProperty({}, 'then', { get: function () { count += 1; } });
2612      Promise.resolve(thenable);
2613      return count === 1;
2614    }());
2615
2616    var BadResolverPromise = function BadResolverPromise(executor) {
2617      var p = new Promise(executor);
2618      executor(3, function () {});
2619      this.then = p.then;
2620      this.constructor = BadResolverPromise;
2621    };
2622    BadResolverPromise.prototype = Promise.prototype;
2623    BadResolverPromise.all = Promise.all;
2624    // Chrome Canary 49 (probably older too) has some implementation bugs
2625    var hasBadResolverPromise = valueOrFalseIfThrows(function () {
2626      return !!BadResolverPromise.all([1, 2]);
2627    });
2628
2629    if (!promiseSupportsSubclassing || !promiseIgnoresNonFunctionThenCallbacks ||
2630        !promiseRequiresObjectContext || promiseResolveBroken ||
2631        !getsThenSynchronously || hasBadResolverPromise) {
2632      /* globals Promise: true */
2633      /* eslint-disable no-undef */
2634      /* jshint -W020 */
2635      Promise = PromiseShim;
2636      /* jshint +W020 */
2637      /* eslint-enable no-undef */
2638      /* globals Promise: false */
2639      overrideNative(globals, 'Promise', PromiseShim);
2640    }
2641    if (Promise.all.length !== 1) {
2642      var origAll = Promise.all;
2643      overrideNative(Promise, 'all', function all(iterable) {
2644        return ES.Call(origAll, this, arguments);
2645      });
2646    }
2647    if (Promise.race.length !== 1) {
2648      var origRace = Promise.race;
2649      overrideNative(Promise, 'race', function race(iterable) {
2650        return ES.Call(origRace, this, arguments);
2651      });
2652    }
2653    if (Promise.resolve.length !== 1) {
2654      var origResolve = Promise.resolve;
2655      overrideNative(Promise, 'resolve', function resolve(x) {
2656        return ES.Call(origResolve, this, arguments);
2657      });
2658    }
2659    if (Promise.reject.length !== 1) {
2660      var origReject = Promise.reject;
2661      overrideNative(Promise, 'reject', function reject(r) {
2662        return ES.Call(origReject, this, arguments);
2663      });
2664    }
2665    ensureEnumerable(Promise, 'all');
2666    ensureEnumerable(Promise, 'race');
2667    ensureEnumerable(Promise, 'resolve');
2668    ensureEnumerable(Promise, 'reject');
2669    addDefaultSpecies(Promise);
2670  }
2671
2672  // Map and Set require a true ES5 environment
2673  // Their fast path also requires that the environment preserve
2674  // property insertion order, which is not guaranteed by the spec.
2675  var testOrder = function (a) {
2676    var b = keys(_reduce(a, function (o, k) {
2677      o[k] = true;
2678      return o;
2679    }, {}));
2680    return a.join(':') === b.join(':');
2681  };
2682  var preservesInsertionOrder = testOrder(['z', 'a', 'bb']);
2683  // some engines (eg, Chrome) only preserve insertion order for string keys
2684  var preservesNumericInsertionOrder = testOrder(['z', 1, 'a', '3', 2]);
2685
2686  if (supportsDescriptors) {
2687
2688    var fastkey = function fastkey(key) {
2689      if (!preservesInsertionOrder) {
2690        return null;
2691      }
2692      if (typeof key === 'undefined' || key === null) {
2693        return '^' + ES.ToString(key);
2694      } else if (typeof key === 'string') {
2695        return '$' + key;
2696      } else if (typeof key === 'number') {
2697        // note that -0 will get coerced to "0" when used as a property key
2698        if (!preservesNumericInsertionOrder) {
2699          return 'n' + key;
2700        }
2701        return key;
2702      } else if (typeof key === 'boolean') {
2703        return 'b' + key;
2704      }
2705      return null;
2706    };
2707
2708    var emptyObject = function emptyObject() {
2709      // accomodate some older not-quite-ES5 browsers
2710      return Object.create ? Object.create(null) : {};
2711    };
2712
2713    var addIterableToMap = function addIterableToMap(MapConstructor, map, iterable) {
2714      if (isArray(iterable) || Type.string(iterable)) {
vendor: 21,560 bytes, lines 2715-3338
2715        _forEach(iterable, function (entry) {
2716          if (!ES.TypeIsObject(entry)) {
2717            throw new TypeError('Iterator value ' + entry + ' is not an entry object');
2718          }
2719          map.set(entry[0], entry[1]);
2720        });
2721      } else if (iterable instanceof MapConstructor) {
2722        _call(MapConstructor.prototype.forEach, iterable, function (value, key) {
2723          map.set(key, value);
2724        });
2725      } else {
2726        var iter, adder;
2727        if (iterable !== null && typeof iterable !== 'undefined') {
2728          adder = map.set;
2729          if (!ES.IsCallable(adder)) { throw new TypeError('bad map'); }
2730          iter = ES.GetIterator(iterable);
2731        }
2732        if (typeof iter !== 'undefined') {
2733          while (true) {
2734            var next = ES.IteratorStep(iter);
2735            if (next === false) { break; }
2736            var nextItem = next.value;
2737            try {
2738              if (!ES.TypeIsObject(nextItem)) {
2739                throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
2740              }
2741              _call(adder, map, nextItem[0], nextItem[1]);
2742            } catch (e) {
2743              ES.IteratorClose(iter, true);
2744              throw e;
2745            }
2746          }
2747        }
2748      }
2749    };
2750    var addIterableToSet = function addIterableToSet(SetConstructor, set, iterable) {
2751      if (isArray(iterable) || Type.string(iterable)) {
2752        _forEach(iterable, function (value) {
2753          set.add(value);
2754        });
2755      } else if (iterable instanceof SetConstructor) {
2756        _call(SetConstructor.prototype.forEach, iterable, function (value) {
2757          set.add(value);
2758        });
2759      } else {
2760        var iter, adder;
2761        if (iterable !== null && typeof iterable !== 'undefined') {
2762          adder = set.add;
2763          if (!ES.IsCallable(adder)) { throw new TypeError('bad set'); }
2764          iter = ES.GetIterator(iterable);
2765        }
2766        if (typeof iter !== 'undefined') {
2767          while (true) {
2768            var next = ES.IteratorStep(iter);
2769            if (next === false) { break; }
2770            var nextValue = next.value;
2771            try {
2772              _call(adder, set, nextValue);
2773            } catch (e) {
2774              ES.IteratorClose(iter, true);
2775              throw e;
2776            }
2777          }
2778        }
2779      }
2780    };
2781
2782    var collectionShims = {
2783      Map: (function () {
2784
2785        var empty = {};
2786
2787        var MapEntry = function MapEntry(key, value) {
2788          this.key = key;
2789          this.value = value;
2790          this.next = null;
2791          this.prev = null;
2792        };
2793
2794        MapEntry.prototype.isRemoved = function isRemoved() {
2795          return this.key === empty;
2796        };
2797
2798        var isMap = function isMap(map) {
2799          return !!map._es6map;
2800        };
2801
2802        var requireMapSlot = function requireMapSlot(map, method) {
2803          if (!ES.TypeIsObject(map) || !isMap(map)) {
2804            throw new TypeError('Method Map.prototype.' + method + ' called on incompatible receiver ' + ES.ToString(map));
2805          }
2806        };
2807
2808        var MapIterator = function MapIterator(map, kind) {
2809          requireMapSlot(map, '[[MapIterator]]');
2810          this.head = map._head;
2811          this.i = this.head;
2812          this.kind = kind;
2813        };
2814
2815        MapIterator.prototype = {
2816          next: function next() {
2817            var i = this.i;
2818            var kind = this.kind;
2819            var head = this.head;
2820            if (typeof this.i === 'undefined') {
2821              return iteratorResult();
2822            }
2823            while (i.isRemoved() && i !== head) {
2824              // back up off of removed entries
2825              i = i.prev;
2826            }
2827            // advance to next unreturned element.
2828            var result;
2829            while (i.next !== head) {
2830              i = i.next;
2831              if (!i.isRemoved()) {
2832                if (kind === 'key') {
2833                  result = i.key;
2834                } else if (kind === 'value') {
2835                  result = i.value;
2836                } else {
2837                  result = [i.key, i.value];
2838                }
2839                this.i = i;
2840                return iteratorResult(result);
2841              }
2842            }
2843            // once the iterator is done, it is done forever.
2844            this.i = void 0;
2845            return iteratorResult();
2846          }
2847        };
2848        addIterator(MapIterator.prototype);
2849
2850        var Map$prototype;
2851        var MapShim = function Map() {
2852          if (!(this instanceof Map)) {
2853            throw new TypeError('Constructor Map requires "new"');
2854          }
2855          if (this && this._es6map) {
2856            throw new TypeError('Bad construction');
2857          }
2858          var map = emulateES6construct(this, Map, Map$prototype, {
2859            _es6map: true,
2860            _head: null,
2861            _storage: emptyObject(),
2862            _size: 0
2863          });
2864
2865          var head = new MapEntry(null, null);
2866          // circular doubly-linked list.
2867          head.next = head.prev = head;
2868          map._head = head;
2869
2870          // Optionally initialize map from iterable
2871          if (arguments.length > 0) {
2872            addIterableToMap(Map, map, arguments[0]);
2873          }
2874          return map;
2875        };
2876        Map$prototype = MapShim.prototype;
2877
2878        Value.getter(Map$prototype, 'size', function () {
2879          if (typeof this._size === 'undefined') {
2880            throw new TypeError('size method called on incompatible Map');
2881          }
2882          return this._size;
2883        });
2884
2885        defineProperties(Map$prototype, {
2886          get: function get(key) {
2887            requireMapSlot(this, 'get');
2888            var fkey = fastkey(key);
2889            if (fkey !== null) {
2890              // fast O(1) path
2891              var entry = this._storage[fkey];
2892              if (entry) {
2893                return entry.value;
2894              } else {
2895                return;
2896              }
2897            }
2898            var head = this._head;
2899            var i = head;
2900            while ((i = i.next) !== head) {
2901              if (ES.SameValueZero(i.key, key)) {
2902                return i.value;
2903              }
2904            }
2905          },
2906
2907          has: function has(key) {
2908            requireMapSlot(this, 'has');
2909            var fkey = fastkey(key);
2910            if (fkey !== null) {
2911              // fast O(1) path
2912              return typeof this._storage[fkey] !== 'undefined';
2913            }
2914            var head = this._head;
2915            var i = head;
2916            while ((i = i.next) !== head) {
2917              if (ES.SameValueZero(i.key, key)) {
2918                return true;
2919              }
2920            }
2921            return false;
2922          },
2923
2924          set: function set(key, value) {
2925            requireMapSlot(this, 'set');
2926            var head = this._head;
2927            var i = head;
2928            var entry;
2929            var fkey = fastkey(key);
2930            if (fkey !== null) {
2931              // fast O(1) path
2932              if (typeof this._storage[fkey] !== 'undefined') {
2933                this._storage[fkey].value = value;
2934                return this;
2935              } else {
2936                entry = this._storage[fkey] = new MapEntry(key, value);
2937                i = head.prev;
2938                // fall through
2939              }
2940            }
2941            while ((i = i.next) !== head) {
2942              if (ES.SameValueZero(i.key, key)) {
2943                i.value = value;
2944                return this;
2945              }
2946            }
2947            entry = entry || new MapEntry(key, value);
2948            if (ES.SameValue(-0, key)) {
2949              entry.key = +0; // coerce -0 to +0 in entry
2950            }
2951            entry.next = this._head;
2952            entry.prev = this._head.prev;
2953            entry.prev.next = entry;
2954            entry.next.prev = entry;
2955            this._size += 1;
2956            return this;
2957          },
2958
2959          'delete': function (key) {
2960            requireMapSlot(this, 'delete');
2961            var head = this._head;
2962            var i = head;
2963            var fkey = fastkey(key);
2964            if (fkey !== null) {
2965              // fast O(1) path
2966              if (typeof this._storage[fkey] === 'undefined') {
2967                return false;
2968              }
2969              i = this._storage[fkey].prev;
2970              delete this._storage[fkey];
2971              // fall through
2972            }
2973            while ((i = i.next) !== head) {
2974              if (ES.SameValueZero(i.key, key)) {
2975                i.key = i.value = empty;
2976                i.prev.next = i.next;
2977                i.next.prev = i.prev;
2978                this._size -= 1;
2979                return true;
2980              }
2981            }
2982            return false;
2983          },
2984
2985          clear: function clear() {
2986            requireMapSlot(this, 'clear');
2987            this._size = 0;
2988            this._storage = emptyObject();
2989            var head = this._head;
2990            var i = head;
2991            var p = i.next;
2992            while ((i = p) !== head) {
2993              i.key = i.value = empty;
2994              p = i.next;
2995              i.next = i.prev = head;
2996            }
2997            head.next = head.prev = head;
2998          },
2999
3000          keys: function keys() {
3001            requireMapSlot(this, 'keys');
3002            return new MapIterator(this, 'key');
3003          },
3004
3005          values: function values() {
3006            requireMapSlot(this, 'values');
3007            return new MapIterator(this, 'value');
3008          },
3009
3010          entries: function entries() {
3011            requireMapSlot(this, 'entries');
3012            return new MapIterator(this, 'key+value');
3013          },
3014
3015          forEach: function forEach(callback) {
3016            requireMapSlot(this, 'forEach');
3017            var context = arguments.length > 1 ? arguments[1] : null;
3018            var it = this.entries();
3019            for (var entry = it.next(); !entry.done; entry = it.next()) {
3020              if (context) {
3021                _call(callback, context, entry.value[1], entry.value[0], this);
3022              } else {
3023                callback(entry.value[1], entry.value[0], this);
3024              }
3025            }
3026          }
3027        });
3028        addIterator(Map$prototype, Map$prototype.entries);
3029
3030        return MapShim;
3031      }()),
3032
3033      Set: (function () {
3034        var isSet = function isSet(set) {
3035          return set._es6set && typeof set._storage !== 'undefined';
3036        };
3037        var requireSetSlot = function requireSetSlot(set, method) {
3038          if (!ES.TypeIsObject(set) || !isSet(set)) {
3039            // https://github.com/paulmillr/es6-shim/issues/176
3040            throw new TypeError('Set.prototype.' + method + ' called on incompatible receiver ' + ES.ToString(set));
3041          }
3042        };
3043
3044        // Creating a Map is expensive.  To speed up the common case of
3045        // Sets containing only string or numeric keys, we use an object
3046        // as backing storage and lazily create a full Map only when
3047        // required.
3048        var Set$prototype;
3049        var SetShim = function Set() {
3050          if (!(this instanceof Set)) {
3051            throw new TypeError('Constructor Set requires "new"');
3052          }
3053          if (this && this._es6set) {
3054            throw new TypeError('Bad construction');
3055          }
3056          var set = emulateES6construct(this, Set, Set$prototype, {
3057            _es6set: true,
3058            '[[SetData]]': null,
3059            _storage: emptyObject()
3060          });
3061          if (!set._es6set) {
3062            throw new TypeError('bad set');
3063          }
3064
3065          // Optionally initialize Set from iterable
3066          if (arguments.length > 0) {
3067            addIterableToSet(Set, set, arguments[0]);
3068          }
3069          return set;
3070        };
3071        Set$prototype = SetShim.prototype;
3072
3073        var decodeKey = function (key) {
3074          var k = key;
3075          if (k === '^null') {
3076            return null;
3077          } else if (k === '^undefined') {
3078            return void 0;
3079          } else {
3080            var first = k.charAt(0);
3081            if (first === '$') {
3082              return _strSlice(k, 1);
3083            } else if (first === 'n') {
3084              return +_strSlice(k, 1);
3085            } else if (first === 'b') {
3086              return k === 'btrue';
3087            }
3088          }
3089          return +k;
3090        };
3091        // Switch from the object backing storage to a full Map.
3092        var ensureMap = function ensureMap(set) {
3093          if (!set['[[SetData]]']) {
3094            var m = set['[[SetData]]'] = new collectionShims.Map();
3095            _forEach(keys(set._storage), function (key) {
3096              var k = decodeKey(key);
3097              m.set(k, k);
3098            });
3099            set['[[SetData]]'] = m;
3100          }
3101          set._storage = null; // free old backing storage
3102        };
3103
3104        Value.getter(SetShim.prototype, 'size', function () {
3105          requireSetSlot(this, 'size');
3106          if (this._storage) {
3107            return keys(this._storage).length;
3108          }
3109          ensureMap(this);
3110          return this['[[SetData]]'].size;
3111        });
3112
3113        defineProperties(SetShim.prototype, {
3114          has: function has(key) {
3115            requireSetSlot(this, 'has');
3116            var fkey;
3117            if (this._storage && (fkey = fastkey(key)) !== null) {
3118              return !!this._storage[fkey];
3119            }
3120            ensureMap(this);
3121            return this['[[SetData]]'].has(key);
3122          },
3123
3124          add: function add(key) {
3125            requireSetSlot(this, 'add');
3126            var fkey;
3127            if (this._storage && (fkey = fastkey(key)) !== null) {
3128              this._storage[fkey] = true;
3129              return this;
3130            }
3131            ensureMap(this);
3132            this['[[SetData]]'].set(key, key);
3133            return this;
3134          },
3135
3136          'delete': function (key) {
3137            requireSetSlot(this, 'delete');
3138            var fkey;
3139            if (this._storage && (fkey = fastkey(key)) !== null) {
3140              var hasFKey = _hasOwnProperty(this._storage, fkey);
3141              return (delete this._storage[fkey]) && hasFKey;
3142            }
3143            ensureMap(this);
3144            return this['[[SetData]]']['delete'](key);
3145          },
3146
3147          clear: function clear() {
3148            requireSetSlot(this, 'clear');
3149            if (this._storage) {
3150              this._storage = emptyObject();
3151            }
3152            if (this['[[SetData]]']) {
3153              this['[[SetData]]'].clear();
3154            }
3155          },
3156
3157          values: function values() {
3158            requireSetSlot(this, 'values');
3159            ensureMap(this);
3160            return this['[[SetData]]'].values();
3161          },
3162
3163          entries: function entries() {
3164            requireSetSlot(this, 'entries');
3165            ensureMap(this);
3166            return this['[[SetData]]'].entries();
3167          },
3168
3169          forEach: function forEach(callback) {
3170            requireSetSlot(this, 'forEach');
3171            var context = arguments.length > 1 ? arguments[1] : null;
3172            var entireSet = this;
3173            ensureMap(entireSet);
3174            this['[[SetData]]'].forEach(function (value, key) {
3175              if (context) {
3176                _call(callback, context, key, key, entireSet);
3177              } else {
3178                callback(key, key, entireSet);
3179              }
3180            });
3181          }
3182        });
3183        defineProperty(SetShim.prototype, 'keys', SetShim.prototype.values, true);
3184        addIterator(SetShim.prototype, SetShim.prototype.values);
3185
3186        return SetShim;
3187      }())
3188    };
3189
3190    if (globals.Map || globals.Set) {
3191      // Safari 8, for example, doesn't accept an iterable.
3192      var mapAcceptsArguments = valueOrFalseIfThrows(function () { return new Map([[1, 2]]).get(1) === 2; });
3193      if (!mapAcceptsArguments) {
3194        var OrigMapNoArgs = globals.Map;
3195        globals.Map = function Map() {
3196          if (!(this instanceof Map)) {
3197            throw new TypeError('Constructor Map requires "new"');
3198          }
3199          var m = new OrigMapNoArgs();
3200          if (arguments.length > 0) {
3201            addIterableToMap(Map, m, arguments[0]);
3202          }
3203          delete m.constructor;
3204          Object.setPrototypeOf(m, globals.Map.prototype);
3205          return m;
3206        };
3207        globals.Map.prototype = create(OrigMapNoArgs.prototype);
3208        defineProperty(globals.Map.prototype, 'constructor', globals.Map, true);
3209        Value.preserveToString(globals.Map, OrigMapNoArgs);
3210      }
3211      var testMap = new Map();
3212      var mapUsesSameValueZero = (function () {
3213        // Chrome 38-42, node 0.11/0.12, iojs 1/2 also have a bug when the Map has a size > 4
3214        var m = new Map([[1, 0], [2, 0], [3, 0], [4, 0]]);
3215        m.set(-0, m);
3216        return m.get(0) === m && m.get(-0) === m && m.has(0) && m.has(-0);
3217      }());
3218      var mapSupportsChaining = testMap.set(1, 2) === testMap;
3219      if (!mapUsesSameValueZero || !mapSupportsChaining) {
3220        var origMapSet = Map.prototype.set;
3221        overrideNative(Map.prototype, 'set', function set(k, v) {
3222          _call(origMapSet, this, k === 0 ? 0 : k, v);
3223          return this;
3224        });
3225      }
3226      if (!mapUsesSameValueZero) {
3227        var origMapGet = Map.prototype.get;
3228        var origMapHas = Map.prototype.has;
3229        defineProperties(Map.prototype, {
3230          get: function get(k) {
3231            return _call(origMapGet, this, k === 0 ? 0 : k);
3232          },
3233          has: function has(k) {
3234            return _call(origMapHas, this, k === 0 ? 0 : k);
3235          }
3236        }, true);
3237        Value.preserveToString(Map.prototype.get, origMapGet);
3238        Value.preserveToString(Map.prototype.has, origMapHas);
3239      }
3240      var testSet = new Set();
3241      var setUsesSameValueZero = (function (s) {
3242        s['delete'](0);
3243        s.add(-0);
3244        return !s.has(0);
3245      }(testSet));
3246      var setSupportsChaining = testSet.add(1) === testSet;
3247      if (!setUsesSameValueZero || !setSupportsChaining) {
3248        var origSetAdd = Set.prototype.add;
3249        Set.prototype.add = function add(v) {
3250          _call(origSetAdd, this, v === 0 ? 0 : v);
3251          return this;
3252        };
3253        Value.preserveToString(Set.prototype.add, origSetAdd);
3254      }
3255      if (!setUsesSameValueZero) {
3256        var origSetHas = Set.prototype.has;
3257        Set.prototype.has = function has(v) {
3258          return _call(origSetHas, this, v === 0 ? 0 : v);
3259        };
3260        Value.preserveToString(Set.prototype.has, origSetHas);
3261        var origSetDel = Set.prototype['delete'];
3262        Set.prototype['delete'] = function SetDelete(v) {
3263          return _call(origSetDel, this, v === 0 ? 0 : v);
3264        };
3265        Value.preserveToString(Set.prototype['delete'], origSetDel);
3266      }
3267      var mapSupportsSubclassing = supportsSubclassing(globals.Map, function (M) {
3268        var m = new M([]);
3269        // Firefox 32 is ok with the instantiating the subclass but will
3270        // throw when the map is used.
3271        m.set(42, 42);
3272        return m instanceof M;
3273      });
3274      var mapFailsToSupportSubclassing = Object.setPrototypeOf && !mapSupportsSubclassing; // without Object.setPrototypeOf, subclassing is not possible
3275      var mapRequiresNew = (function () {
3276        try {
3277          return !(globals.Map() instanceof globals.Map);
3278        } catch (e) {
3279          return e instanceof TypeError;
3280        }
3281      }());
3282      if (globals.Map.length !== 0 || mapFailsToSupportSubclassing || !mapRequiresNew) {
3283        var OrigMap = globals.Map;
3284        globals.Map = function Map() {
3285          if (!(this instanceof Map)) {
3286            throw new TypeError('Constructor Map requires "new"');
3287          }
3288          var m = new OrigMap();
3289          if (arguments.length > 0) {
3290            addIterableToMap(Map, m, arguments[0]);
3291          }
3292          delete m.constructor;
3293          Object.setPrototypeOf(m, Map.prototype);
3294          return m;
3295        };
3296        globals.Map.prototype = OrigMap.prototype;
3297        defineProperty(globals.Map.prototype, 'constructor', globals.Map, true);
3298        Value.preserveToString(globals.Map, OrigMap);
3299      }
3300      var setSupportsSubclassing = supportsSubclassing(globals.Set, function (S) {
3301        var s = new S([]);
3302        s.add(42, 42);
3303        return s instanceof S;
3304      });
3305      var setFailsToSupportSubclassing = Object.setPrototypeOf && !setSupportsSubclassing; // without Object.setPrototypeOf, subclassing is not possible
3306      var setRequiresNew = (function () {
3307        try {
3308          return !(globals.Set() instanceof globals.Set);
3309        } catch (e) {
3310          return e instanceof TypeError;
3311        }
3312      }());
3313      if (globals.Set.length !== 0 || setFailsToSupportSubclassing || !setRequiresNew) {
3314        var OrigSet = globals.Set;
3315        globals.Set = function Set() {
3316          if (!(this instanceof Set)) {
3317            throw new TypeError('Constructor Set requires "new"');
3318          }
3319          var s = new OrigSet();
3320          if (arguments.length > 0) {
3321            addIterableToSet(Set, s, arguments[0]);
3322          }
3323          delete s.constructor;
3324          Object.setPrototypeOf(s, Set.prototype);
3325          return s;
3326        };
3327        globals.Set.prototype = OrigSet.prototype;
3328        defineProperty(globals.Set.prototype, 'constructor', globals.Set, true);
3329        Value.preserveToString(globals.Set, OrigSet);
3330      }
3331      var newMap = new globals.Map();
3332      var mapIterationThrowsStopIterator = !valueOrFalseIfThrows(function () {
3333        return newMap.keys().next().done;
3334      });
3335      /*
3336        - In Firefox < 23, Map#size is a function.
3337        - In all current Firefox, Set#entries/keys/values & Map#clear do not exist
3338        - https://bugzilla.mozilla.org/show_bug.cgi?id=869996
vendor: 15,248 bytes, lines 3339-3777
3339        - In Firefox 24, Map and Set do not implement forEach
3340        - In Firefox 25 at least, Map and Set are callable without "new"
3341      */
3342      if (
3343        typeof globals.Map.prototype.clear !== 'function' ||
3344        new globals.Set().size !== 0 ||
3345        newMap.size !== 0 ||
3346        typeof globals.Map.prototype.keys !== 'function' ||
3347        typeof globals.Set.prototype.keys !== 'function' ||
3348        typeof globals.Map.prototype.forEach !== 'function' ||
3349        typeof globals.Set.prototype.forEach !== 'function' ||
3350        isCallableWithoutNew(globals.Map) ||
3351        isCallableWithoutNew(globals.Set) ||
3352        typeof newMap.keys().next !== 'function' || // Safari 8
3353        mapIterationThrowsStopIterator || // Firefox 25
3354        !mapSupportsSubclassing
3355      ) {
3356        defineProperties(globals, {
3357          Map: collectionShims.Map,
3358          Set: collectionShims.Set
3359        }, true);
3360      }
3361
3362      if (globals.Set.prototype.keys !== globals.Set.prototype.values) {
3363        // Fixed in WebKit with https://bugs.webkit.org/show_bug.cgi?id=144190
3364        defineProperty(globals.Set.prototype, 'keys', globals.Set.prototype.values, true);
3365      }
3366
3367      // Shim incomplete iterator implementations.
3368      addIterator(Object.getPrototypeOf((new globals.Map()).keys()));
3369      addIterator(Object.getPrototypeOf((new globals.Set()).keys()));
3370
3371      if (functionsHaveNames && globals.Set.prototype.has.name !== 'has') {
3372        // Microsoft Edge v0.11.10074.0 is missing a name on Set#has
3373        var anonymousSetHas = globals.Set.prototype.has;
3374        overrideNative(globals.Set.prototype, 'has', function has(key) {
3375          return _call(anonymousSetHas, this, key);
3376        });
3377      }
3378    }
3379    defineProperties(globals, collectionShims);
3380    addDefaultSpecies(globals.Map);
3381    addDefaultSpecies(globals.Set);
3382  }
3383
3384  var throwUnlessTargetIsObject = function throwUnlessTargetIsObject(target) {
3385    if (!ES.TypeIsObject(target)) {
3386      throw new TypeError('target must be an object');
3387    }
3388  };
3389
3390  // Some Reflect methods are basically the same as
3391  // those on the Object global, except that a TypeError is thrown if
3392  // target isn't an object. As well as returning a boolean indicating
3393  // the success of the operation.
3394  var ReflectShims = {
3395    // Apply method in a functional form.
3396    apply: function apply() {
3397      return ES.Call(ES.Call, null, arguments);
3398    },
3399
3400    // New operator in a functional form.
3401    construct: function construct(constructor, args) {
3402      if (!ES.IsConstructor(constructor)) {
3403        throw new TypeError('First argument must be a constructor.');
3404      }
3405      var newTarget = arguments.length > 2 ? arguments[2] : constructor;
3406      if (!ES.IsConstructor(newTarget)) {
3407        throw new TypeError('new.target must be a constructor.');
3408      }
3409      return ES.Construct(constructor, args, newTarget, 'internal');
3410    },
3411
3412    // When deleting a non-existent or configurable property,
3413    // true is returned.
3414    // When attempting to delete a non-configurable property,
3415    // it will return false.
3416    deleteProperty: function deleteProperty(target, key) {
3417      throwUnlessTargetIsObject(target);
3418      if (supportsDescriptors) {
3419        var desc = Object.getOwnPropertyDescriptor(target, key);
3420
3421        if (desc && !desc.configurable) {
3422          return false;
3423        }
3424      }
3425
3426      // Will return true.
3427      return delete target[key];
3428    },
3429
3430    has: function has(target, key) {
3431      throwUnlessTargetIsObject(target);
3432      return key in target;
3433    }
3434  };
3435
3436  if (Object.getOwnPropertyNames) {
3437    Object.assign(ReflectShims, {
3438      // Basically the result of calling the internal [[OwnPropertyKeys]].
3439      // Concatenating propertyNames and propertySymbols should do the trick.
3440      // This should continue to work together with a Symbol shim
3441      // which overrides Object.getOwnPropertyNames and implements
3442      // Object.getOwnPropertySymbols.
3443      ownKeys: function ownKeys(target) {
3444        throwUnlessTargetIsObject(target);
3445        var keys = Object.getOwnPropertyNames(target);
3446
3447        if (ES.IsCallable(Object.getOwnPropertySymbols)) {
3448          _pushApply(keys, Object.getOwnPropertySymbols(target));
3449        }
3450
3451        return keys;
3452      }
3453    });
3454  }
3455
3456  var callAndCatchException = function ConvertExceptionToBoolean(func) {
3457    return !throwsError(func);
3458  };
3459
3460  if (Object.preventExtensions) {
3461    Object.assign(ReflectShims, {
3462      isExtensible: function isExtensible(target) {
3463        throwUnlessTargetIsObject(target);
3464        return Object.isExtensible(target);
3465      },
3466      preventExtensions: function preventExtensions(target) {
3467        throwUnlessTargetIsObject(target);
3468        return callAndCatchException(function () {
3469          Object.preventExtensions(target);
3470        });
3471      }
3472    });
3473  }
3474
3475  if (supportsDescriptors) {
3476    var internalGet = function get(target, key, receiver) {
3477      var desc = Object.getOwnPropertyDescriptor(target, key);
3478
3479      if (!desc) {
3480        var parent = Object.getPrototypeOf(target);
3481
3482        if (parent === null) {
3483          return void 0;
3484        }
3485
3486        return internalGet(parent, key, receiver);
3487      }
3488
3489      if ('value' in desc) {
3490        return desc.value;
3491      }
3492
3493      if (desc.get) {
3494        return ES.Call(desc.get, receiver);
3495      }
3496
3497      return void 0;
3498    };
3499
3500    var internalSet = function set(target, key, value, receiver) {
3501      var desc = Object.getOwnPropertyDescriptor(target, key);
3502
3503      if (!desc) {
3504        var parent = Object.getPrototypeOf(target);
3505
3506        if (parent !== null) {
3507          return internalSet(parent, key, value, receiver);
3508        }
3509
3510        desc = {
3511          value: void 0,
3512          writable: true,
3513          enumerable: true,
3514          configurable: true
3515        };
3516      }
3517
3518      if ('value' in desc) {
3519        if (!desc.writable) {
3520          return false;
3521        }
3522
3523        if (!ES.TypeIsObject(receiver)) {
3524          return false;
3525        }
3526
3527        var existingDesc = Object.getOwnPropertyDescriptor(receiver, key);
3528
3529        if (existingDesc) {
3530          return Reflect.defineProperty(receiver, key, {
3531            value: value
3532          });
3533        } else {
3534          return Reflect.defineProperty(receiver, key, {
3535            value: value,
3536            writable: true,
3537            enumerable: true,
3538            configurable: true
3539          });
3540        }
3541      }
3542
3543      if (desc.set) {
3544        _call(desc.set, receiver, value);
3545        return true;
3546      }
3547
3548      return false;
3549    };
3550
3551    Object.assign(ReflectShims, {
3552      defineProperty: function defineProperty(target, propertyKey, attributes) {
3553        throwUnlessTargetIsObject(target);
3554        return callAndCatchException(function () {
3555          Object.defineProperty(target, propertyKey, attributes);
3556        });
3557      },
3558
3559      getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) {
3560        throwUnlessTargetIsObject(target);
3561        return Object.getOwnPropertyDescriptor(target, propertyKey);
3562      },
3563
3564      // Syntax in a functional form.
3565      get: function get(target, key) {
3566        throwUnlessTargetIsObject(target);
3567        var receiver = arguments.length > 2 ? arguments[2] : target;
3568
3569        return internalGet(target, key, receiver);
3570      },
3571
3572      set: function set(target, key, value) {
3573        throwUnlessTargetIsObject(target);
3574        var receiver = arguments.length > 3 ? arguments[3] : target;
3575
3576        return internalSet(target, key, value, receiver);
3577      }
3578    });
3579  }
3580
3581  if (Object.getPrototypeOf) {
3582    var objectDotGetPrototypeOf = Object.getPrototypeOf;
3583    ReflectShims.getPrototypeOf = function getPrototypeOf(target) {
3584      throwUnlessTargetIsObject(target);
3585      return objectDotGetPrototypeOf(target);
3586    };
3587  }
3588
3589  if (Object.setPrototypeOf && ReflectShims.getPrototypeOf) {
3590    var willCreateCircularPrototype = function (object, lastProto) {
3591      var proto = lastProto;
3592      while (proto) {
3593        if (object === proto) {
3594          return true;
3595        }
3596        proto = ReflectShims.getPrototypeOf(proto);
3597      }
3598      return false;
3599    };
3600
3601    Object.assign(ReflectShims, {
3602      // Sets the prototype of the given object.
3603      // Returns true on success, otherwise false.
3604      setPrototypeOf: function setPrototypeOf(object, proto) {
3605        throwUnlessTargetIsObject(object);
3606        if (proto !== null && !ES.TypeIsObject(proto)) {
3607          throw new TypeError('proto must be an object or null');
3608        }
3609
3610        // If they already are the same, we're done.
3611        if (proto === Reflect.getPrototypeOf(object)) {
3612          return true;
3613        }
3614
3615        // Cannot alter prototype if object not extensible.
3616        if (Reflect.isExtensible && !Reflect.isExtensible(object)) {
3617          return false;
3618        }
3619
3620        // Ensure that we do not create a circular prototype chain.
3621        if (willCreateCircularPrototype(object, proto)) {
3622          return false;
3623        }
3624
3625        Object.setPrototypeOf(object, proto);
3626
3627        return true;
3628      }
3629    });
3630  }
3631  var defineOrOverrideReflectProperty = function (key, shim) {
3632    if (!ES.IsCallable(globals.Reflect[key])) {
3633      defineProperty(globals.Reflect, key, shim);
3634    } else {
3635      var acceptsPrimitives = valueOrFalseIfThrows(function () {
3636        globals.Reflect[key](1);
3637        globals.Reflect[key](NaN);
3638        globals.Reflect[key](true);
3639        return true;
3640      });
3641      if (acceptsPrimitives) {
3642        overrideNative(globals.Reflect, key, shim);
3643      }
3644    }
3645  };
3646  Object.keys(ReflectShims).forEach(function (key) {
3647    defineOrOverrideReflectProperty(key, ReflectShims[key]);
3648  });
3649  var originalReflectGetProto = globals.Reflect.getPrototypeOf;
3650  if (functionsHaveNames && originalReflectGetProto && originalReflectGetProto.name !== 'getPrototypeOf') {
3651    overrideNative(globals.Reflect, 'getPrototypeOf', function getPrototypeOf(target) {
3652      return _call(originalReflectGetProto, globals.Reflect, target);
3653    });
3654  }
3655  if (globals.Reflect.setPrototypeOf) {
3656    if (valueOrFalseIfThrows(function () {
3657      globals.Reflect.setPrototypeOf(1, {});
3658      return true;
3659    })) {
3660      overrideNative(globals.Reflect, 'setPrototypeOf', ReflectShims.setPrototypeOf);
3661    }
3662  }
3663  if (globals.Reflect.defineProperty) {
3664    if (!valueOrFalseIfThrows(function () {
3665      var basic = !globals.Reflect.defineProperty(1, 'test', { value: 1 });
3666      // "extensible" fails on Edge 0.12
3667      var extensible = typeof Object.preventExtensions !== 'function' || !globals.Reflect.defineProperty(Object.preventExtensions({}), 'test', {});
3668      return basic && extensible;
3669    })) {
3670      overrideNative(globals.Reflect, 'defineProperty', ReflectShims.defineProperty);
3671    }
3672  }
3673  if (globals.Reflect.construct) {
3674    if (!valueOrFalseIfThrows(function () {
3675      var F = function F() {};
3676      return globals.Reflect.construct(function () {}, [], F) instanceof F;
3677    })) {
3678      overrideNative(globals.Reflect, 'construct', ReflectShims.construct);
3679    }
3680  }
3681
3682  if (String(new Date(NaN)) !== 'Invalid Date') {
3683    var dateToString = Date.prototype.toString;
3684    var shimmedDateToString = function toString() {
3685      var valueOf = +this;
3686      if (valueOf !== valueOf) {
3687        return 'Invalid Date';
3688      }
3689      return ES.Call(dateToString, this);
3690    };
3691    overrideNative(Date.prototype, 'toString', shimmedDateToString);
3692  }
3693
3694  // Annex B HTML methods
3695  // http://www.ecma-international.org/ecma-262/6.0/#sec-additional-properties-of-the-string.prototype-object
3696  var stringHTMLshims = {
3697    anchor: function anchor(name) { return ES.CreateHTML(this, 'a', 'name', name); },
3698    big: function big() { return ES.CreateHTML(this, 'big', '', ''); },
3699    blink: function blink() { return ES.CreateHTML(this, 'blink', '', ''); },
3700    bold: function bold() { return ES.CreateHTML(this, 'b', '', ''); },
3701    fixed: function fixed() { return ES.CreateHTML(this, 'tt', '', ''); },
3702    fontcolor: function fontcolor(color) { return ES.CreateHTML(this, 'font', 'color', color); },
3703    fontsize: function fontsize(size) { return ES.CreateHTML(this, 'font', 'size', size); },
3704    italics: function italics() { return ES.CreateHTML(this, 'i', '', ''); },
3705    link: function link(url) { return ES.CreateHTML(this, 'a', 'href', url); },
3706    small: function small() { return ES.CreateHTML(this, 'small', '', ''); },
3707    strike: function strike() { return ES.CreateHTML(this, 'strike', '', ''); },
3708    sub: function sub() { return ES.CreateHTML(this, 'sub', '', ''); },
3709    sup: function sub() { return ES.CreateHTML(this, 'sup', '', ''); }
3710  };
3711  _forEach(Object.keys(stringHTMLshims), function (key) {
3712    var method = String.prototype[key];
3713    var shouldOverwrite = false;
3714    if (ES.IsCallable(method)) {
3715      var output = _call(method, '', ' " ');
3716      var quotesCount = _concat([], output.match(/"/g)).length;
3717      shouldOverwrite = output !== output.toLowerCase() || quotesCount > 2;
3718    } else {
3719      shouldOverwrite = true;
3720    }
3721    if (shouldOverwrite) {
3722      overrideNative(String.prototype, key, stringHTMLshims[key]);
3723    }
3724  });
3725
3726  var JSONstringifiesSymbols = (function () {
3727    // Microsoft Edge v0.12 stringifies Symbols incorrectly
3728    if (!hasSymbols) { return false; } // Symbols are not supported
3729    var stringify = typeof JSON === 'object' && typeof JSON.stringify === 'function' ? JSON.stringify : null;
3730    if (!stringify) { return false; } // JSON.stringify is not supported
3731    if (typeof stringify(Symbol()) !== 'undefined') { return true; } // Symbols should become `undefined`
3732    if (stringify([Symbol()]) !== '[null]') { return true; } // Symbols in arrays should become `null`
3733    var obj = { a: Symbol() };
3734    obj[Symbol()] = true;
3735    if (stringify(obj) !== '{}') { return true; } // Symbol-valued keys *and* Symbol-valued properties should be omitted
3736    return false;
3737  }());
3738  var JSONstringifyAcceptsObjectSymbol = valueOrFalseIfThrows(function () {
3739    // Chrome 45 throws on stringifying object symbols
3740    if (!hasSymbols) { return true; } // Symbols are not supported
3741    return JSON.stringify(Object(Symbol())) === '{}' && JSON.stringify([Object(Symbol())]) === '[{}]';
3742  });
3743  if (JSONstringifiesSymbols || !JSONstringifyAcceptsObjectSymbol) {
3744    var origStringify = JSON.stringify;
3745    overrideNative(JSON, 'stringify', function stringify(value) {
3746      if (typeof value === 'symbol') { return; }
3747      var replacer;
3748      if (arguments.length > 1) {
3749        replacer = arguments[1];
3750      }
3751      var args = [value];
3752      if (!isArray(replacer)) {
3753        var replaceFn = ES.IsCallable(replacer) ? replacer : null;
3754        var wrappedReplacer = function (key, val) {
3755          var parsedValue = replaceFn ? _call(replaceFn, this, key, val) : val;
3756          if (typeof parsedValue !== 'symbol') {
3757            if (Type.symbol(parsedValue)) {
3758              return assignTo({})(parsedValue);
3759            } else {
3760              return parsedValue;
3761            }
3762          }
3763        };
3764        args.push(wrappedReplacer);
3765      } else {
3766        // create wrapped replacer that handles an array replacer?
3767        args.push(replacer);
3768      }
3769      if (arguments.length > 2) {
3770        args.push(arguments[2]);
3771      }
3772      return origStringify.apply(this, args);
3773    });
3774  }
3775
3776  return globals;
3777}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.