Skip to content

Instantly share code, notes, and snippets.

@1999
Last active February 8, 2017 06:53
Show Gist options
  • Save 1999/d5b51418762420a7a6026118a6b27174 to your computer and use it in GitHub Desktop.
Save 1999/d5b51418762420a7a6026118a6b27174 to your computer and use it in GitHub Desktop.
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
require('es5-shim');
require('es5-shim/es5-sham');
require('es6-shim');
// Array#includes is stage 4, in ES7/ES2016
require('array-includes/shim')();
// Object.values/Object.entries are stage 4, in ES8/ES2017
require('object.values/shim')();
require('object.entries/shim')();
// String#padStart/String#padEnd are stage 4, in ES8/ES2017
require('string.prototype.padstart/shim')();
require('string.prototype.padend/shim')();
// Object.getOwnPropertyDescriptors is stage 4, in ES8/ES2017
require('object.getownpropertydescriptors/shim')();
},{"array-includes/shim":4,"es5-shim":19,"es5-shim/es5-sham":18,"es6-shim":20,"object.entries/shim":33,"object.getownpropertydescriptors/shim":36,"object.values/shim":39,"string.prototype.padend/shim":43,"string.prototype.padstart/shim":46}],2:[function(require,module,exports){
(function (global){
'use strict';
var ES = require('es-abstract/es6');
var $isNaN = Number.isNaN || function (a) { return a !== a; };
var $isFinite = Number.isFinite || function (n) { return typeof n === 'number' && global.isFinite(n); };
var indexOf = Array.prototype.indexOf;
module.exports = function includes(searchElement) {
var fromIndex = arguments.length > 1 ? ES.ToInteger(arguments[1]) : 0;
if (indexOf && !$isNaN(searchElement) && $isFinite(fromIndex) && typeof searchElement !== 'undefined') {
return indexOf.apply(this, arguments) > -1;
}
var O = ES.ToObject(this);
var length = ES.ToLength(O.length);
if (length === 0) {
return false;
}
var k = fromIndex >= 0 ? fromIndex : Math.max(0, length + fromIndex);
while (k < length) {
if (ES.SameValueZero(searchElement, O[k])) {
return true;
}
k += 1;
}
return false;
};
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"es-abstract/es6":7}],3:[function(require,module,exports){
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return Array.prototype.includes || implementation;
};
},{"./implementation":2}],4:[function(require,module,exports){
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
module.exports = function shimArrayPrototypeIncludes() {
var polyfill = getPolyfill();
if (Array.prototype.includes !== polyfill) {
define(Array.prototype, { includes: polyfill });
}
return polyfill;
};
},{"./polyfill":3,"define-properties":5}],5:[function(require,module,exports){
'use strict';
var keys = require('object-keys');
var foreach = require('foreach');
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
var toStr = Object.prototype.toString;
var isFunction = function (fn) {
return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
};
var arePropertyDescriptorsSupported = function () {
var obj = {};
try {
Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
/* eslint-disable no-unused-vars, no-restricted-syntax */
for (var _ in obj) { return false; }
/* eslint-enable no-unused-vars, no-restricted-syntax */
return obj.x === obj;
} catch (e) { /* this is IE 8. */
return false;
}
};
var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();
var defineProperty = function (object, name, value, predicate) {
if (name in object && (!isFunction(predicate) || !predicate())) {
return;
}
if (supportsDescriptors) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
value: value,
writable: true
});
} else {
object[name] = value;
}
};
var defineProperties = function (object, map) {
var predicates = arguments.length > 2 ? arguments[2] : {};
var props = keys(map);
if (hasSymbols) {
props = props.concat(Object.getOwnPropertySymbols(map));
}
foreach(props, function (name) {
defineProperty(object, name, map[name], predicates[name]);
});
};
defineProperties.supportsDescriptors = !!supportsDescriptors;
module.exports = defineProperties;
},{"foreach":21,"object-keys":29}],6:[function(require,module,exports){
'use strict';
var $isNaN = require('./helpers/isNaN');
var $isFinite = require('./helpers/isFinite');
var sign = require('./helpers/sign');
var mod = require('./helpers/mod');
var IsCallable = require('is-callable');
var toPrimitive = require('es-to-primitive/es5');
// https://es5.github.io/#x9
var ES5 = {
ToPrimitive: toPrimitive,
ToBoolean: function ToBoolean(value) {
return Boolean(value);
},
ToNumber: function ToNumber(value) {
return Number(value);
},
ToInteger: function ToInteger(value) {
var number = this.ToNumber(value);
if ($isNaN(number)) { return 0; }
if (number === 0 || !$isFinite(number)) { return number; }
return sign(number) * Math.floor(Math.abs(number));
},
ToInt32: function ToInt32(x) {
return this.ToNumber(x) >> 0;
},
ToUint32: function ToUint32(x) {
return this.ToNumber(x) >>> 0;
},
ToUint16: function ToUint16(value) {
var number = this.ToNumber(value);
if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
var posInt = sign(number) * Math.floor(Math.abs(number));
return mod(posInt, 0x10000);
},
ToString: function ToString(value) {
return String(value);
},
ToObject: function ToObject(value) {
this.CheckObjectCoercible(value);
return Object(value);
},
CheckObjectCoercible: function CheckObjectCoercible(value, optMessage) {
/* jshint eqnull:true */
if (value == null) {
throw new TypeError(optMessage || 'Cannot call method on ' + value);
}
return value;
},
IsCallable: IsCallable,
SameValue: function SameValue(x, y) {
if (x === y) { // 0 === -0, but they are not identical.
if (x === 0) { return 1 / x === 1 / y; }
return true;
}
return $isNaN(x) && $isNaN(y);
},
// http://www.ecma-international.org/ecma-262/5.1/#sec-8
Type: function Type(x) {
if (x === null) {
return 'Null';
}
if (typeof x === 'undefined') {
return 'Undefined';
}
if (typeof x === 'function' || typeof x === 'object') {
return 'Object';
}
if (typeof x === 'number') {
return 'Number';
}
if (typeof x === 'boolean') {
return 'Boolean';
}
if (typeof x === 'string') {
return 'String';
}
}
};
module.exports = ES5;
},{"./helpers/isFinite":10,"./helpers/isNaN":11,"./helpers/mod":13,"./helpers/sign":14,"es-to-primitive/es5":15,"is-callable":25}],7:[function(require,module,exports){
'use strict';
var toStr = Object.prototype.toString;
var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
var symbolToStr = hasSymbols ? Symbol.prototype.toString : toStr;
var $isNaN = require('./helpers/isNaN');
var $isFinite = require('./helpers/isFinite');
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
var assign = require('./helpers/assign');
var sign = require('./helpers/sign');
var mod = require('./helpers/mod');
var isPrimitive = require('./helpers/isPrimitive');
var toPrimitive = require('es-to-primitive/es6');
var parseInteger = parseInt;
var bind = require('function-bind');
var strSlice = bind.call(Function.call, String.prototype.slice);
var isBinary = bind.call(Function.call, RegExp.prototype.test, /^0b[01]+$/i);
var isOctal = bind.call(Function.call, RegExp.prototype.test, /^0o[0-7]+$/i);
var nonWS = ['\u0085', '\u200b', '\ufffe'].join('');
var nonWSregex = new RegExp('[' + nonWS + ']', 'g');
var hasNonWS = bind.call(Function.call, RegExp.prototype.test, nonWSregex);
var invalidHexLiteral = /^[-+]0x[0-9a-f]+$/i;
var isInvalidHexLiteral = bind.call(Function.call, RegExp.prototype.test, invalidHexLiteral);
// whitespace from: http://es5.github.io/#x15.5.4.20
// implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324
var ws = [
'\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003',
'\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028',
'\u2029\uFEFF'
].join('');
var trimRegex = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
var replace = bind.call(Function.call, String.prototype.replace);
var trim = function (value) {
return replace(value, trimRegex, '');
};
var ES5 = require('./es5');
var hasRegExpMatcher = require('is-regex');
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-abstract-operations
var ES6 = assign(assign({}, ES5), {
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args
Call: function Call(F, V) {
var args = arguments.length > 2 ? arguments[2] : [];
if (!this.IsCallable(F)) {
throw new TypeError(F + ' is not a function');
}
return F.apply(V, args);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toprimitive
ToPrimitive: toPrimitive,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toboolean
// ToBoolean: ES5.ToBoolean,
// http://www.ecma-international.org/ecma-262/6.0/#sec-tonumber
ToNumber: function ToNumber(argument) {
var value = isPrimitive(argument) ? argument : toPrimitive(argument, 'number');
if (typeof value === 'symbol') {
throw new TypeError('Cannot convert a Symbol value to a number');
}
if (typeof value === 'string') {
if (isBinary(value)) {
return this.ToNumber(parseInteger(strSlice(value, 2), 2));
} else if (isOctal(value)) {
return this.ToNumber(parseInteger(strSlice(value, 2), 8));
} else if (hasNonWS(value) || isInvalidHexLiteral(value)) {
return NaN;
} else {
var trimmed = trim(value);
if (trimmed !== value) {
return this.ToNumber(trimmed);
}
}
}
return Number(value);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tointeger
// ToInteger: ES5.ToNumber,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint32
// ToInt32: ES5.ToInt32,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint32
// ToUint32: ES5.ToUint32,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint16
ToInt16: function ToInt16(argument) {
var int16bit = this.ToUint16(argument);
return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit;
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint16
// ToUint16: ES5.ToUint16,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint8
ToInt8: function ToInt8(argument) {
var int8bit = this.ToUint8(argument);
return int8bit >= 0x80 ? int8bit - 0x100 : int8bit;
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8
ToUint8: function ToUint8(argument) {
var number = this.ToNumber(argument);
if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
var posInt = sign(number) * Math.floor(Math.abs(number));
return mod(posInt, 0x100);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8clamp
ToUint8Clamp: function ToUint8Clamp(argument) {
var number = this.ToNumber(argument);
if ($isNaN(number) || number <= 0) { return 0; }
if (number >= 0xFF) { return 0xFF; }
var f = Math.floor(argument);
if (f + 0.5 < number) { return f + 1; }
if (number < f + 0.5) { return f; }
if (f % 2 !== 0) { return f + 1; }
return f;
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tostring
ToString: function ToString(argument) {
if (typeof argument === 'symbol') {
throw new TypeError('Cannot convert a Symbol value to a string');
}
return String(argument);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toobject
ToObject: function ToObject(value) {
this.RequireObjectCoercible(value);
return Object(value);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-topropertykey
ToPropertyKey: function ToPropertyKey(argument) {
var key = this.ToPrimitive(argument, String);
return typeof key === 'symbol' ? symbolToStr.call(key) : this.ToString(key);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
ToLength: function ToLength(argument) {
var len = this.ToInteger(argument);
if (len <= 0) { return 0; } // includes converting -0 to +0
if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; }
return len;
},
// http://www.ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring
CanonicalNumericIndexString: function CanonicalNumericIndexString(argument) {
if (toStr.call(argument) !== '[object String]') {
throw new TypeError('must be a string');
}
if (argument === '-0') { return -0; }
var n = this.ToNumber(argument);
if (this.SameValue(this.ToString(n), argument)) { return n; }
return void 0;
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-requireobjectcoercible
RequireObjectCoercible: ES5.CheckObjectCoercible,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray
IsArray: Array.isArray || function IsArray(argument) {
return toStr.call(argument) === '[object Array]';
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-iscallable
// IsCallable: ES5.IsCallable,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor
IsConstructor: function IsConstructor(argument) {
return typeof argument === 'function' && !!argument.prototype; // unfortunately there's no way to truly check this without try/catch `new argument`
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isextensible-o
IsExtensible: function IsExtensible(obj) {
if (!Object.preventExtensions) { return true; }
if (isPrimitive(obj)) {
return false;
}
return Object.isExtensible(obj);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isinteger
IsInteger: function IsInteger(argument) {
if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) {
return false;
}
var abs = Math.abs(argument);
return Math.floor(abs) === abs;
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ispropertykey
IsPropertyKey: function IsPropertyKey(argument) {
return typeof argument === 'string' || typeof argument === 'symbol';
},
// http://www.ecma-international.org/ecma-262/6.0/#sec-isregexp
IsRegExp: function IsRegExp(argument) {
if (!argument || typeof argument !== 'object') {
return false;
}
if (hasSymbols) {
var isRegExp = argument[Symbol.match];
if (typeof isRegExp !== 'undefined') {
return ES5.ToBoolean(isRegExp);
}
}
return hasRegExpMatcher(argument);
},
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevalue
// SameValue: ES5.SameValue,
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero
SameValueZero: function SameValueZero(x, y) {
return (x === y) || ($isNaN(x) && $isNaN(y));
},
/**
* 7.3.2 GetV (V, P)
* 1. Assert: IsPropertyKey(P) is true.
* 2. Let O be ToObject(V).
* 3. ReturnIfAbrupt(O).
* 4. Return O.[[Get]](P, V).
*/
GetV: function GetV(V, P) {
// 7.3.2.1
if (!this.IsPropertyKey(P)) {
throw new TypeError('Assertion failed: IsPropertyKey(P) is not true');
}
// 7.3.2.2-3
var O = this.ToObject(V);
// 7.3.2.4
return O[P];
},
/**
* 7.3.9 - http://www.ecma-international.org/ecma-262/6.0/#sec-getmethod
* 1. Assert: IsPropertyKey(P) is true.
* 2. Let func be GetV(O, P).
* 3. ReturnIfAbrupt(func).
* 4. If func is either undefined or null, return undefined.
* 5. If IsCallable(func) is false, throw a TypeError exception.
* 6. Return func.
*/
GetMethod: function GetMethod(O, P) {
// 7.3.9.1
if (!this.IsPropertyKey(P)) {
throw new TypeError('Assertion failed: IsPropertyKey(P) is not true');
}
// 7.3.9.2
var func = this.GetV(O, P);
// 7.3.9.4
if (func == null) {
return undefined;
}
// 7.3.9.5
if (!this.IsCallable(func)) {
throw new TypeError(P + 'is not a function');
}
// 7.3.9.6
return func;
},
/**
* 7.3.1 Get (O, P) - http://www.ecma-international.org/ecma-262/6.0/#sec-get-o-p
* 1. Assert: Type(O) is Object.
* 2. Assert: IsPropertyKey(P) is true.
* 3. Return O.[[Get]](P, O).
*/
Get: function Get(O, P) {
// 7.3.1.1
if (this.Type(O) !== 'Object') {
throw new TypeError('Assertion failed: Type(O) is not Object');
}
// 7.3.1.2
if (!this.IsPropertyKey(P)) {
throw new TypeError('Assertion failed: IsPropertyKey(P) is not true');
}
// 7.3.1.3
return O[P];
},
Type: function Type(x) {
if (typeof x === 'symbol') {
return 'Symbol';
}
return ES5.Type(x);
},
// http://www.ecma-international.org/ecma-262/6.0/#sec-speciesconstructor
SpeciesConstructor: function SpeciesConstructor(O, defaultConstructor) {
if (this.Type(O) !== 'Object') {
throw new TypeError('Assertion failed: Type(O) is not Object');
}
var C = O.constructor;
if (typeof C === 'undefined') {
return defaultConstructor;
}
if (this.Type(C) !== 'Object') {
throw new TypeError('O.constructor is not an Object');
}
var S = hasSymbols && Symbol.species ? C[Symbol.species] : undefined;
if (S == null) {
return defaultConstructor;
}
if (this.IsConstructor(S)) {
return S;
}
throw new TypeError('no constructor found');
}
});
delete ES6.CheckObjectCoercible; // renamed in ES6 to RequireObjectCoercible
module.exports = ES6;
},{"./es5":6,"./helpers/assign":9,"./helpers/isFinite":10,"./helpers/isNaN":11,"./helpers/isPrimitive":12,"./helpers/mod":13,"./helpers/sign":14,"es-to-primitive/es6":16,"function-bind":23,"is-regex":27}],8:[function(require,module,exports){
'use strict';
var ES6 = require('./es6');
var assign = require('./helpers/assign');
var ES7 = assign(ES6, {
// https://github.com/tc39/ecma262/pull/60
SameValueNonNumber: function SameValueNonNumber(x, y) {
if (typeof x === 'number' || typeof x !== typeof y) {
throw new TypeError('SameValueNonNumber requires two non-number values of the same type.');
}
return this.SameValue(x, y);
}
});
module.exports = ES7;
},{"./es6":7,"./helpers/assign":9}],9:[function(require,module,exports){
var has = Object.prototype.hasOwnProperty;
module.exports = Object.assign || function assign(target, source) {
for (var key in source) {
if (has.call(source, key)) {
target[key] = source[key];
}
}
return target;
};
},{}],10:[function(require,module,exports){
var $isNaN = Number.isNaN || function (a) { return a !== a; };
module.exports = Number.isFinite || function (x) { return typeof x === 'number' && !$isNaN(x) && x !== Infinity && x !== -Infinity; };
},{}],11:[function(require,module,exports){
module.exports = Number.isNaN || function isNaN(a) {
return a !== a;
};
},{}],12:[function(require,module,exports){
module.exports = function isPrimitive(value) {
return value === null || (typeof value !== 'function' && typeof value !== 'object');
};
},{}],13:[function(require,module,exports){
module.exports = function mod(number, modulo) {
var remain = number % modulo;
return Math.floor(remain >= 0 ? remain : remain + modulo);
};
},{}],14:[function(require,module,exports){
module.exports = function sign(number) {
return number >= 0 ? 1 : -1;
};
},{}],15:[function(require,module,exports){
'use strict';
var toStr = Object.prototype.toString;
var isPrimitive = require('./helpers/isPrimitive');
var isCallable = require('is-callable');
// https://es5.github.io/#x8.12
var ES5internalSlots = {
'[[DefaultValue]]': function (O, hint) {
var actualHint = hint || (toStr.call(O) === '[object Date]' ? String : Number);
if (actualHint === String || actualHint === Number) {
var methods = actualHint === String ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
var value, i;
for (i = 0; i < methods.length; ++i) {
if (isCallable(O[methods[i]])) {
value = O[methods[i]]();
if (isPrimitive(value)) {
return value;
}
}
}
throw new TypeError('No default value');
}
throw new TypeError('invalid [[DefaultValue]] hint supplied');
}
};
// https://es5.github.io/#x9
module.exports = function ToPrimitive(input, PreferredType) {
if (isPrimitive(input)) {
return input;
}
return ES5internalSlots['[[DefaultValue]]'](input, PreferredType);
};
},{"./helpers/isPrimitive":17,"is-callable":25}],16:[function(require,module,exports){
'use strict';
var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
var isPrimitive = require('./helpers/isPrimitive');
var isCallable = require('is-callable');
var isDate = require('is-date-object');
var isSymbol = require('is-symbol');
var ordinaryToPrimitive = function OrdinaryToPrimitive(O, hint) {
if (typeof O === 'undefined' || O === null) {
throw new TypeError('Cannot call method on ' + O);
}
if (typeof hint !== 'string' || (hint !== 'number' && hint !== 'string')) {
throw new TypeError('hint must be "string" or "number"');
}
var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
var method, result, i;
for (i = 0; i < methodNames.length; ++i) {
method = O[methodNames[i]];
if (isCallable(method)) {
result = method.call(O);
if (isPrimitive(result)) {
return result;
}
}
}
throw new TypeError('No default value');
};
var GetMethod = function GetMethod(O, P) {
var func = O[P];
if (func !== null && typeof func !== 'undefined') {
if (!isCallable(func)) {
throw new TypeError(func + ' returned for property ' + P + ' of object ' + O + ' is not a function');
}
return func;
}
};
// http://www.ecma-international.org/ecma-262/6.0/#sec-toprimitive
module.exports = function ToPrimitive(input, PreferredType) {
if (isPrimitive(input)) {
return input;
}
var hint = 'default';
if (arguments.length > 1) {
if (PreferredType === String) {
hint = 'string';
} else if (PreferredType === Number) {
hint = 'number';
}
}
var exoticToPrim;
if (hasSymbols) {
if (Symbol.toPrimitive) {
exoticToPrim = GetMethod(input, Symbol.toPrimitive);
} else if (isSymbol(input)) {
exoticToPrim = Symbol.prototype.valueOf;
}
}
if (typeof exoticToPrim !== 'undefined') {
var result = exoticToPrim.call(input, hint);
if (isPrimitive(result)) {
return result;
}
throw new TypeError('unable to convert exotic object to primitive');
}
if (hint === 'default' && (isDate(input) || isSymbol(input))) {
hint = 'string';
}
return ordinaryToPrimitive(input, hint === 'default' ? 'number' : hint);
};
},{"./helpers/isPrimitive":17,"is-callable":25,"is-date-object":26,"is-symbol":28}],17:[function(require,module,exports){
arguments[4][12][0].apply(exports,arguments)
},{"dup":12}],18:[function(require,module,exports){
/*!
* https://github.com/es-shims/es5-shim
* @license es5-shim Copyright 2009-2015 by contributors, MIT License
* see https://github.com/es-shims/es5-shim/blob/master/LICENSE
*/
// vim: ts=4 sts=4 sw=4 expandtab
// Add semicolon to prevent IIFE from being passed as argument to concatenated code.
;
// UMD (Universal Module Definition)
// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js
(function (root, factory) {
'use strict';
/* global define, exports, module */
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.returnExports = factory();
}
}(this, function () {
var call = Function.call;
var prototypeOfObject = Object.prototype;
var owns = call.bind(prototypeOfObject.hasOwnProperty);
var isEnumerable = call.bind(prototypeOfObject.propertyIsEnumerable);
var toStr = call.bind(prototypeOfObject.toString);
// If JS engine supports accessors creating shortcuts.
var defineGetter;
var defineSetter;
var lookupGetter;
var lookupSetter;
var supportsAccessors = owns(prototypeOfObject, '__defineGetter__');
if (supportsAccessors) {
/* eslint-disable no-underscore-dangle */
defineGetter = call.bind(prototypeOfObject.__defineGetter__);
defineSetter = call.bind(prototypeOfObject.__defineSetter__);
lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
/* eslint-enable no-underscore-dangle */
}
var isPrimitive = function isPrimitive(o) {
return o == null || (typeof o !== 'object' && typeof o !== 'function');
};
// ES5 15.2.3.2
// http://es5.github.com/#x15.2.3.2
if (!Object.getPrototypeOf) {
// https://github.com/es-shims/es5-shim/issues#issue/2
// http://ejohn.org/blog/objectgetprototypeof/
// recommended by fschaefer on github
//
// sure, and webreflection says ^_^
// ... this will nerever possibly return null
// ... Opera Mini breaks here with infinite loops
Object.getPrototypeOf = function getPrototypeOf(object) {
/* eslint-disable no-proto */
var proto = object.__proto__;
/* eslint-enable no-proto */
if (proto || proto === null) {
return proto;
} else if (toStr(object.constructor) === '[object Function]') {
return object.constructor.prototype;
} else if (object instanceof Object) {
return prototypeOfObject;
} else {
// Correctly return null for Objects created with `Object.create(null)`
// (shammed or native) or `{ __proto__: null}`. Also returns null for
// cross-realm objects on browsers that lack `__proto__` support (like
// IE <11), but that's the best we can do.
return null;
}
};
}
// ES5 15.2.3.3
// http://es5.github.com/#x15.2.3.3
var doesGetOwnPropertyDescriptorWork = function doesGetOwnPropertyDescriptorWork(object) {
try {
object.sentinel = 0;
return Object.getOwnPropertyDescriptor(object, 'sentinel').value === 0;
} catch (exception) {
return false;
}
};
// check whether getOwnPropertyDescriptor works if it's given. Otherwise, shim partially.
if (Object.defineProperty) {
var getOwnPropertyDescriptorWorksOnObject = doesGetOwnPropertyDescriptorWork({});
var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined' ||
doesGetOwnPropertyDescriptorWork(document.createElement('div'));
if (!getOwnPropertyDescriptorWorksOnDom || !getOwnPropertyDescriptorWorksOnObject) {
var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
}
}
if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
var ERR_NON_OBJECT = 'Object.getOwnPropertyDescriptor called on a non-object: ';
/* eslint-disable no-proto */
Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
if (isPrimitive(object)) {
throw new TypeError(ERR_NON_OBJECT + object);
}
// make a valiant attempt to use the real getOwnPropertyDescriptor
// for I8's DOM elements.
if (getOwnPropertyDescriptorFallback) {
try {
return getOwnPropertyDescriptorFallback.call(Object, object, property);
} catch (exception) {
// try the shim if the real one doesn't work
}
}
var descriptor;
// If object does not owns property return undefined immediately.
if (!owns(object, property)) {
return descriptor;
}
// If object has a property then it's for sure `configurable`, and
// probably `enumerable`. Detect enumerability though.
descriptor = {
enumerable: isEnumerable(object, property),
configurable: true
};
// If JS engine supports accessor properties then property may be a
// getter or setter.
if (supportsAccessors) {
// Unfortunately `__lookupGetter__` will return a getter even
// if object has own non getter property along with a same named
// inherited getter. To avoid misbehavior we temporary remove
// `__proto__` so that `__lookupGetter__` will return getter only
// if it's owned by an object.
var prototype = object.__proto__;
var notPrototypeOfObject = object !== prototypeOfObject;
// avoid recursion problem, breaking in Opera Mini when
// Object.getOwnPropertyDescriptor(Object.prototype, 'toString')
// or any other Object.prototype accessor
if (notPrototypeOfObject) {
object.__proto__ = prototypeOfObject;
}
var getter = lookupGetter(object, property);
var setter = lookupSetter(object, property);
if (notPrototypeOfObject) {
// Once we have getter and setter we can put values back.
object.__proto__ = prototype;
}
if (getter || setter) {
if (getter) {
descriptor.get = getter;
}
if (setter) {
descriptor.set = setter;
}
// If it was accessor property we're done and return here
// in order to avoid adding `value` to the descriptor.
return descriptor;
}
}
// If we got this far we know that object has an own property that is
// not an accessor so we set it as a value and return descriptor.
descriptor.value = object[property];
descriptor.writable = true;
return descriptor;
};
/* eslint-enable no-proto */
}
// ES5 15.2.3.4
// http://es5.github.com/#x15.2.3.4
if (!Object.getOwnPropertyNames) {
Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
return Object.keys(object);
};
}
// ES5 15.2.3.5
// http://es5.github.com/#x15.2.3.5
if (!Object.create) {
// Contributed by Brandon Benvie, October, 2012
var createEmpty;
var supportsProto = !({ __proto__: null } instanceof Object);
// the following produces false positives
// in Opera Mini => not a reliable check
// Object.prototype.__proto__ === null
// Check for document.domain and active x support
// No need to use active x approach when document.domain is not set
// see https://github.com/es-shims/es5-shim/issues/150
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
/* global ActiveXObject */
var shouldUseActiveX = function shouldUseActiveX() {
// return early if document.domain not set
if (!document.domain) {
return false;
}
try {
return !!new ActiveXObject('htmlfile');
} catch (exception) {
return false;
}
};
// This supports IE8 when document.domain is used
// see https://github.com/es-shims/es5-shim/issues/150
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
var getEmptyViaActiveX = function getEmptyViaActiveX() {
var empty;
var xDoc;
xDoc = new ActiveXObject('htmlfile');
var script = 'script';
xDoc.write('<' + script + '></' + script + '>');
xDoc.close();
empty = xDoc.parentWindow.Object.prototype;
xDoc = null;
return empty;
};
// The original implementation using an iframe
// before the activex approach was added
// see https://github.com/es-shims/es5-shim/issues/150
var getEmptyViaIFrame = function getEmptyViaIFrame() {
var iframe = document.createElement('iframe');
var parent = document.body || document.documentElement;
var empty;
iframe.style.display = 'none';
parent.appendChild(iframe);
/* eslint-disable no-script-url */
iframe.src = 'javascript:';
/* eslint-enable no-script-url */
empty = iframe.contentWindow.Object.prototype;
parent.removeChild(iframe);
iframe = null;
return empty;
};
/* global document */
if (supportsProto || typeof document === 'undefined') {
createEmpty = function () {
return { __proto__: null };
};
} else {
// In old IE __proto__ can't be used to manually set `null`, nor does
// any other method exist to make an object that inherits from nothing,
// aside from Object.prototype itself. Instead, create a new global
// object and *steal* its Object.prototype and strip it bare. This is
// used as the prototype to create nullary objects.
createEmpty = function () {
// Determine which approach to use
// see https://github.com/es-shims/es5-shim/issues/150
var empty = shouldUseActiveX() ? getEmptyViaActiveX() : getEmptyViaIFrame();
delete empty.constructor;
delete empty.hasOwnProperty;
delete empty.propertyIsEnumerable;
delete empty.isPrototypeOf;
delete empty.toLocaleString;
delete empty.toString;
delete empty.valueOf;
var Empty = function Empty() {};
Empty.prototype = empty;
// short-circuit future calls
createEmpty = function () {
return new Empty();
};
return new Empty();
};
}
Object.create = function create(prototype, properties) {
var object;
var Type = function Type() {}; // An empty constructor.
if (prototype === null) {
object = createEmpty();
} else {
if (prototype !== null && isPrimitive(prototype)) {
// In the native implementation `parent` can be `null`
// OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc)
// Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
// like they are in modern browsers. Using `Object.create` on DOM elements
// is...err...probably inappropriate, but the native version allows for it.
throw new TypeError('Object prototype may only be an Object or null'); // same msg as Chrome
}
Type.prototype = prototype;
object = new Type();
// IE has no built-in implementation of `Object.getPrototypeOf`
// neither `__proto__`, but this manually setting `__proto__` will
// guarantee that `Object.getPrototypeOf` will work as expected with
// objects created using `Object.create`
/* eslint-disable no-proto */
object.__proto__ = prototype;
/* eslint-enable no-proto */
}
if (properties !== void 0) {
Object.defineProperties(object, properties);
}
return object;
};
}
// ES5 15.2.3.6
// http://es5.github.com/#x15.2.3.6
// Patch for WebKit and IE8 standard mode
// Designed by hax <hax.github.com>
// related issue: https://github.com/es-shims/es5-shim/issues#issue/5
// IE8 Reference:
// http://msdn.microsoft.com/en-us/library/dd282900.aspx
// http://msdn.microsoft.com/en-us/library/dd229916.aspx
// WebKit Bugs:
// https://bugs.webkit.org/show_bug.cgi?id=36423
var doesDefinePropertyWork = function doesDefinePropertyWork(object) {
try {
Object.defineProperty(object, 'sentinel', {});
return 'sentinel' in object;
} catch (exception) {
return false;
}
};
// check whether defineProperty works if it's given. Otherwise,
// shim partially.
if (Object.defineProperty) {
var definePropertyWorksOnObject = doesDefinePropertyWork({});
var definePropertyWorksOnDom = typeof document === 'undefined' ||
doesDefinePropertyWork(document.createElement('div'));
if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
var definePropertyFallback = Object.defineProperty,
definePropertiesFallback = Object.defineProperties;
}
}
if (!Object.defineProperty || definePropertyFallback) {
var ERR_NON_OBJECT_DESCRIPTOR = 'Property description must be an object: ';
var ERR_NON_OBJECT_TARGET = 'Object.defineProperty called on non-object: ';
var ERR_ACCESSORS_NOT_SUPPORTED = 'getters & setters can not be defined on this javascript engine';
Object.defineProperty = function defineProperty(object, property, descriptor) {
if (isPrimitive(object)) {
throw new TypeError(ERR_NON_OBJECT_TARGET + object);
}
if (isPrimitive(descriptor)) {
throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
}
// make a valiant attempt to use the real defineProperty
// for I8's DOM elements.
if (definePropertyFallback) {
try {
return definePropertyFallback.call(Object, object, property, descriptor);
} catch (exception) {
// try the shim if the real one doesn't work
}
}
// If it's a data property.
if ('value' in descriptor) {
// fail silently if 'writable', 'enumerable', or 'configurable'
// are requested but not supported
/*
// alternate approach:
if ( // can't implement these features; allow false but not true
('writable' in descriptor && !descriptor.writable) ||
('enumerable' in descriptor && !descriptor.enumerable) ||
('configurable' in descriptor && !descriptor.configurable)
))
throw new RangeError(
'This implementation of Object.defineProperty does not support configurable, enumerable, or writable.'
);
*/
if (supportsAccessors && (lookupGetter(object, property) || lookupSetter(object, property))) {
// As accessors are supported only on engines implementing
// `__proto__` we can safely override `__proto__` while defining
// a property to make sure that we don't hit an inherited
// accessor.
/* eslint-disable no-proto */
var prototype = object.__proto__;
object.__proto__ = prototypeOfObject;
// Deleting a property anyway since getter / setter may be
// defined on object itself.
delete object[property];
object[property] = descriptor.value;
// Setting original `__proto__` back now.
object.__proto__ = prototype;
/* eslint-enable no-proto */
} else {
object[property] = descriptor.value;
}
} else {
var hasGetter = 'get' in descriptor;
var hasSetter = 'set' in descriptor;
if (!supportsAccessors && (hasGetter || hasSetter)) {
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
}
// If we got that far then getters and setters can be defined !!
if (hasGetter) {
defineGetter(object, property, descriptor.get);
}
if (hasSetter) {
defineSetter(object, property, descriptor.set);
}
}
return object;
};
}
// ES5 15.2.3.7
// http://es5.github.com/#x15.2.3.7
if (!Object.defineProperties || definePropertiesFallback) {
Object.defineProperties = function defineProperties(object, properties) {
// make a valiant attempt to use the real defineProperties
if (definePropertiesFallback) {
try {
return definePropertiesFallback.call(Object, object, properties);
} catch (exception) {
// try the shim if the real one doesn't work
}
}
Object.keys(properties).forEach(function (property) {
if (property !== '__proto__') {
Object.defineProperty(object, property, properties[property]);
}
});
return object;
};
}
// ES5 15.2.3.8
// http://es5.github.com/#x15.2.3.8
if (!Object.seal) {
Object.seal = function seal(object) {
if (Object(object) !== object) {
throw new TypeError('Object.seal can only be called on Objects.');
}
// this is misleading and breaks feature-detection, but
// allows "securable" code to "gracefully" degrade to working
// but insecure code.
return object;
};
}
// ES5 15.2.3.9
// http://es5.github.com/#x15.2.3.9
if (!Object.freeze) {
Object.freeze = function freeze(object) {
if (Object(object) !== object) {
throw new TypeError('Object.freeze can only be called on Objects.');
}
// this is misleading and breaks feature-detection, but
// allows "securable" code to "gracefully" degrade to working
// but insecure code.
return object;
};
}
// detect a Rhino bug and patch it
try {
Object.freeze(function () {});
} catch (exception) {
Object.freeze = (function (freezeObject) {
return function freeze(object) {
if (typeof object === 'function') {
return object;
} else {
return freezeObject(object);
}
};
}(Object.freeze));
}
// ES5 15.2.3.10
// http://es5.github.com/#x15.2.3.10
if (!Object.preventExtensions) {
Object.preventExtensions = function preventExtensions(object) {
if (Object(object) !== object) {
throw new TypeError('Object.preventExtensions can only be called on Objects.');
}
// this is misleading and breaks feature-detection, but
// allows "securable" code to "gracefully" degrade to working
// but insecure code.
return object;
};
}
// ES5 15.2.3.11
// http://es5.github.com/#x15.2.3.11
if (!Object.isSealed) {
Object.isSealed = function isSealed(object) {
if (Object(object) !== object) {
throw new TypeError('Object.isSealed can only be called on Objects.');
}
return false;
};
}
// ES5 15.2.3.12
// http://es5.github.com/#x15.2.3.12
if (!Object.isFrozen) {
Object.isFrozen = function isFrozen(object) {
if (Object(object) !== object) {
throw new TypeError('Object.isFrozen can only be called on Objects.');
}
return false;
};
}
// ES5 15.2.3.13
// http://es5.github.com/#x15.2.3.13
if (!Object.isExtensible) {
Object.isExtensible = function isExtensible(object) {
// 1. If Type(O) is not Object throw a TypeError exception.
if (Object(object) !== object) {
throw new TypeError('Object.isExtensible can only be called on Objects.');
}
// 2. Return the Boolean value of the [[Extensible]] internal property of O.
var name = '';
while (owns(object, name)) {
name += '?';
}
object[name] = true;
var returnValue = owns(object, name);
delete object[name];
return returnValue;
};
}
}));
},{}],19:[function(require,module,exports){
/*!
* https://github.com/es-shims/es5-shim
* @license es5-shim Copyright 2009-2015 by contributors, MIT License
* see https://github.com/es-shims/es5-shim/blob/master/LICENSE
*/
// vim: ts=4 sts=4 sw=4 expandtab
// Add semicolon to prevent IIFE from being passed as argument to concatenated code.
;
// UMD (Universal Module Definition)
// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js
(function (root, factory) {
'use strict';
/* global define, exports, module */
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.returnExports = factory();
}
}(this, function () {
/**
* Brings an environment as close to ECMAScript 5 compliance
* as is possible with the facilities of erstwhile engines.
*
* Annotated ES5: http://es5.github.com/ (specific links below)
* ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
* Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
*/
// Shortcut to an often accessed properties, in order to avoid multiple
// dereference that costs universally. This also holds a reference to known-good
// functions.
var $Array = Array;
var ArrayPrototype = $Array.prototype;
var $Object = Object;
var ObjectPrototype = $Object.prototype;
var $Function = Function;
var FunctionPrototype = $Function.prototype;
var $String = String;
var StringPrototype = $String.prototype;
var $Number = Number;
var NumberPrototype = $Number.prototype;
var array_slice = ArrayPrototype.slice;
var array_splice = ArrayPrototype.splice;
var array_push = ArrayPrototype.push;
var array_unshift = ArrayPrototype.unshift;
var array_concat = ArrayPrototype.concat;
var array_join = ArrayPrototype.join;
var call = FunctionPrototype.call;
var apply = FunctionPrototype.apply;
var max = Math.max;
var min = Math.min;
// Having a toString local variable name breaks in Opera so use to_string.
var to_string = ObjectPrototype.toString;
/* global Symbol */
/* eslint-disable one-var-declaration-per-line, no-redeclare, max-statements-per-line */
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, constructorRegex = /^\s*class /, isES6ClassFn = function isES6ClassFn(value) { try { var fnStr = fnToStr.call(value); var singleStripped = fnStr.replace(/\/\/.*\n/g, ''); var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, ''); var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' '); return constructorRegex.test(spaceStripped); } catch (e) { return false; /* not a function */ } }, tryFunctionObject = function tryFunctionObject(value) { try { if (isES6ClassFn(value)) { return false; } fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]', isCallable = function isCallable(value) { if (!value) { return false; } if (typeof value !== 'function' && typeof value !== 'object') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } if (isES6ClassFn(value)) { return false; } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
var isRegex; /* inlined from https://npmjs.com/is-regex */ var regexExec = RegExp.prototype.exec, tryRegexExec = function tryRegexExec(value) { try { regexExec.call(value); return true; } catch (e) { return false; } }, regexClass = '[object RegExp]'; isRegex = function isRegex(value) { if (typeof value !== 'object') { return false; } return hasToStringTag ? tryRegexExec(value) : to_string.call(value) === regexClass; };
var isString; /* inlined from https://npmjs.com/is-string */ var strValue = String.prototype.valueOf, tryStringObject = function tryStringObject(value) { try { strValue.call(value); return true; } catch (e) { return false; } }, stringClass = '[object String]'; isString = function isString(value) { if (typeof value === 'string') { return true; } if (typeof value !== 'object') { return false; } return hasToStringTag ? tryStringObject(value) : to_string.call(value) === stringClass; };
/* eslint-enable one-var-declaration-per-line, no-redeclare, max-statements-per-line */
/* inlined from http://npmjs.com/define-properties */
var supportsDescriptors = $Object.defineProperty && (function () {
try {
var obj = {};
$Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
for (var _ in obj) { // jscs:ignore disallowUnusedVariables
return false;
}
return obj.x === obj;
} catch (e) { /* this is ES3 */
return false;
}
}());
var defineProperties = (function (has) {
// Define configurable, writable, and non-enumerable props
// if they don't exist.
var defineProperty;
if (supportsDescriptors) {
defineProperty = function (object, name, method, forceAssign) {
if (!forceAssign && (name in object)) {
return;
}
$Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
};
} else {
defineProperty = function (object, name, method, forceAssign) {
if (!forceAssign && (name in object)) {
return;
}
object[name] = method;
};
}
return function defineProperties(object, map, forceAssign) {
for (var name in map) {
if (has.call(map, name)) {
defineProperty(object, name, map[name], forceAssign);
}
}
};
}(ObjectPrototype.hasOwnProperty));
//
// Util
// ======
//
/* replaceable with https://npmjs.com/package/es-abstract /helpers/isPrimitive */
var isPrimitive = function isPrimitive(input) {
var type = typeof input;
return input === null || (type !== 'object' && type !== 'function');
};
var isActualNaN = $Number.isNaN || function isActualNaN(x) {
return x !== x;
};
var ES = {
// ES5 9.4
// http://es5.github.com/#x9.4
// http://jsperf.com/to-integer
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToInteger */
ToInteger: function ToInteger(num) {
var n = +num;
if (isActualNaN(n)) {
n = 0;
} else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}
return n;
},
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToPrimitive */
ToPrimitive: function ToPrimitive(input) {
var val, valueOf, toStr;
if (isPrimitive(input)) {
return input;
}
valueOf = input.valueOf;
if (isCallable(valueOf)) {
val = valueOf.call(input);
if (isPrimitive(val)) {
return val;
}
}
toStr = input.toString;
if (isCallable(toStr)) {
val = toStr.call(input);
if (isPrimitive(val)) {
return val;
}
}
throw new TypeError();
},
// ES5 9.9
// http://es5.github.com/#x9.9
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToObject */
ToObject: function (o) {
if (o == null) { // this matches both null and undefined
throw new TypeError("can't convert " + o + ' to object');
}
return $Object(o);
},
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToUint32 */
ToUint32: function ToUint32(x) {
return x >>> 0;
}
};
//
// Function
// ========
//
// ES-5 15.3.4.5
// http://es5.github.com/#x15.3.4.5
var Empty = function Empty() {};
defineProperties(FunctionPrototype, {
bind: function bind(that) { // .length is 1
// 1. Let Target be the this value.
var target = this;
// 2. If IsCallable(Target) is false, throw a TypeError exception.
if (!isCallable(target)) {
throw new TypeError('Function.prototype.bind called on incompatible ' + target);
}
// 3. Let A be a new (possibly empty) internal list of all of the
// argument values provided after thisArg (arg1, arg2 etc), in order.
// XXX slicedArgs will stand in for "A" if used
var args = array_slice.call(arguments, 1); // for normal call
// 4. Let F be a new native ECMAScript object.
// 11. Set the [[Prototype]] internal property of F to the standard
// built-in Function prototype object as specified in 15.3.3.1.
// 12. Set the [[Call]] internal property of F as described in
// 15.3.4.5.1.
// 13. Set the [[Construct]] internal property of F as described in
// 15.3.4.5.2.
// 14. Set the [[HasInstance]] internal property of F as described in
// 15.3.4.5.3.
var bound;
var binder = function () {
if (this instanceof bound) {
// 15.3.4.5.2 [[Construct]]
// When the [[Construct]] internal method of a function object,
// F that was created using the bind function is called with a
// list of arguments ExtraArgs, the following steps are taken:
// 1. Let target be the value of F's [[TargetFunction]]
// internal property.
// 2. If target has no [[Construct]] internal method, a
// TypeError exception is thrown.
// 3. Let boundArgs be the value of F's [[BoundArgs]] internal
// property.
// 4. Let args be a new list containing the same values as the
// list boundArgs in the same order followed by the same
// values as the list ExtraArgs in the same order.
// 5. Return the result of calling the [[Construct]] internal
// method of target providing args as the arguments.
var result = apply.call(
target,
this,
array_concat.call(args, array_slice.call(arguments))
);
if ($Object(result) === result) {
return result;
}
return this;
} else {
// 15.3.4.5.1 [[Call]]
// When the [[Call]] internal method of a function object, F,
// which was created using the bind function is called with a
// this value and a list of arguments ExtraArgs, the following
// steps are taken:
// 1. Let boundArgs be the value of F's [[BoundArgs]] internal
// property.
// 2. Let boundThis be the value of F's [[BoundThis]] internal
// property.
// 3. Let target be the value of F's [[TargetFunction]] internal
// property.
// 4. Let args be a new list containing the same values as the
// list boundArgs in the same order followed by the same
// values as the list ExtraArgs in the same order.
// 5. Return the result of calling the [[Call]] internal method
// of target providing boundThis as the this value and
// providing args as the arguments.
// equiv: target.call(this, ...boundArgs, ...args)
return apply.call(
target,
that,
array_concat.call(args, array_slice.call(arguments))
);
}
};
// 15. If the [[Class]] internal property of Target is "Function", then
// a. Let L be the length property of Target minus the length of A.
// b. Set the length own property of F to either 0 or L, whichever is
// larger.
// 16. Else set the length own property of F to 0.
var boundLength = max(0, target.length - args.length);
// 17. Set the attributes of the length own property of F to the values
// specified in 15.3.5.1.
var boundArgs = [];
for (var i = 0; i < boundLength; i++) {
array_push.call(boundArgs, '$' + i);
}
// XXX Build a dynamic function with desired amount of arguments is the only
// way to set the length property of a function.
// In environments where Content Security Policies enabled (Chrome extensions,
// for ex.) all use of eval or Function costructor throws an exception.
// However in all of these environments Function.prototype.bind exists
// and so this code will never be executed.
bound = $Function('binder', 'return function (' + array_join.call(boundArgs, ',') + '){ return binder.apply(this, arguments); }')(binder);
if (target.prototype) {
Empty.prototype = target.prototype;
bound.prototype = new Empty();
// Clean up dangling references.
Empty.prototype = null;
}
// TODO
// 18. Set the [[Extensible]] internal property of F to true.
// TODO
// 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
// 20. Call the [[DefineOwnProperty]] internal method of F with
// arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
// thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
// false.
// 21. Call the [[DefineOwnProperty]] internal method of F with
// arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
// [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
// and false.
// TODO
// NOTE Function objects created using Function.prototype.bind do not
// have a prototype property or the [[Code]], [[FormalParameters]], and
// [[Scope]] internal properties.
// XXX can't delete prototype in pure-js.
// 22. Return F.
return bound;
}
});
// _Please note: Shortcuts are defined after `Function.prototype.bind` as we
// use it in defining shortcuts.
var owns = call.bind(ObjectPrototype.hasOwnProperty);
var toStr = call.bind(ObjectPrototype.toString);
var arraySlice = call.bind(array_slice);
var arraySliceApply = apply.bind(array_slice);
var strSlice = call.bind(StringPrototype.slice);
var strSplit = call.bind(StringPrototype.split);
var strIndexOf = call.bind(StringPrototype.indexOf);
var pushCall = call.bind(array_push);
var isEnum = call.bind(ObjectPrototype.propertyIsEnumerable);
var arraySort = call.bind(ArrayPrototype.sort);
//
// Array
// =====
//
var isArray = $Array.isArray || function isArray(obj) {
return toStr(obj) === '[object Array]';
};
// ES5 15.4.4.12
// http://es5.github.com/#x15.4.4.13
// Return len+argCount.
// [bugfix, ielt8]
// IE < 8 bug: [].unshift(0) === undefined but should be "1"
var hasUnshiftReturnValueBug = [].unshift(0) !== 1;
defineProperties(ArrayPrototype, {
unshift: function () {
array_unshift.apply(this, arguments);
return this.length;
}
}, hasUnshiftReturnValueBug);
// ES5 15.4.3.2
// http://es5.github.com/#x15.4.3.2
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
defineProperties($Array, { isArray: isArray });
// The IsCallable() check in the Array functions
// has been replaced with a strict check on the
// internal class of the object to trap cases where
// the provided function was actually a regular
// expression literal, which in V8 and
// JavaScriptCore is a typeof "function". Only in
// V8 are regular expression literals permitted as
// reduce parameters, so it is desirable in the
// general case for the shim to match the more
// strict and common behavior of rejecting regular
// expressions.
// ES5 15.4.4.18
// http://es5.github.com/#x15.4.4.18
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
// Check failure of by-index access of string characters (IE < 9)
// and failure of `0 in boxedString` (Rhino)
var boxedString = $Object('a');
var splitString = boxedString[0] !== 'a' || !(0 in boxedString);
var properlyBoxesContext = function properlyBoxed(method) {
// Check node 0.6.21 bug where third parameter is not boxed
var properlyBoxesNonStrict = true;
var properlyBoxesStrict = true;
var threwException = false;
if (method) {
try {
method.call('foo', function (_, __, context) {
if (typeof context !== 'object') {
properlyBoxesNonStrict = false;
}
});
method.call([1], function () {
'use strict';
properlyBoxesStrict = typeof this === 'string';
}, 'x');
} catch (e) {
threwException = true;
}
}
return !!method && !threwException && properlyBoxesNonStrict && properlyBoxesStrict;
};
defineProperties(ArrayPrototype, {
forEach: function forEach(callbackfn/*, thisArg*/) {
var object = ES.ToObject(this);
var self = splitString && isString(this) ? strSplit(this, '') : object;
var i = -1;
var length = ES.ToUint32(self.length);
var T;
if (arguments.length > 1) {
T = arguments[1];
}
// If no callback function or if callback is not a callable function
if (!isCallable(callbackfn)) {
throw new TypeError('Array.prototype.forEach callback must be a function');
}
while (++i < length) {
if (i in self) {
// Invoke the callback function with call, passing arguments:
// context, property value, property key, thisArg object
if (typeof T === 'undefined') {
callbackfn(self[i], i, object);
} else {
callbackfn.call(T, self[i], i, object);
}
}
}
}
}, !properlyBoxesContext(ArrayPrototype.forEach));
// ES5 15.4.4.19
// http://es5.github.com/#x15.4.4.19
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
defineProperties(ArrayPrototype, {
map: function map(callbackfn/*, thisArg*/) {
var object = ES.ToObject(this);
var self = splitString && isString(this) ? strSplit(this, '') : object;
var length = ES.ToUint32(self.length);
var result = $Array(length);
var T;
if (arguments.length > 1) {
T = arguments[1];
}
// If no callback function or if callback is not a callable function
if (!isCallable(callbackfn)) {
throw new TypeError('Array.prototype.map callback must be a function');
}
for (var i = 0; i < length; i++) {
if (i in self) {
if (typeof T === 'undefined') {
result[i] = callbackfn(self[i], i, object);
} else {
result[i] = callbackfn.call(T, self[i], i, object);
}
}
}
return result;
}
}, !properlyBoxesContext(ArrayPrototype.map));
// ES5 15.4.4.20
// http://es5.github.com/#x15.4.4.20
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
defineProperties(ArrayPrototype, {
filter: function filter(callbackfn/*, thisArg*/) {
var object = ES.ToObject(this);
var self = splitString && isString(this) ? strSplit(this, '') : object;
var length = ES.ToUint32(self.length);
var result = [];
var value;
var T;
if (arguments.length > 1) {
T = arguments[1];
}
// If no callback function or if callback is not a callable function
if (!isCallable(callbackfn)) {
throw new TypeError('Array.prototype.filter callback must be a function');
}
for (var i = 0; i < length; i++) {
if (i in self) {
value = self[i];
if (typeof T === 'undefined' ? callbackfn(value, i, object) : callbackfn.call(T, value, i, object)) {
pushCall(result, value);
}
}
}
return result;
}
}, !properlyBoxesContext(ArrayPrototype.filter));
// ES5 15.4.4.16
// http://es5.github.com/#x15.4.4.16
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
defineProperties(ArrayPrototype, {
every: function every(callbackfn/*, thisArg*/) {
var object = ES.ToObject(this);
var self = splitString && isString(this) ? strSplit(this, '') : object;
var length = ES.ToUint32(self.length);
var T;
if (arguments.length > 1) {
T = arguments[1];
}
// If no callback function or if callback is not a callable function
if (!isCallable(callbackfn)) {
throw new TypeError('Array.prototype.every callback must be a function');
}
for (var i = 0; i < length; i++) {
if (i in self && !(typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) {
return false;
}
}
return true;
}
}, !properlyBoxesContext(ArrayPrototype.every));
// ES5 15.4.4.17
// http://es5.github.com/#x15.4.4.17
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
defineProperties(ArrayPrototype, {
some: function some(callbackfn/*, thisArg */) {
var object = ES.ToObject(this);
var self = splitString && isString(this) ? strSplit(this, '') : object;
var length = ES.ToUint32(self.length);
var T;
if (arguments.length > 1) {
T = arguments[1];
}
// If no callback function or if callback is not a callable function
if (!isCallable(callbackfn)) {
throw new TypeError('Array.prototype.some callback must be a function');
}
for (var i = 0; i < length; i++) {
if (i in self && (typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) {
return true;
}
}
return false;
}
}, !properlyBoxesContext(ArrayPrototype.some));
// ES5 15.4.4.21
// http://es5.github.com/#x15.4.4.21
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
var reduceCoercesToObject = false;
if (ArrayPrototype.reduce) {
reduceCoercesToObject = typeof ArrayPrototype.reduce.call('es5', function (_, __, ___, list) {
return list;
}) === 'object';
}
defineProperties(ArrayPrototype, {
reduce: function reduce(callbackfn/*, initialValue*/) {
var object = ES.ToObject(this);
var self = splitString && isString(this) ? strSplit(this, '') : object;
var length = ES.ToUint32(self.length);
// If no callback function or if callback is not a callable function
if (!isCallable(callbackfn)) {
throw new TypeError('Array.prototype.reduce callback must be a function');
}
// no value to return if no initial value and an empty array
if (length === 0 && arguments.length === 1) {
throw new TypeError('reduce of empty array with no initial value');
}
var i = 0;
var result;
if (arguments.length >= 2) {
result = arguments[1];
} else {
do {
if (i in self) {
result = self[i++];
break;
}
// if array contains no values, no initial value to return
if (++i >= length) {
throw new TypeError('reduce of empty array with no initial value');
}
} while (true);
}
for (; i < length; i++) {
if (i in self) {
result = callbackfn(result, self[i], i, object);
}
}
return result;
}
}, !reduceCoercesToObject);
// ES5 15.4.4.22
// http://es5.github.com/#x15.4.4.22
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
var reduceRightCoercesToObject = false;
if (ArrayPrototype.reduceRight) {
reduceRightCoercesToObject = typeof ArrayPrototype.reduceRight.call('es5', function (_, __, ___, list) {
return list;
}) === 'object';
}
defineProperties(ArrayPrototype, {
reduceRight: function reduceRight(callbackfn/*, initial*/) {
var object = ES.ToObject(this);
var self = splitString && isString(this) ? strSplit(this, '') : object;
var length = ES.ToUint32(self.length);
// If no callback function or if callback is not a callable function
if (!isCallable(callbackfn)) {
throw new TypeError('Array.prototype.reduceRight callback must be a function');
}
// no value to return if no initial value, empty array
if (length === 0 && arguments.length === 1) {
throw new TypeError('reduceRight of empty array with no initial value');
}
var result;
var i = length - 1;
if (arguments.length >= 2) {
result = arguments[1];
} else {
do {
if (i in self) {
result = self[i--];
break;
}
// if array contains no values, no initial value to return
if (--i < 0) {
throw new TypeError('reduceRight of empty array with no initial value');
}
} while (true);
}
if (i < 0) {
return result;
}
do {
if (i in self) {
result = callbackfn(result, self[i], i, object);
}
} while (i--);
return result;
}
}, !reduceRightCoercesToObject);
// ES5 15.4.4.14
// http://es5.github.com/#x15.4.4.14
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
var hasFirefox2IndexOfBug = ArrayPrototype.indexOf && [0, 1].indexOf(1, 2) !== -1;
defineProperties(ArrayPrototype, {
indexOf: function indexOf(searchElement/*, fromIndex */) {
var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this);
var length = ES.ToUint32(self.length);
if (length === 0) {
return -1;
}
var i = 0;
if (arguments.length > 1) {
i = ES.ToInteger(arguments[1]);
}
// handle negative indices
i = i >= 0 ? i : max(0, length + i);
for (; i < length; i++) {
if (i in self && self[i] === searchElement) {
return i;
}
}
return -1;
}
}, hasFirefox2IndexOfBug);
// ES5 15.4.4.15
// http://es5.github.com/#x15.4.4.15
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
var hasFirefox2LastIndexOfBug = ArrayPrototype.lastIndexOf && [0, 1].lastIndexOf(0, -3) !== -1;
defineProperties(ArrayPrototype, {
lastIndexOf: function lastIndexOf(searchElement/*, fromIndex */) {
var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this);
var length = ES.ToUint32(self.length);
if (length === 0) {
return -1;
}
var i = length - 1;
if (arguments.length > 1) {
i = min(i, ES.ToInteger(arguments[1]));
}
// handle negative indices
i = i >= 0 ? i : length - Math.abs(i);
for (; i >= 0; i--) {
if (i in self && searchElement === self[i]) {
return i;
}
}
return -1;
}
}, hasFirefox2LastIndexOfBug);
// ES5 15.4.4.12
// http://es5.github.com/#x15.4.4.12
var spliceNoopReturnsEmptyArray = (function () {
var a = [1, 2];
var result = a.splice();
return a.length === 2 && isArray(result) && result.length === 0;
}());
defineProperties(ArrayPrototype, {
// Safari 5.0 bug where .splice() returns undefined
splice: function splice(start, deleteCount) {
if (arguments.length === 0) {
return [];
} else {
return array_splice.apply(this, arguments);
}
}
}, !spliceNoopReturnsEmptyArray);
var spliceWorksWithEmptyObject = (function () {
var obj = {};
ArrayPrototype.splice.call(obj, 0, 0, 1);
return obj.length === 1;
}());
defineProperties(ArrayPrototype, {
splice: function splice(start, deleteCount) {
if (arguments.length === 0) {
return [];
}
var args = arguments;
this.length = max(ES.ToInteger(this.length), 0);
if (arguments.length > 0 && typeof deleteCount !== 'number') {
args = arraySlice(arguments);
if (args.length < 2) {
pushCall(args, this.length - start);
} else {
args[1] = ES.ToInteger(deleteCount);
}
}
return array_splice.apply(this, args);
}
}, !spliceWorksWithEmptyObject);
var spliceWorksWithLargeSparseArrays = (function () {
// Per https://github.com/es-shims/es5-shim/issues/295
// Safari 7/8 breaks with sparse arrays of size 1e5 or greater
var arr = new $Array(1e5);
// note: the index MUST be 8 or larger or the test will false pass
arr[8] = 'x';
arr.splice(1, 1);
// note: this test must be defined *after* the indexOf shim
// per https://github.com/es-shims/es5-shim/issues/313
return arr.indexOf('x') === 7;
}());
var spliceWorksWithSmallSparseArrays = (function () {
// Per https://github.com/es-shims/es5-shim/issues/295
// Opera 12.15 breaks on this, no idea why.
var n = 256;
var arr = [];
arr[n] = 'a';
arr.splice(n + 1, 0, 'b');
return arr[n] === 'a';
}());
defineProperties(ArrayPrototype, {
splice: function splice(start, deleteCount) {
var O = ES.ToObject(this);
var A = [];
var len = ES.ToUint32(O.length);
var relativeStart = ES.ToInteger(start);
var actualStart = relativeStart < 0 ? max((len + relativeStart), 0) : min(relativeStart, len);
var actualDeleteCount = min(max(ES.ToInteger(deleteCount), 0), len - actualStart);
var k = 0;
var from;
while (k < actualDeleteCount) {
from = $String(actualStart + k);
if (owns(O, from)) {
A[k] = O[from];
}
k += 1;
}
var items = arraySlice(arguments, 2);
var itemCount = items.length;
var to;
if (itemCount < actualDeleteCount) {
k = actualStart;
var maxK = len - actualDeleteCount;
while (k < maxK) {
from = $String(k + actualDeleteCount);
to = $String(k + itemCount);
if (owns(O, from)) {
O[to] = O[from];
} else {
delete O[to];
}
k += 1;
}
k = len;
var minK = len - actualDeleteCount + itemCount;
while (k > minK) {
delete O[k - 1];
k -= 1;
}
} else if (itemCount > actualDeleteCount) {
k = len - actualDeleteCount;
while (k > actualStart) {
from = $String(k + actualDeleteCount - 1);
to = $String(k + itemCount - 1);
if (owns(O, from)) {
O[to] = O[from];
} else {
delete O[to];
}
k -= 1;
}
}
k = actualStart;
for (var i = 0; i < items.length; ++i) {
O[k] = items[i];
k += 1;
}
O.length = len - actualDeleteCount + itemCount;
return A;
}
}, !spliceWorksWithLargeSparseArrays || !spliceWorksWithSmallSparseArrays);
var originalJoin = ArrayPrototype.join;
var hasStringJoinBug;
try {
hasStringJoinBug = Array.prototype.join.call('123', ',') !== '1,2,3';
} catch (e) {
hasStringJoinBug = true;
}
if (hasStringJoinBug) {
defineProperties(ArrayPrototype, {
join: function join(separator) {
var sep = typeof separator === 'undefined' ? ',' : separator;
return originalJoin.call(isString(this) ? strSplit(this, '') : this, sep);
}
}, hasStringJoinBug);
}
var hasJoinUndefinedBug = [1, 2].join(undefined) !== '1,2';
if (hasJoinUndefinedBug) {
defineProperties(ArrayPrototype, {
join: function join(separator) {
var sep = typeof separator === 'undefined' ? ',' : separator;
return originalJoin.call(this, sep);
}
}, hasJoinUndefinedBug);
}
var pushShim = function push(item) {
var O = ES.ToObject(this);
var n = ES.ToUint32(O.length);
var i = 0;
while (i < arguments.length) {
O[n + i] = arguments[i];
i += 1;
}
O.length = n + i;
return n + i;
};
var pushIsNotGeneric = (function () {
var obj = {};
var result = Array.prototype.push.call(obj, undefined);
return result !== 1 || obj.length !== 1 || typeof obj[0] !== 'undefined' || !owns(obj, 0);
}());
defineProperties(ArrayPrototype, {
push: function push(item) {
if (isArray(this)) {
return array_push.apply(this, arguments);
}
return pushShim.apply(this, arguments);
}
}, pushIsNotGeneric);
// This fixes a very weird bug in Opera 10.6 when pushing `undefined
var pushUndefinedIsWeird = (function () {
var arr = [];
var result = arr.push(undefined);
return result !== 1 || arr.length !== 1 || typeof arr[0] !== 'undefined' || !owns(arr, 0);
}());
defineProperties(ArrayPrototype, { push: pushShim }, pushUndefinedIsWeird);
// ES5 15.2.3.14
// http://es5.github.io/#x15.4.4.10
// Fix boxed string bug
defineProperties(ArrayPrototype, {
slice: function (start, end) {
var arr = isString(this) ? strSplit(this, '') : this;
return arraySliceApply(arr, arguments);
}
}, splitString);
var sortIgnoresNonFunctions = (function () {
try {
[1, 2].sort(null);
[1, 2].sort({});
return true;
} catch (e) {}
return false;
}());
var sortThrowsOnRegex = (function () {
// this is a problem in Firefox 4, in which `typeof /a/ === 'function'`
try {
[1, 2].sort(/a/);
return false;
} catch (e) {}
return true;
}());
var sortIgnoresUndefined = (function () {
// applies in IE 8, for one.
try {
[1, 2].sort(undefined);
return true;
} catch (e) {}
return false;
}());
defineProperties(ArrayPrototype, {
sort: function sort(compareFn) {
if (typeof compareFn === 'undefined') {
return arraySort(this);
}
if (!isCallable(compareFn)) {
throw new TypeError('Array.prototype.sort callback must be a function');
}
return arraySort(this, compareFn);
}
}, sortIgnoresNonFunctions || !sortIgnoresUndefined || !sortThrowsOnRegex);
//
// Object
// ======
//
// ES5 15.2.3.14
// http://es5.github.com/#x15.2.3.14
// http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
var hasDontEnumBug = !isEnum({ 'toString': null }, 'toString');
var hasProtoEnumBug = isEnum(function () {}, 'prototype');
var hasStringEnumBug = !owns('x', '0');
var equalsConstructorPrototype = function (o) {
var ctor = o.constructor;
return ctor && ctor.prototype === o;
};
var blacklistedKeys = {
$window: true,
$console: true,
$parent: true,
$self: true,
$frame: true,
$frames: true,
$frameElement: true,
$webkitIndexedDB: true,
$webkitStorageInfo: true,
$external: true
};
var hasAutomationEqualityBug = (function () {
/* globals window */
if (typeof window === 'undefined') {
return false;
}
for (var k in window) {
try {
if (!blacklistedKeys['$' + k] && owns(window, k) && window[k] !== null && typeof window[k] === 'object') {
equalsConstructorPrototype(window[k]);
}
} catch (e) {
return true;
}
}
return false;
}());
var equalsConstructorPrototypeIfNotBuggy = function (object) {
if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
return equalsConstructorPrototype(object);
}
try {
return equalsConstructorPrototype(object);
} catch (e) {
return false;
}
};
var dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
];
var dontEnumsLength = dontEnums.length;
// taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js
// can be replaced with require('is-arguments') if we ever use a build process instead
var isStandardArguments = function isArguments(value) {
return toStr(value) === '[object Arguments]';
};
var isLegacyArguments = function isArguments(value) {
return value !== null &&
typeof value === 'object' &&
typeof value.length === 'number' &&
value.length >= 0 &&
!isArray(value) &&
isCallable(value.callee);
};
var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments;
defineProperties($Object, {
keys: function keys(object) {
var isFn = isCallable(object);
var isArgs = isArguments(object);
var isObject = object !== null && typeof object === 'object';
var isStr = isObject && isString(object);
if (!isObject && !isFn && !isArgs) {
throw new TypeError('Object.keys called on a non-object');
}
var theKeys = [];
var skipProto = hasProtoEnumBug && isFn;
if ((isStr && hasStringEnumBug) || isArgs) {
for (var i = 0; i < object.length; ++i) {
pushCall(theKeys, $String(i));
}
}
if (!isArgs) {
for (var name in object) {
if (!(skipProto && name === 'prototype') && owns(object, name)) {
pushCall(theKeys, $String(name));
}
}
}
if (hasDontEnumBug) {
var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
for (var j = 0; j < dontEnumsLength; j++) {
var dontEnum = dontEnums[j];
if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) {
pushCall(theKeys, dontEnum);
}
}
}
return theKeys;
}
});
var keysWorksWithArguments = $Object.keys && (function () {
// Safari 5.0 bug
return $Object.keys(arguments).length === 2;
}(1, 2));
var keysHasArgumentsLengthBug = $Object.keys && (function () {
var argKeys = $Object.keys(arguments);
return arguments.length !== 1 || argKeys.length !== 1 || argKeys[0] !== 1;
}(1));
var originalKeys = $Object.keys;
defineProperties($Object, {
keys: function keys(object) {
if (isArguments(object)) {
return originalKeys(arraySlice(object));
} else {
return originalKeys(object);
}
}
}, !keysWorksWithArguments || keysHasArgumentsLengthBug);
//
// Date
// ====
//
var hasNegativeMonthYearBug = new Date(-3509827329600292).getUTCMonth() !== 0;
var aNegativeTestDate = new Date(-1509842289600292);
var aPositiveTestDate = new Date(1449662400000);
var hasToUTCStringFormatBug = aNegativeTestDate.toUTCString() !== 'Mon, 01 Jan -45875 11:59:59 GMT';
var hasToDateStringFormatBug;
var hasToStringFormatBug;
var timeZoneOffset = aNegativeTestDate.getTimezoneOffset();
if (timeZoneOffset < -720) {
hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Tue Jan 02 -45875';
hasToStringFormatBug = !(/^Thu Dec 10 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/).test(aPositiveTestDate.toString());
} else {
hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Mon Jan 01 -45875';
hasToStringFormatBug = !(/^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/).test(aPositiveTestDate.toString());
}
var originalGetFullYear = call.bind(Date.prototype.getFullYear);
var originalGetMonth = call.bind(Date.prototype.getMonth);
var originalGetDate = call.bind(Date.prototype.getDate);
var originalGetUTCFullYear = call.bind(Date.prototype.getUTCFullYear);
var originalGetUTCMonth = call.bind(Date.prototype.getUTCMonth);
var originalGetUTCDate = call.bind(Date.prototype.getUTCDate);
var originalGetUTCDay = call.bind(Date.prototype.getUTCDay);
var originalGetUTCHours = call.bind(Date.prototype.getUTCHours);
var originalGetUTCMinutes = call.bind(Date.prototype.getUTCMinutes);
var originalGetUTCSeconds = call.bind(Date.prototype.getUTCSeconds);
var originalGetUTCMilliseconds = call.bind(Date.prototype.getUTCMilliseconds);
var dayName = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var monthName = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var daysInMonth = function daysInMonth(month, year) {
return originalGetDate(new Date(year, month, 0));
};
defineProperties(Date.prototype, {
getFullYear: function getFullYear() {
if (!this || !(this instanceof Date)) {
throw new TypeError('this is not a Date object.');
}
var year = originalGetFullYear(this);
if (year < 0 && originalGetMonth(this) > 11) {
return year + 1;
}
return year;
},
getMonth: function getMonth() {
if (!this || !(this instanceof Date)) {
throw new TypeError('this is not a Date object.');
}
var year = originalGetFullYear(this);
var month = originalGetMonth(this);
if (year < 0 && month > 11) {
return 0;
}
return month;
},
getDate: function getDate() {
if (!this || !(this instanceof Date)) {
throw new TypeError('this is not a Date object.');
}
var year = originalGetFullYear(this);
var month = originalGetMonth(this);
var date = originalGetDate(this);
if (year < 0 && month > 11) {
if (month === 12) {
return date;
}
var days = daysInMonth(0, year + 1);
return (days - date) + 1;
}
return date;
},
getUTCFullYear: function getUTCFullYear() {
if (!this || !(this instanceof Date)) {
throw new TypeError('this is not a Date object.');
}
var year = originalGetUTCFullYear(this);
if (year < 0 && originalGetUTCMonth(this) > 11) {
return year + 1;
}
return year;
},
getUTCMonth: function getUTCMonth() {
if (!this || !(this instanceof Date)) {
throw new TypeError('this is not a Date object.');
}
var year = originalGetUTCFullYear(this);
var month = originalGetUTCMonth(this);
if (year < 0 && month > 11) {
return 0;
}
return month;
},
getUTCDate: function getUTCDate() {
if (!this || !(this instanceof Date)) {
throw new TypeError('this is not a Date object.');
}
var year = originalGetUTCFullYear(this);
var month = originalGetUTCMonth(this);
var date = originalGetUTCDate(this);
if (year < 0 && month > 11) {
if (month === 12) {
return date;
}
var days = daysInMonth(0, year + 1);
return (days - date) + 1;
}
return date;
}
}, hasNegativeMonthYearBug);
defineProperties(Date.prototype, {
toUTCString: function toUTCString() {
if (!this || !(this instanceof Date)) {
throw new TypeError('this is not a Date object.');
}
var day = originalGetUTCDay(this);
var date = originalGetUTCDate(this);
var month = originalGetUTCMonth(this);
var year = originalGetUTCFullYear(this);
var hour = originalGetUTCHours(this);
var minute = originalGetUTCMinutes(this);
var second = originalGetUTCSeconds(this);
return dayName[day] + ', ' +
(date < 10 ? '0' + date : date) + ' ' +
monthName[month] + ' ' +
year + ' ' +
(hour < 10 ? '0' + hour : hour) + ':' +
(minute < 10 ? '0' + minute : minute) + ':' +
(second < 10 ? '0' + second : second) + ' GMT';
}
}, hasNegativeMonthYearBug || hasToUTCStringFormatBug);
// Opera 12 has `,`
defineProperties(Date.prototype, {
toDateString: function toDateString() {
if (!this || !(this instanceof Date)) {
throw new TypeError('this is not a Date object.');
}
var day = this.getDay();
var date = this.getDate();
var month = this.getMonth();
var year = this.getFullYear();
return dayName[day] + ' ' +
monthName[month] + ' ' +
(date < 10 ? '0' + date : date) + ' ' +
year;
}
}, hasNegativeMonthYearBug || hasToDateStringFormatBug);
// can't use defineProperties here because of toString enumeration issue in IE <= 8
if (hasNegativeMonthYearBug || hasToStringFormatBug) {
Date.prototype.toString = function toString() {
if (!this || !(this instanceof Date)) {
throw new TypeError('this is not a Date object.');
}
var day = this.getDay();
var date = this.getDate();
var month = this.getMonth();
var year = this.getFullYear();
var hour = this.getHours();
var minute = this.getMinutes();
var second = this.getSeconds();
var timezoneOffset = this.getTimezoneOffset();
var hoursOffset = Math.floor(Math.abs(timezoneOffset) / 60);
var minutesOffset = Math.floor(Math.abs(timezoneOffset) % 60);
return dayName[day] + ' ' +
monthName[month] + ' ' +
(date < 10 ? '0' + date : date) + ' ' +
year + ' ' +
(hour < 10 ? '0' + hour : hour) + ':' +
(minute < 10 ? '0' + minute : minute) + ':' +
(second < 10 ? '0' + second : second) + ' GMT' +
(timezoneOffset > 0 ? '-' : '+') +
(hoursOffset < 10 ? '0' + hoursOffset : hoursOffset) +
(minutesOffset < 10 ? '0' + minutesOffset : minutesOffset);
};
if (supportsDescriptors) {
$Object.defineProperty(Date.prototype, 'toString', {
configurable: true,
enumerable: false,
writable: true
});
}
}
// ES5 15.9.5.43
// http://es5.github.com/#x15.9.5.43
// This function returns a String value represent the instance in time
// represented by this Date object. The format of the String is the Date Time
// string format defined in 15.9.1.15. All fields are present in the String.
// The time zone is always UTC, denoted by the suffix Z. If the time value of
// this object is not a finite Number a RangeError exception is thrown.
var negativeDate = -62198755200000;
var negativeYearString = '-000001';
var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1;
var hasSafari51DateBug = Date.prototype.toISOString && new Date(-1).toISOString() !== '1969-12-31T23:59:59.999Z';
var getTime = call.bind(Date.prototype.getTime);
defineProperties(Date.prototype, {
toISOString: function toISOString() {
if (!isFinite(this) || !isFinite(getTime(this))) {
// Adope Photoshop requires the second check.
throw new RangeError('Date.prototype.toISOString called on non-finite value.');
}
var year = originalGetUTCFullYear(this);
var month = originalGetUTCMonth(this);
// see https://github.com/es-shims/es5-shim/issues/111
year += Math.floor(month / 12);
month = (month % 12 + 12) % 12;
// the date time string format is specified in 15.9.1.15.
var result = [month + 1, originalGetUTCDate(this), originalGetUTCHours(this), originalGetUTCMinutes(this), originalGetUTCSeconds(this)];
year = (
(year < 0 ? '-' : (year > 9999 ? '+' : '')) +
strSlice('00000' + Math.abs(year), (0 <= year && year <= 9999) ? -4 : -6)
);
for (var i = 0; i < result.length; ++i) {
// pad months, days, hours, minutes, and seconds to have two digits.
result[i] = strSlice('00' + result[i], -2);
}
// pad milliseconds to have three digits.
return (
year + '-' + arraySlice(result, 0, 2).join('-') +
'T' + arraySlice(result, 2).join(':') + '.' +
strSlice('000' + originalGetUTCMilliseconds(this), -3) + 'Z'
);
}
}, hasNegativeDateBug || hasSafari51DateBug);
// ES5 15.9.5.44
// http://es5.github.com/#x15.9.5.44
// This function provides a String representation of a Date object for use by
// JSON.stringify (15.12.3).
var dateToJSONIsSupported = (function () {
try {
return Date.prototype.toJSON &&
new Date(NaN).toJSON() === null &&
new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
Date.prototype.toJSON.call({ // generic
toISOString: function () { return true; }
});
} catch (e) {
return false;
}
}());
if (!dateToJSONIsSupported) {
Date.prototype.toJSON = function toJSON(key) {
// When the toJSON method is called with argument key, the following
// steps are taken:
// 1. Let O be the result of calling ToObject, giving it the this
// value as its argument.
// 2. Let tv be ES.ToPrimitive(O, hint Number).
var O = $Object(this);
var tv = ES.ToPrimitive(O);
// 3. If tv is a Number and is not finite, return null.
if (typeof tv === 'number' && !isFinite(tv)) {
return null;
}
// 4. Let toISO be the result of calling the [[Get]] internal method of
// O with argument "toISOString".
var toISO = O.toISOString;
// 5. If IsCallable(toISO) is false, throw a TypeError exception.
if (!isCallable(toISO)) {
throw new TypeError('toISOString property is not callable');
}
// 6. Return the result of calling the [[Call]] internal method of
// toISO with O as the this value and an empty argument list.
return toISO.call(O);
// NOTE 1 The argument is ignored.
// NOTE 2 The toJSON function is intentionally generic; it does not
// require that its this value be a Date object. Therefore, it can be
// transferred to other kinds of objects for use as a method. However,
// it does require that any such object have a toISOString method. An
// object is free to use the argument key to filter its
// stringification.
};
}
// ES5 15.9.4.2
// http://es5.github.com/#x15.9.4.2
// based on work shared by Daniel Friesen (dantman)
// http://gist.github.com/303249
var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15;
var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z')) || !isNaN(Date.parse('2012-12-31T23:59:60.000Z'));
var doesNotParseY2KNewYear = isNaN(Date.parse('2000-01-01T00:00:00.000Z'));
if (doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
// XXX global assignment won't work in embeddings that use
// an alternate object for the context.
/* global Date: true */
/* eslint-disable no-undef */
var maxSafeUnsigned32Bit = Math.pow(2, 31) - 1;
var hasSafariSignedIntBug = isActualNaN(new Date(1970, 0, 1, 0, 0, 0, maxSafeUnsigned32Bit + 1).getTime());
/* eslint-disable no-implicit-globals */
Date = (function (NativeDate) {
/* eslint-enable no-implicit-globals */
/* eslint-enable no-undef */
// Date.length === 7
var DateShim = function Date(Y, M, D, h, m, s, ms) {
var length = arguments.length;
var date;
if (this instanceof NativeDate) {
var seconds = s;
var millis = ms;
if (hasSafariSignedIntBug && length >= 7 && ms > maxSafeUnsigned32Bit) {
// work around a Safari 8/9 bug where it treats the seconds as signed
var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit;
var sToShift = Math.floor(msToShift / 1e3);
seconds += sToShift;
millis -= sToShift * 1e3;
}
date = length === 1 && $String(Y) === Y ? // isString(Y)
// We explicitly pass it through parse:
new NativeDate(DateShim.parse(Y)) :
// We have to manually make calls depending on argument
// length here
length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) :
length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) :
length >= 5 ? new NativeDate(Y, M, D, h, m) :
length >= 4 ? new NativeDate(Y, M, D, h) :
length >= 3 ? new NativeDate(Y, M, D) :
length >= 2 ? new NativeDate(Y, M) :
length >= 1 ? new NativeDate(Y instanceof NativeDate ? +Y : Y) :
new NativeDate();
} else {
date = NativeDate.apply(this, arguments);
}
if (!isPrimitive(date)) {
// Prevent mixups with unfixed Date object
defineProperties(date, { constructor: DateShim }, true);
}
return date;
};
// 15.9.1.15 Date Time String Format.
var isoDateExpression = new RegExp('^' +
'(\\d{4}|[+-]\\d{6})' + // four-digit year capture or sign +
// 6-digit extended year
'(?:-(\\d{2})' + // optional month capture
'(?:-(\\d{2})' + // optional day capture
'(?:' + // capture hours:minutes:seconds.milliseconds
'T(\\d{2})' + // hours capture
':(\\d{2})' + // minutes capture
'(?:' + // optional :seconds.milliseconds
':(\\d{2})' + // seconds capture
'(?:(\\.\\d{1,}))?' + // milliseconds capture
')?' +
'(' + // capture UTC offset component
'Z|' + // UTC capture
'(?:' + // offset specifier +/-hours:minutes
'([-+])' + // sign capture
'(\\d{2})' + // hours offset capture
':(\\d{2})' + // minutes offset capture
')' +
')?)?)?)?' +
'$');
var months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
var dayFromMonth = function dayFromMonth(year, month) {
var t = month > 1 ? 1 : 0;
return (
months[month] +
Math.floor((year - 1969 + t) / 4) -
Math.floor((year - 1901 + t) / 100) +
Math.floor((year - 1601 + t) / 400) +
365 * (year - 1970)
);
};
var toUTC = function toUTC(t) {
var s = 0;
var ms = t;
if (hasSafariSignedIntBug && ms > maxSafeUnsigned32Bit) {
// work around a Safari 8/9 bug where it treats the seconds as signed
var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit;
var sToShift = Math.floor(msToShift / 1e3);
s += sToShift;
ms -= sToShift * 1e3;
}
return $Number(new NativeDate(1970, 0, 1, 0, 0, s, ms));
};
// Copy any custom methods a 3rd party library may have added
for (var key in NativeDate) {
if (owns(NativeDate, key)) {
DateShim[key] = NativeDate[key];
}
}
// Copy "native" methods explicitly; they may be non-enumerable
defineProperties(DateShim, {
now: NativeDate.now,
UTC: NativeDate.UTC
}, true);
DateShim.prototype = NativeDate.prototype;
defineProperties(DateShim.prototype, {
constructor: DateShim
}, true);
// Upgrade Date.parse to handle simplified ISO 8601 strings
var parseShim = function parse(string) {
var match = isoDateExpression.exec(string);
if (match) {
// parse months, days, hours, minutes, seconds, and milliseconds
// provide default values if necessary
// parse the UTC offset component
var year = $Number(match[1]),
month = $Number(match[2] || 1) - 1,
day = $Number(match[3] || 1) - 1,
hour = $Number(match[4] || 0),
minute = $Number(match[5] || 0),
second = $Number(match[6] || 0),
millisecond = Math.floor($Number(match[7] || 0) * 1000),
// When time zone is missed, local offset should be used
// (ES 5.1 bug)
// see https://bugs.ecmascript.org/show_bug.cgi?id=112
isLocalTime = Boolean(match[4] && !match[8]),
signOffset = match[9] === '-' ? 1 : -1,
hourOffset = $Number(match[10] || 0),
minuteOffset = $Number(match[11] || 0),
result;
var hasMinutesOrSecondsOrMilliseconds = minute > 0 || second > 0 || millisecond > 0;
if (
hour < (hasMinutesOrSecondsOrMilliseconds ? 24 : 25) &&
minute < 60 && second < 60 && millisecond < 1000 &&
month > -1 && month < 12 && hourOffset < 24 &&
minuteOffset < 60 && // detect invalid offsets
day > -1 &&
day < (dayFromMonth(year, month + 1) - dayFromMonth(year, month))
) {
result = (
(dayFromMonth(year, month) + day) * 24 +
hour +
hourOffset * signOffset
) * 60;
result = (
(result + minute + minuteOffset * signOffset) * 60 +
second
) * 1000 + millisecond;
if (isLocalTime) {
result = toUTC(result);
}
if (-8.64e15 <= result && result <= 8.64e15) {
return result;
}
}
return NaN;
}
return NativeDate.parse.apply(this, arguments);
};
defineProperties(DateShim, { parse: parseShim });
return DateShim;
}(Date));
/* global Date: false */
}
// ES5 15.9.4.4
// http://es5.github.com/#x15.9.4.4
if (!Date.now) {
Date.now = function now() {
return new Date().getTime();
};
}
//
// Number
// ======
//
// ES5.1 15.7.4.5
// http://es5.github.com/#x15.7.4.5
var hasToFixedBugs = NumberPrototype.toFixed && (
(0.00008).toFixed(3) !== '0.000' ||
(0.9).toFixed(0) !== '1' ||
(1.255).toFixed(2) !== '1.25' ||
(1000000000000000128).toFixed(0) !== '1000000000000000128'
);
var toFixedHelpers = {
base: 1e7,
size: 6,
data: [0, 0, 0, 0, 0, 0],
multiply: function multiply(n, c) {
var i = -1;
var c2 = c;
while (++i < toFixedHelpers.size) {
c2 += n * toFixedHelpers.data[i];
toFixedHelpers.data[i] = c2 % toFixedHelpers.base;
c2 = Math.floor(c2 / toFixedHelpers.base);
}
},
divide: function divide(n) {
var i = toFixedHelpers.size;
var c = 0;
while (--i >= 0) {
c += toFixedHelpers.data[i];
toFixedHelpers.data[i] = Math.floor(c / n);
c = (c % n) * toFixedHelpers.base;
}
},
numToString: function numToString() {
var i = toFixedHelpers.size;
var s = '';
while (--i >= 0) {
if (s !== '' || i === 0 || toFixedHelpers.data[i] !== 0) {
var t = $String(toFixedHelpers.data[i]);
if (s === '') {
s = t;
} else {
s += strSlice('0000000', 0, 7 - t.length) + t;
}
}
}
return s;
},
pow: function pow(x, n, acc) {
return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
},
log: function log(x) {
var n = 0;
var x2 = x;
while (x2 >= 4096) {
n += 12;
x2 /= 4096;
}
while (x2 >= 2) {
n += 1;
x2 /= 2;
}
return n;
}
};
var toFixedShim = function toFixed(fractionDigits) {
var f, x, s, m, e, z, j, k;
// Test for NaN and round fractionDigits down
f = $Number(fractionDigits);
f = isActualNaN(f) ? 0 : Math.floor(f);
if (f < 0 || f > 20) {
throw new RangeError('Number.toFixed called with invalid number of decimals');
}
x = $Number(this);
if (isActualNaN(x)) {
return 'NaN';
}
// If it is too big or small, return the string value of the number
if (x <= -1e21 || x >= 1e21) {
return $String(x);
}
s = '';
if (x < 0) {
s = '-';
x = -x;
}
m = '0';
if (x > 1e-21) {
// 1e-21 < x < 1e21
// -70 < log2(x) < 70
e = toFixedHelpers.log(x * toFixedHelpers.pow(2, 69, 1)) - 69;
z = (e < 0 ? x * toFixedHelpers.pow(2, -e, 1) : x / toFixedHelpers.pow(2, e, 1));
z *= 0x10000000000000; // Math.pow(2, 52);
e = 52 - e;
// -18 < e < 122
// x = z / 2 ^ e
if (e > 0) {
toFixedHelpers.multiply(0, z);
j = f;
while (j >= 7) {
toFixedHelpers.multiply(1e7, 0);
j -= 7;
}
toFixedHelpers.multiply(toFixedHelpers.pow(10, j, 1), 0);
j = e - 1;
while (j >= 23) {
toFixedHelpers.divide(1 << 23);
j -= 23;
}
toFixedHelpers.divide(1 << j);
toFixedHelpers.multiply(1, 1);
toFixedHelpers.divide(2);
m = toFixedHelpers.numToString();
} else {
toFixedHelpers.multiply(0, z);
toFixedHelpers.multiply(1 << (-e), 0);
m = toFixedHelpers.numToString() + strSlice('0.00000000000000000000', 2, 2 + f);
}
}
if (f > 0) {
k = m.length;
if (k <= f) {
m = s + strSlice('0.0000000000000000000', 0, f - k + 2) + m;
} else {
m = s + strSlice(m, 0, k - f) + '.' + strSlice(m, k - f);
}
} else {
m = s + m;
}
return m;
};
defineProperties(NumberPrototype, { toFixed: toFixedShim }, hasToFixedBugs);
var hasToPrecisionUndefinedBug = (function () {
try {
return 1.0.toPrecision(undefined) === '1';
} catch (e) {
return true;
}
}());
var originalToPrecision = NumberPrototype.toPrecision;
defineProperties(NumberPrototype, {
toPrecision: function toPrecision(precision) {
return typeof precision === 'undefined' ? originalToPrecision.call(this) : originalToPrecision.call(this, precision);
}
}, hasToPrecisionUndefinedBug);
//
// String
// ======
//
// ES5 15.5.4.14
// http://es5.github.com/#x15.5.4.14
// [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
// Many browsers do not split properly with regular expressions or they
// do not perform the split correctly under obscure conditions.
// See http://blog.stevenlevithan.com/archives/cross-browser-split
// I've tested in many browsers and this seems to cover the deviant ones:
// 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
// '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
// 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
// [undefined, "t", undefined, "e", ...]
// ''.split(/.?/) should be [], not [""]
// '.'.split(/()()/) should be ["."], not ["", "", "."]
if (
'ab'.split(/(?:ab)*/).length !== 2 ||
'.'.split(/(.?)(.?)/).length !== 4 ||
'tesst'.split(/(s)*/)[1] === 't' ||
'test'.split(/(?:)/, -1).length !== 4 ||
''.split(/.?/).length ||
'.'.split(/()()/).length > 1
) {
(function () {
var compliantExecNpcg = typeof (/()??/).exec('')[1] === 'undefined'; // NPCG: nonparticipating capturing group
var maxSafe32BitInt = Math.pow(2, 32) - 1;
StringPrototype.split = function (separator, limit) {
var string = String(this);
if (typeof separator === 'undefined' && limit === 0) {
return [];
}
// If `separator` is not a regex, use native split
if (!isRegex(separator)) {
return strSplit(this, separator, limit);
}
var output = [];
var flags = (separator.ignoreCase ? 'i' : '') +
(separator.multiline ? 'm' : '') +
(separator.unicode ? 'u' : '') + // in ES6
(separator.sticky ? 'y' : ''), // Firefox 3+ and ES6
lastLastIndex = 0,
// Make `global` and avoid `lastIndex` issues by working with a copy
separator2, match, lastIndex, lastLength;
var separatorCopy = new RegExp(separator.source, flags + 'g');
if (!compliantExecNpcg) {
// Doesn't need flags gy, but they don't hurt
separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
}
/* Values for `limit`, per the spec:
* If undefined: 4294967295 // maxSafe32BitInt
* If 0, Infinity, or NaN: 0
* If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
* If negative number: 4294967296 - Math.floor(Math.abs(limit))
* If other: Type-convert, then use the above rules
*/
var splitLimit = typeof limit === 'undefined' ? maxSafe32BitInt : ES.ToUint32(limit);
match = separatorCopy.exec(string);
while (match) {
// `separatorCopy.lastIndex` is not reliable cross-browser
lastIndex = match.index + match[0].length;
if (lastIndex > lastLastIndex) {
pushCall(output, strSlice(string, lastLastIndex, match.index));
// Fix browsers whose `exec` methods don't consistently return `undefined` for
// nonparticipating capturing groups
if (!compliantExecNpcg && match.length > 1) {
/* eslint-disable no-loop-func */
match[0].replace(separator2, function () {
for (var i = 1; i < arguments.length - 2; i++) {
if (typeof arguments[i] === 'undefined') {
match[i] = void 0;
}
}
});
/* eslint-enable no-loop-func */
}
if (match.length > 1 && match.index < string.length) {
array_push.apply(output, arraySlice(match, 1));
}
lastLength = match[0].length;
lastLastIndex = lastIndex;
if (output.length >= splitLimit) {
break;
}
}
if (separatorCopy.lastIndex === match.index) {
separatorCopy.lastIndex++; // Avoid an infinite loop
}
match = separatorCopy.exec(string);
}
if (lastLastIndex === string.length) {
if (lastLength || !separatorCopy.test('')) {
pushCall(output, '');
}
} else {
pushCall(output, strSlice(string, lastLastIndex));
}
return output.length > splitLimit ? arraySlice(output, 0, splitLimit) : output;
};
}());
// [bugfix, chrome]
// If separator is undefined, then the result array contains just one String,
// which is the this value (converted to a String). If limit is not undefined,
// then the output array is truncated so that it contains no more than limit
// elements.
// "0".split(undefined, 0) -> []
} else if ('0'.split(void 0, 0).length) {
StringPrototype.split = function split(separator, limit) {
if (typeof separator === 'undefined' && limit === 0) {
return [];
}
return strSplit(this, separator, limit);
};
}
var str_replace = StringPrototype.replace;
var replaceReportsGroupsCorrectly = (function () {
var groups = [];
'x'.replace(/x(.)?/g, function (match, group) {
pushCall(groups, group);
});
return groups.length === 1 && typeof groups[0] === 'undefined';
}());
if (!replaceReportsGroupsCorrectly) {
StringPrototype.replace = function replace(searchValue, replaceValue) {
var isFn = isCallable(replaceValue);
var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source);
if (!isFn || !hasCapturingGroups) {
return str_replace.call(this, searchValue, replaceValue);
} else {
var wrappedReplaceValue = function (match) {
var length = arguments.length;
var originalLastIndex = searchValue.lastIndex;
searchValue.lastIndex = 0;
var args = searchValue.exec(match) || [];
searchValue.lastIndex = originalLastIndex;
pushCall(args, arguments[length - 2], arguments[length - 1]);
return replaceValue.apply(this, args);
};
return str_replace.call(this, searchValue, wrappedReplaceValue);
}
};
}
// ECMA-262, 3rd B.2.3
// Not an ECMAScript standard, although ECMAScript 3rd Edition has a
// non-normative section suggesting uniform semantics and it should be
// normalized across all browsers
// [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
var string_substr = StringPrototype.substr;
var hasNegativeSubstrBug = ''.substr && '0b'.substr(-1) !== 'b';
defineProperties(StringPrototype, {
substr: function substr(start, length) {
var normalizedStart = start;
if (start < 0) {
normalizedStart = max(this.length + start, 0);
}
return string_substr.call(this, normalizedStart, length);
}
}, hasNegativeSubstrBug);
// ES5 15.5.4.20
// whitespace from: http://es5.github.io/#x15.5.4.20
var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
'\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' +
'\u2029\uFEFF';
var zeroWidth = '\u200b';
var wsRegexChars = '[' + ws + ']';
var trimBeginRegexp = new RegExp('^' + wsRegexChars + wsRegexChars + '*');
var trimEndRegexp = new RegExp(wsRegexChars + wsRegexChars + '*$');
var hasTrimWhitespaceBug = StringPrototype.trim && (ws.trim() || !zeroWidth.trim());
defineProperties(StringPrototype, {
// http://blog.stevenlevithan.com/archives/faster-trim-javascript
// http://perfectionkills.com/whitespace-deviations/
trim: function trim() {
if (typeof this === 'undefined' || this === null) {
throw new TypeError("can't convert " + this + ' to object');
}
return $String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, '');
}
}, hasTrimWhitespaceBug);
var trim = call.bind(String.prototype.trim);
var hasLastIndexBug = StringPrototype.lastIndexOf && 'abcあい'.lastIndexOf('あい', 2) !== -1;
defineProperties(StringPrototype, {
lastIndexOf: function lastIndexOf(searchString) {
if (typeof this === 'undefined' || this === null) {
throw new TypeError("can't convert " + this + ' to object');
}
var S = $String(this);
var searchStr = $String(searchString);
var numPos = arguments.length > 1 ? $Number(arguments[1]) : NaN;
var pos = isActualNaN(numPos) ? Infinity : ES.ToInteger(numPos);
var start = min(max(pos, 0), S.length);
var searchLen = searchStr.length;
var k = start + searchLen;
while (k > 0) {
k = max(0, k - searchLen);
var index = strIndexOf(strSlice(S, k, start + searchLen), searchStr);
if (index !== -1) {
return k + index;
}
}
return -1;
}
}, hasLastIndexBug);
var originalLastIndexOf = StringPrototype.lastIndexOf;
defineProperties(StringPrototype, {
lastIndexOf: function lastIndexOf(searchString) {
return originalLastIndexOf.apply(this, arguments);
}
}, StringPrototype.lastIndexOf.length !== 1);
// ES-5 15.1.2.2
/* eslint-disable radix */
if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
/* eslint-enable radix */
/* global parseInt: true */
parseInt = (function (origParseInt) {
var hexRegex = /^[\-+]?0[xX]/;
return function parseInt(str, radix) {
var string = trim(String(str));
var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10);
return origParseInt(string, defaultedRadix);
};
}(parseInt));
}
// https://es5.github.io/#x15.1.2.3
if (1 / parseFloat('-0') !== -Infinity) {
/* global parseFloat: true */
parseFloat = (function (origParseFloat) {
return function parseFloat(string) {
var inputString = trim(String(string));
var result = origParseFloat(inputString);
return result === 0 && strSlice(inputString, 0, 1) === '-' ? -0 : result;
};
}(parseFloat));
}
if (String(new RangeError('test')) !== 'RangeError: test') {
var errorToStringShim = function toString() {
if (typeof this === 'undefined' || this === null) {
throw new TypeError("can't convert " + this + ' to object');
}
var name = this.name;
if (typeof name === 'undefined') {
name = 'Error';
} else if (typeof name !== 'string') {
name = $String(name);
}
var msg = this.message;
if (typeof msg === 'undefined') {
msg = '';
} else if (typeof msg !== 'string') {
msg = $String(msg);
}
if (!name) {
return msg;
}
if (!msg) {
return name;
}
return name + ': ' + msg;
};
// can't use defineProperties here because of toString enumeration issue in IE <= 8
Error.prototype.toString = errorToStringShim;
}
if (supportsDescriptors) {
var ensureNonEnumerable = function (obj, prop) {
if (isEnum(obj, prop)) {
var desc = Object.getOwnPropertyDescriptor(obj, prop);
if (desc.configurable) {
desc.enumerable = false;
Object.defineProperty(obj, prop, desc);
}
}
};
ensureNonEnumerable(Error.prototype, 'message');
if (Error.prototype.message !== '') {
Error.prototype.message = '';
}
ensureNonEnumerable(Error.prototype, 'name');
}
if (String(/a/mig) !== '/a/gim') {
var regexToString = function toString() {
var str = '/' + this.source + '/';
if (this.global) {
str += 'g';
}
if (this.ignoreCase) {
str += 'i';
}
if (this.multiline) {
str += 'm';
}
return str;
};
// can't use defineProperties here because of toString enumeration issue in IE <= 8
RegExp.prototype.toString = regexToString;
}
}));
},{}],20:[function(require,module,exports){
(function (process,global){
/*!
* https://github.com/paulmillr/es6-shim
* @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com)
* and contributors, MIT License
* es6-shim: v0.35.1
* see https://github.com/paulmillr/es6-shim/blob/0.35.1/LICENSE
* Details and documentation:
* https://github.com/paulmillr/es6-shim/
*/
// UMD (Universal Module Definition)
// see https://github.com/umdjs/umd/blob/master/returnExports.js
(function (root, factory) {
/*global define, module, exports */
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.returnExports = factory();
}
}(this, function () {
'use strict';
var _apply = Function.call.bind(Function.apply);
var _call = Function.call.bind(Function.call);
var isArray = Array.isArray;
var keys = Object.keys;
var not = function notThunker(func) {
return function notThunk() {
return !_apply(func, this, arguments);
};
};
var throwsError = function (func) {
try {
func();
return false;
} catch (e) {
return true;
}
};
var valueOrFalseIfThrows = function valueOrFalseIfThrows(func) {
try {
return func();
} catch (e) {
return false;
}
};
var isCallableWithoutNew = not(throwsError);
var arePropertyDescriptorsSupported = function () {
// if Object.defineProperty exists but throws, it's IE 8
return !throwsError(function () {
Object.defineProperty({}, 'x', { get: function () {} });
});
};
var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
var functionsHaveNames = (function foo() {}).name === 'foo'; // eslint-disable-line no-extra-parens
var _forEach = Function.call.bind(Array.prototype.forEach);
var _reduce = Function.call.bind(Array.prototype.reduce);
var _filter = Function.call.bind(Array.prototype.filter);
var _some = Function.call.bind(Array.prototype.some);
var defineProperty = function (object, name, value, force) {
if (!force && name in object) { return; }
if (supportsDescriptors) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: value
});
} else {
object[name] = value;
}
};
// Define configurable, writable and non-enumerable props
// if they don’t exist.
var defineProperties = function (object, map, forceOverride) {
_forEach(keys(map), function (name) {
var method = map[name];
defineProperty(object, name, method, !!forceOverride);
});
};
var _toString = Function.call.bind(Object.prototype.toString);
var isCallable = typeof /abc/ === 'function' ? function IsCallableSlow(x) {
// Some old browsers (IE, FF) say that typeof /abc/ === 'function'
return typeof x === 'function' && _toString(x) === '[object Function]';
} : function IsCallableFast(x) { return typeof x === 'function'; };
var Value = {
getter: function (object, name, getter) {
if (!supportsDescriptors) {
throw new TypeError('getters require true ES5 support');
}
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
get: getter
});
},
proxy: function (originalObject, key, targetObject) {
if (!supportsDescriptors) {
throw new TypeError('getters require true ES5 support');
}
var originalDescriptor = Object.getOwnPropertyDescriptor(originalObject, key);
Object.defineProperty(targetObject, key, {
configurable: originalDescriptor.configurable,
enumerable: originalDescriptor.enumerable,
get: function getKey() { return originalObject[key]; },
set: function setKey(value) { originalObject[key] = value; }
});
},
redefine: function (object, property, newValue) {
if (supportsDescriptors) {
var descriptor = Object.getOwnPropertyDescriptor(object, property);
descriptor.value = newValue;
Object.defineProperty(object, property, descriptor);
} else {
object[property] = newValue;
}
},
defineByDescriptor: function (object, property, descriptor) {
if (supportsDescriptors) {
Object.defineProperty(object, property, descriptor);
} else if ('value' in descriptor) {
object[property] = descriptor.value;
}
},
preserveToString: function (target, source) {
if (source && isCallable(source.toString)) {
defineProperty(target, 'toString', source.toString.bind(source), true);
}
}
};
// Simple shim for Object.create on ES3 browsers
// (unlike real shim, no attempt to support `prototype === null`)
var create = Object.create || function (prototype, properties) {
var Prototype = function Prototype() {};
Prototype.prototype = prototype;
var object = new Prototype();
if (typeof properties !== 'undefined') {
keys(properties).forEach(function (key) {
Value.defineByDescriptor(object, key, properties[key]);
});
}
return object;
};
var supportsSubclassing = function (C, f) {
if (!Object.setPrototypeOf) { return false; /* skip test on IE < 11 */ }
return valueOrFalseIfThrows(function () {
var Sub = function Subclass(arg) {
var o = new C(arg);
Object.setPrototypeOf(o, Subclass.prototype);
return o;
};
Object.setPrototypeOf(Sub, C);
Sub.prototype = create(C.prototype, {
constructor: { value: Sub }
});
return f(Sub);
});
};
var getGlobal = function () {
/* global self, window, global */
// the only reliable means to get the global object is
// `Function('return this')()`
// However, this causes CSP violations in Chrome apps.
if (typeof self !== 'undefined') { return self; }
if (typeof window !== 'undefined') { return window; }
if (typeof global !== 'undefined') { return global; }
throw new Error('unable to locate global object');
};
var globals = getGlobal();
var globalIsFinite = globals.isFinite;
var _indexOf = Function.call.bind(String.prototype.indexOf);
var _arrayIndexOfApply = Function.apply.bind(Array.prototype.indexOf);
var _concat = Function.call.bind(Array.prototype.concat);
// var _sort = Function.call.bind(Array.prototype.sort);
var _strSlice = Function.call.bind(String.prototype.slice);
var _push = Function.call.bind(Array.prototype.push);
var _pushApply = Function.apply.bind(Array.prototype.push);
var _shift = Function.call.bind(Array.prototype.shift);
var _max = Math.max;
var _min = Math.min;
var _floor = Math.floor;
var _abs = Math.abs;
var _exp = Math.exp;
var _log = Math.log;
var _sqrt = Math.sqrt;
var _hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty);
var ArrayIterator; // make our implementation private
var noop = function () {};
var OrigMap = globals.Map;
var origMapDelete = OrigMap && OrigMap.prototype['delete'];
var origMapGet = OrigMap && OrigMap.prototype.get;
var origMapHas = OrigMap && OrigMap.prototype.has;
var origMapSet = OrigMap && OrigMap.prototype.set;
var Symbol = globals.Symbol || {};
var symbolSpecies = Symbol.species || '@@species';
var numberIsNaN = Number.isNaN || function isNaN(value) {
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN('foo') => true
return value !== value;
};
var numberIsFinite = Number.isFinite || function isFinite(value) {
return typeof value === 'number' && globalIsFinite(value);
};
var _sign = isCallable(Math.sign) ? Math.sign : function sign(value) {
var number = Number(value);
if (number === 0) { return number; }
if (numberIsNaN(number)) { return number; }
return number < 0 ? -1 : 1;
};
// taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js
// can be replaced with require('is-arguments') if we ever use a build process instead
var isStandardArguments = function isArguments(value) {
return _toString(value) === '[object Arguments]';
};
var isLegacyArguments = function isArguments(value) {
return value !== null &&
typeof value === 'object' &&
typeof value.length === 'number' &&
value.length >= 0 &&
_toString(value) !== '[object Array]' &&
_toString(value.callee) === '[object Function]';
};
var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments;
var Type = {
primitive: function (x) { return x === null || (typeof x !== 'function' && typeof x !== 'object'); },
string: function (x) { return _toString(x) === '[object String]'; },
regex: function (x) { return _toString(x) === '[object RegExp]'; },
symbol: function (x) {
return typeof globals.Symbol === 'function' && typeof x === 'symbol';
}
};
var overrideNative = function overrideNative(object, property, replacement) {
var original = object[property];
defineProperty(object, property, replacement, true);
Value.preserveToString(object[property], original);
};
// eslint-disable-next-line no-restricted-properties
var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && Type.symbol(Symbol());
// This is a private name in the es6 spec, equal to '[Symbol.iterator]'
// we're going to use an arbitrary _-prefixed name to make our shims
// work properly with each other, even though we don't have full Iterator
// support. That is, `Array.from(map.keys())` will work, but we don't
// pretend to export a "real" Iterator interface.
var $iterator$ = Type.symbol(Symbol.iterator) ? Symbol.iterator : '_es6-shim iterator_';
// Firefox ships a partial implementation using the name @@iterator.
// https://bugzilla.mozilla.org/show_bug.cgi?id=907077#c14
// So use that name if we detect it.
if (globals.Set && typeof new globals.Set()['@@iterator'] === 'function') {
$iterator$ = '@@iterator';
}
// Reflect
if (!globals.Reflect) {
defineProperty(globals, 'Reflect', {}, true);
}
var Reflect = globals.Reflect;
var $String = String;
/* global document */
var domAll = (typeof document === 'undefined' || !document) ? null : document.all;
/* jshint eqnull:true */
var isNullOrUndefined = domAll == null ? function isNullOrUndefined(x) {
/* jshint eqnull:true */
return x == null;
} : function isNullOrUndefinedAndNotDocumentAll(x) {
/* jshint eqnull:true */
return x == null && x !== domAll;
};
var ES = {
// http://www.ecma-international.org/ecma-262/6.0/#sec-call
Call: function Call(F, V) {
var args = arguments.length > 2 ? arguments[2] : [];
if (!ES.IsCallable(F)) {
throw new TypeError(F + ' is not a function');
}
return _apply(F, V, args);
},
RequireObjectCoercible: function (x, optMessage) {
if (isNullOrUndefined(x)) {
throw new TypeError(optMessage || 'Cannot call method on ' + x);
}
return x;
},
// This might miss the "(non-standard exotic and does not implement
// [[Call]])" case from
// http://www.ecma-international.org/ecma-262/6.0/#sec-typeof-operator-runtime-semantics-evaluation
// but we can't find any evidence these objects exist in practice.
// If we find some in the future, you could test `Object(x) === x`,
// which is reliable according to
// http://www.ecma-international.org/ecma-262/6.0/#sec-toobject
// but is not well optimized by runtimes and creates an object
// whenever it returns false, and thus is very slow.
TypeIsObject: function (x) {
if (x === void 0 || x === null || x === true || x === false) {
return false;
}
return typeof x === 'function' || typeof x === 'object' || x === domAll;
},
ToObject: function (o, optMessage) {
return Object(ES.RequireObjectCoercible(o, optMessage));
},
IsCallable: isCallable,
IsConstructor: function (x) {
// We can't tell callables from constructors in ES5
return ES.IsCallable(x);
},
ToInt32: function (x) {
return ES.ToNumber(x) >> 0;
},
ToUint32: function (x) {
return ES.ToNumber(x) >>> 0;
},
ToNumber: function (value) {
if (_toString(value) === '[object Symbol]') {
throw new TypeError('Cannot convert a Symbol value to a number');
}
return +value;
},
ToInteger: function (value) {
var number = ES.ToNumber(value);
if (numberIsNaN(number)) { return 0; }
if (number === 0 || !numberIsFinite(number)) { return number; }
return (number > 0 ? 1 : -1) * _floor(_abs(number));
},
ToLength: function (value) {
var len = ES.ToInteger(value);
if (len <= 0) { return 0; } // includes converting -0 to +0
if (len > Number.MAX_SAFE_INTEGER) { return Number.MAX_SAFE_INTEGER; }
return len;
},
SameValue: function (a, b) {
if (a === b) {
// 0 === -0, but they are not identical.
if (a === 0) { return 1 / a === 1 / b; }
return true;
}
return numberIsNaN(a) && numberIsNaN(b);
},
SameValueZero: function (a, b) {
// same as SameValue except for SameValueZero(+0, -0) == true
return (a === b) || (numberIsNaN(a) && numberIsNaN(b));
},
IsIterable: function (o) {
return ES.TypeIsObject(o) && (typeof o[$iterator$] !== 'undefined' || isArguments(o));
},
GetIterator: function (o) {
if (isArguments(o)) {
// special case support for `arguments`
return new ArrayIterator(o, 'value');
}
var itFn = ES.GetMethod(o, $iterator$);
if (!ES.IsCallable(itFn)) {
// Better diagnostics if itFn is null or undefined
throw new TypeError('value is not an iterable');
}
var it = ES.Call(itFn, o);
if (!ES.TypeIsObject(it)) {
throw new TypeError('bad iterator');
}
return it;
},
GetMethod: function (o, p) {
var func = ES.ToObject(o)[p];
if (isNullOrUndefined(func)) {
return void 0;
}
if (!ES.IsCallable(func)) {
throw new TypeError('Method not callable: ' + p);
}
return func;
},
IteratorComplete: function (iterResult) {
return !!iterResult.done;
},
IteratorClose: function (iterator, completionIsThrow) {
var returnMethod = ES.GetMethod(iterator, 'return');
if (returnMethod === void 0) {
return;
}
var innerResult, innerException;
try {
innerResult = ES.Call(returnMethod, iterator);
} catch (e) {
innerException = e;
}
if (completionIsThrow) {
return;
}
if (innerException) {
throw innerException;
}
if (!ES.TypeIsObject(innerResult)) {
throw new TypeError("Iterator's return method returned a non-object.");
}
},
IteratorNext: function (it) {
var result = arguments.length > 1 ? it.next(arguments[1]) : it.next();
if (!ES.TypeIsObject(result)) {
throw new TypeError('bad iterator');
}
return result;
},
IteratorStep: function (it) {
var result = ES.IteratorNext(it);
var done = ES.IteratorComplete(result);
return done ? false : result;
},
Construct: function (C, args, newTarget, isES6internal) {
var target = typeof newTarget === 'undefined' ? C : newTarget;
if (!isES6internal && Reflect.construct) {
// Try to use Reflect.construct if available
return Reflect.construct(C, args, target);
}
// OK, we have to fake it. This will only work if the
// C.[[ConstructorKind]] == "base" -- but that's the only
// kind we can make in ES5 code anyway.
// OrdinaryCreateFromConstructor(target, "%ObjectPrototype%")
var proto = target.prototype;
if (!ES.TypeIsObject(proto)) {
proto = Object.prototype;
}
var obj = create(proto);
// Call the constructor.
var result = ES.Call(C, obj, args);
return ES.TypeIsObject(result) ? result : obj;
},
SpeciesConstructor: function (O, defaultConstructor) {
var C = O.constructor;
if (C === void 0) {
return defaultConstructor;
}
if (!ES.TypeIsObject(C)) {
throw new TypeError('Bad constructor');
}
var S = C[symbolSpecies];
if (isNullOrUndefined(S)) {
return defaultConstructor;
}
if (!ES.IsConstructor(S)) {
throw new TypeError('Bad @@species');
}
return S;
},
CreateHTML: function (string, tag, attribute, value) {
var S = ES.ToString(string);
var p1 = '<' + tag;
if (attribute !== '') {
var V = ES.ToString(value);
var escapedV = V.replace(/"/g, '&quot;');
p1 += ' ' + attribute + '="' + escapedV + '"';
}
var p2 = p1 + '>';
var p3 = p2 + S;
return p3 + '</' + tag + '>';
},
IsRegExp: function IsRegExp(argument) {
if (!ES.TypeIsObject(argument)) {
return false;
}
var isRegExp = argument[Symbol.match];
if (typeof isRegExp !== 'undefined') {
return !!isRegExp;
}
return Type.regex(argument);
},
ToString: function ToString(string) {
return $String(string);
}
};
// Well-known Symbol shims
if (supportsDescriptors && hasSymbols) {
var defineWellKnownSymbol = function defineWellKnownSymbol(name) {
if (Type.symbol(Symbol[name])) {
return Symbol[name];
}
// eslint-disable-next-line no-restricted-properties
var sym = Symbol['for']('Symbol.' + name);
Object.defineProperty(Symbol, name, {
configurable: false,
enumerable: false,
writable: false,
value: sym
});
return sym;
};
if (!Type.symbol(Symbol.search)) {
var symbolSearch = defineWellKnownSymbol('search');
var originalSearch = String.prototype.search;
defineProperty(RegExp.prototype, symbolSearch, function search(string) {
return ES.Call(originalSearch, string, [this]);
});
var searchShim = function search(regexp) {
var O = ES.RequireObjectCoercible(this);
if (!isNullOrUndefined(regexp)) {
var searcher = ES.GetMethod(regexp, symbolSearch);
if (typeof searcher !== 'undefined') {
return ES.Call(searcher, regexp, [O]);
}
}
return ES.Call(originalSearch, O, [ES.ToString(regexp)]);
};
overrideNative(String.prototype, 'search', searchShim);
}
if (!Type.symbol(Symbol.replace)) {
var symbolReplace = defineWellKnownSymbol('replace');
var originalReplace = String.prototype.replace;
defineProperty(RegExp.prototype, symbolReplace, function replace(string, replaceValue) {
return ES.Call(originalReplace, string, [this, replaceValue]);
});
var replaceShim = function replace(searchValue, replaceValue) {
var O = ES.RequireObjectCoercible(this);
if (!isNullOrUndefined(searchValue)) {
var replacer = ES.GetMethod(searchValue, symbolReplace);
if (typeof replacer !== 'undefined') {
return ES.Call(replacer, searchValue, [O, replaceValue]);
}
}
return ES.Call(originalReplace, O, [ES.ToString(searchValue), replaceValue]);
};
overrideNative(String.prototype, 'replace', replaceShim);
}
if (!Type.symbol(Symbol.split)) {
var symbolSplit = defineWellKnownSymbol('split');
var originalSplit = String.prototype.split;
defineProperty(RegExp.prototype, symbolSplit, function split(string, limit) {
return ES.Call(originalSplit, string, [this, limit]);
});
var splitShim = function split(separator, limit) {
var O = ES.RequireObjectCoercible(this);
if (!isNullOrUndefined(separator)) {
var splitter = ES.GetMethod(separator, symbolSplit);
if (typeof splitter !== 'undefined') {
return ES.Call(splitter, separator, [O, limit]);
}
}
return ES.Call(originalSplit, O, [ES.ToString(separator), limit]);
};
overrideNative(String.prototype, 'split', splitShim);
}
var symbolMatchExists = Type.symbol(Symbol.match);
var stringMatchIgnoresSymbolMatch = symbolMatchExists && (function () {
// Firefox 41, through Nightly 45 has Symbol.match, but String#match ignores it.
// Firefox 40 and below have Symbol.match but String#match works fine.
var o = {};
o[Symbol.match] = function () { return 42; };
return 'a'.match(o) !== 42;
}());
if (!symbolMatchExists || stringMatchIgnoresSymbolMatch) {
var symbolMatch = defineWellKnownSymbol('match');
var originalMatch = String.prototype.match;
defineProperty(RegExp.prototype, symbolMatch, function match(string) {
return ES.Call(originalMatch, string, [this]);
});
var matchShim = function match(regexp) {
var O = ES.RequireObjectCoercible(this);
if (!isNullOrUndefined(regexp)) {
var matcher = ES.GetMethod(regexp, symbolMatch);
if (typeof matcher !== 'undefined') {
return ES.Call(matcher, regexp, [O]);
}
}
return ES.Call(originalMatch, O, [ES.ToString(regexp)]);
};
overrideNative(String.prototype, 'match', matchShim);
}
}
var wrapConstructor = function wrapConstructor(original, replacement, keysToSkip) {
Value.preserveToString(replacement, original);
if (Object.setPrototypeOf) {
// sets up proper prototype chain where possible
Object.setPrototypeOf(original, replacement);
}
if (supportsDescriptors) {
_forEach(Object.getOwnPropertyNames(original), function (key) {
if (key in noop || keysToSkip[key]) { return; }
Value.proxy(original, key, replacement);
});
} else {
_forEach(Object.keys(original), function (key) {
if (key in noop || keysToSkip[key]) { return; }
replacement[key] = original[key];
});
}
replacement.prototype = original.prototype;
Value.redefine(original.prototype, 'constructor', replacement);
};
var defaultSpeciesGetter = function () { return this; };
var addDefaultSpecies = function (C) {
if (supportsDescriptors && !_hasOwnProperty(C, symbolSpecies)) {
Value.getter(C, symbolSpecies, defaultSpeciesGetter);
}
};
var addIterator = function (prototype, impl) {
var implementation = impl || function iterator() { return this; };
defineProperty(prototype, $iterator$, implementation);
if (!prototype[$iterator$] && Type.symbol($iterator$)) {
// implementations are buggy when $iterator$ is a Symbol
prototype[$iterator$] = implementation;
}
};
var createDataProperty = function createDataProperty(object, name, value) {
if (supportsDescriptors) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: true,
writable: true,
value: value
});
} else {
object[name] = value;
}
};
var createDataPropertyOrThrow = function createDataPropertyOrThrow(object, name, value) {
createDataProperty(object, name, value);
if (!ES.SameValue(object[name], value)) {
throw new TypeError('property is nonconfigurable');
}
};
var emulateES6construct = function (o, defaultNewTarget, defaultProto, slots) {
// This is an es5 approximation to es6 construct semantics. in es6,
// 'new Foo' invokes Foo.[[Construct]] which (for almost all objects)
// just sets the internal variable NewTarget (in es6 syntax `new.target`)
// to Foo and then returns Foo().
// Many ES6 object then have constructors of the form:
// 1. If NewTarget is undefined, throw a TypeError exception
// 2. Let xxx by OrdinaryCreateFromConstructor(NewTarget, yyy, zzz)
// So we're going to emulate those first two steps.
if (!ES.TypeIsObject(o)) {
throw new TypeError('Constructor requires `new`: ' + defaultNewTarget.name);
}
var proto = defaultNewTarget.prototype;
if (!ES.TypeIsObject(proto)) {
proto = defaultProto;
}
var obj = create(proto);
for (var name in slots) {
if (_hasOwnProperty(slots, name)) {
var value = slots[name];
defineProperty(obj, name, value, true);
}
}
return obj;
};
// Firefox 31 reports this function's length as 0
// https://bugzilla.mozilla.org/show_bug.cgi?id=1062484
if (String.fromCodePoint && String.fromCodePoint.length !== 1) {
var originalFromCodePoint = String.fromCodePoint;
overrideNative(String, 'fromCodePoint', function fromCodePoint(codePoints) {
return ES.Call(originalFromCodePoint, this, arguments);
});
}
var StringShims = {
fromCodePoint: function fromCodePoint(codePoints) {
var result = [];
var next;
for (var i = 0, length = arguments.length; i < length; i++) {
next = Number(arguments[i]);
if (!ES.SameValue(next, ES.ToInteger(next)) || next < 0 || next > 0x10FFFF) {
throw new RangeError('Invalid code point ' + next);
}
if (next < 0x10000) {
_push(result, String.fromCharCode(next));
} else {
next -= 0x10000;
_push(result, String.fromCharCode((next >> 10) + 0xD800));
_push(result, String.fromCharCode((next % 0x400) + 0xDC00));
}
}
return result.join('');
},
raw: function raw(callSite) {
var cooked = ES.ToObject(callSite, 'bad callSite');
var rawString = ES.ToObject(cooked.raw, 'bad raw value');
var len = rawString.length;
var literalsegments = ES.ToLength(len);
if (literalsegments <= 0) {
return '';
}
var stringElements = [];
var nextIndex = 0;
var nextKey, next, nextSeg, nextSub;
while (nextIndex < literalsegments) {
nextKey = ES.ToString(nextIndex);
nextSeg = ES.ToString(rawString[nextKey]);
_push(stringElements, nextSeg);
if (nextIndex + 1 >= literalsegments) {
break;
}
next = nextIndex + 1 < arguments.length ? arguments[nextIndex + 1] : '';
nextSub = ES.ToString(next);
_push(stringElements, nextSub);
nextIndex += 1;
}
return stringElements.join('');
}
};
if (String.raw && String.raw({ raw: { 0: 'x', 1: 'y', length: 2 } }) !== 'xy') {
// IE 11 TP has a broken String.raw implementation
overrideNative(String, 'raw', StringShims.raw);
}
defineProperties(String, StringShims);
// Fast repeat, uses the `Exponentiation by squaring` algorithm.
// Perf: http://jsperf.com/string-repeat2/2
var stringRepeat = function repeat(s, times) {
if (times < 1) { return ''; }
if (times % 2) { return repeat(s, times - 1) + s; }
var half = repeat(s, times / 2);
return half + half;
};
var stringMaxLength = Infinity;
var StringPrototypeShims = {
repeat: function repeat(times) {
var thisStr = ES.ToString(ES.RequireObjectCoercible(this));
var numTimes = ES.ToInteger(times);
if (numTimes < 0 || numTimes >= stringMaxLength) {
throw new RangeError('repeat count must be less than infinity and not overflow maximum string size');
}
return stringRepeat(thisStr, numTimes);
},
startsWith: function startsWith(searchString) {
var S = ES.ToString(ES.RequireObjectCoercible(this));
if (ES.IsRegExp(searchString)) {
throw new TypeError('Cannot call method "startsWith" with a regex');
}
var searchStr = ES.ToString(searchString);
var position;
if (arguments.length > 1) {
position = arguments[1];
}
var start = _max(ES.ToInteger(position), 0);
return _strSlice(S, start, start + searchStr.length) === searchStr;
},
endsWith: function endsWith(searchString) {
var S = ES.ToString(ES.RequireObjectCoercible(this));
if (ES.IsRegExp(searchString)) {
throw new TypeError('Cannot call method "endsWith" with a regex');
}
var searchStr = ES.ToString(searchString);
var len = S.length;
var endPosition;
if (arguments.length > 1) {
endPosition = arguments[1];
}
var pos = typeof endPosition === 'undefined' ? len : ES.ToInteger(endPosition);
var end = _min(_max(pos, 0), len);
return _strSlice(S, end - searchStr.length, end) === searchStr;
},
includes: function includes(searchString) {
if (ES.IsRegExp(searchString)) {
throw new TypeError('"includes" does not accept a RegExp');
}
var searchStr = ES.ToString(searchString);
var position;
if (arguments.length > 1) {
position = arguments[1];
}
// Somehow this trick makes method 100% compat with the spec.
return _indexOf(this, searchStr, position) !== -1;
},
codePointAt: function codePointAt(pos) {
var thisStr = ES.ToString(ES.RequireObjectCoercible(this));
var position = ES.ToInteger(pos);
var length = thisStr.length;
if (position >= 0 && position < length) {
var first = thisStr.charCodeAt(position);
var isEnd = position + 1 === length;
if (first < 0xD800 || first > 0xDBFF || isEnd) { return first; }
var second = thisStr.charCodeAt(position + 1);
if (second < 0xDC00 || second > 0xDFFF) { return first; }
return ((first - 0xD800) * 1024) + (second - 0xDC00) + 0x10000;
}
}
};
if (String.prototype.includes && 'a'.includes('a', Infinity) !== false) {
overrideNative(String.prototype, 'includes', StringPrototypeShims.includes);
}
if (String.prototype.startsWith && String.prototype.endsWith) {
var startsWithRejectsRegex = throwsError(function () {
/* throws if spec-compliant */
'/a/'.startsWith(/a/);
});
var startsWithHandlesInfinity = valueOrFalseIfThrows(function () {
return 'abc'.startsWith('a', Infinity) === false;
});
if (!startsWithRejectsRegex || !startsWithHandlesInfinity) {
// Firefox (< 37?) and IE 11 TP have a noncompliant startsWith implementation
overrideNative(String.prototype, 'startsWith', StringPrototypeShims.startsWith);
overrideNative(String.prototype, 'endsWith', StringPrototypeShims.endsWith);
}
}
if (hasSymbols) {
var startsWithSupportsSymbolMatch = valueOrFalseIfThrows(function () {
var re = /a/;
re[Symbol.match] = false;
return '/a/'.startsWith(re);
});
if (!startsWithSupportsSymbolMatch) {
overrideNative(String.prototype, 'startsWith', StringPrototypeShims.startsWith);
}
var endsWithSupportsSymbolMatch = valueOrFalseIfThrows(function () {
var re = /a/;
re[Symbol.match] = false;
return '/a/'.endsWith(re);
});
if (!endsWithSupportsSymbolMatch) {
overrideNative(String.prototype, 'endsWith', StringPrototypeShims.endsWith);
}
var includesSupportsSymbolMatch = valueOrFalseIfThrows(function () {
var re = /a/;
re[Symbol.match] = false;
return '/a/'.includes(re);
});
if (!includesSupportsSymbolMatch) {
overrideNative(String.prototype, 'includes', StringPrototypeShims.includes);
}
}
defineProperties(String.prototype, StringPrototypeShims);
// whitespace from: http://es5.github.io/#x15.5.4.20
// implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324
var ws = [
'\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003',
'\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028',
'\u2029\uFEFF'
].join('');
var trimRegexp = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
var trimShim = function trim() {
return ES.ToString(ES.RequireObjectCoercible(this)).replace(trimRegexp, '');
};
var nonWS = ['\u0085', '\u200b', '\ufffe'].join('');
var nonWSregex = new RegExp('[' + nonWS + ']', 'g');
var isBadHexRegex = /^[-+]0x[0-9a-f]+$/i;
var hasStringTrimBug = nonWS.trim().length !== nonWS.length;
defineProperty(String.prototype, 'trim', trimShim, hasStringTrimBug);
// Given an argument x, it will return an IteratorResult object,
// with value set to x and done to false.
// Given no arguments, it will return an iterator completion object.
var iteratorResult = function (x) {
return { value: x, done: arguments.length === 0 };
};
// see http://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype-@@iterator
var StringIterator = function (s) {
ES.RequireObjectCoercible(s);
this._s = ES.ToString(s);
this._i = 0;
};
StringIterator.prototype.next = function () {
var s = this._s;
var i = this._i;
if (typeof s === 'undefined' || i >= s.length) {
this._s = void 0;
return iteratorResult();
}
var first = s.charCodeAt(i);
var second, len;
if (first < 0xD800 || first > 0xDBFF || (i + 1) === s.length) {
len = 1;
} else {
second = s.charCodeAt(i + 1);
len = (second < 0xDC00 || second > 0xDFFF) ? 1 : 2;
}
this._i = i + len;
return iteratorResult(s.substr(i, len));
};
addIterator(StringIterator.prototype);
addIterator(String.prototype, function () {
return new StringIterator(this);
});
var ArrayShims = {
from: function from(items) {
var C = this;
var mapFn;
if (arguments.length > 1) {
mapFn = arguments[1];
}
var mapping, T;
if (typeof mapFn === 'undefined') {
mapping = false;
} else {
if (!ES.IsCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
mapping = true;
}
// Note that that Arrays will use ArrayIterator:
// https://bugs.ecmascript.org/show_bug.cgi?id=2416
var usingIterator = typeof (isArguments(items) || ES.GetMethod(items, $iterator$)) !== 'undefined';
var length, result, i;
if (usingIterator) {
result = ES.IsConstructor(C) ? Object(new C()) : [];
var iterator = ES.GetIterator(items);
var next, nextValue;
i = 0;
while (true) {
next = ES.IteratorStep(iterator);
if (next === false) {
break;
}
nextValue = next.value;
try {
if (mapping) {
nextValue = typeof T === 'undefined' ? mapFn(nextValue, i) : _call(mapFn, T, nextValue, i);
}
result[i] = nextValue;
} catch (e) {
ES.IteratorClose(iterator, true);
throw e;
}
i += 1;
}
length = i;
} else {
var arrayLike = ES.ToObject(items);
length = ES.ToLength(arrayLike.length);
result = ES.IsConstructor(C) ? Object(new C(length)) : new Array(length);
var value;
for (i = 0; i < length; ++i) {
value = arrayLike[i];
if (mapping) {
value = typeof T === 'undefined' ? mapFn(value, i) : _call(mapFn, T, value, i);
}
createDataPropertyOrThrow(result, i, value);
}
}
result.length = length;
return result;
},
of: function of() {
var len = arguments.length;
var C = this;
var A = isArray(C) || !ES.IsCallable(C) ? new Array(len) : ES.Construct(C, [len]);
for (var k = 0; k < len; ++k) {
createDataPropertyOrThrow(A, k, arguments[k]);
}
A.length = len;
return A;
}
};
defineProperties(Array, ArrayShims);
addDefaultSpecies(Array);
// Our ArrayIterator is private; see
// https://github.com/paulmillr/es6-shim/issues/252
ArrayIterator = function (array, kind) {
this.i = 0;
this.array = array;
this.kind = kind;
};
defineProperties(ArrayIterator.prototype, {
next: function () {
var i = this.i;
var array = this.array;
if (!(this instanceof ArrayIterator)) {
throw new TypeError('Not an ArrayIterator');
}
if (typeof array !== 'undefined') {
var len = ES.ToLength(array.length);
for (; i < len; i++) {
var kind = this.kind;
var retval;
if (kind === 'key') {
retval = i;
} else if (kind === 'value') {
retval = array[i];
} else if (kind === 'entry') {
retval = [i, array[i]];
}
this.i = i + 1;
return iteratorResult(retval);
}
}
this.array = void 0;
return iteratorResult();
}
});
addIterator(ArrayIterator.prototype);
/*
var orderKeys = function orderKeys(a, b) {
var aNumeric = String(ES.ToInteger(a)) === a;
var bNumeric = String(ES.ToInteger(b)) === b;
if (aNumeric && bNumeric) {
return b - a;
} else if (aNumeric && !bNumeric) {
return -1;
} else if (!aNumeric && bNumeric) {
return 1;
} else {
return a.localeCompare(b);
}
};
var getAllKeys = function getAllKeys(object) {
var ownKeys = [];
var keys = [];
for (var key in object) {
_push(_hasOwnProperty(object, key) ? ownKeys : keys, key);
}
_sort(ownKeys, orderKeys);
_sort(keys, orderKeys);
return _concat(ownKeys, keys);
};
*/
// note: this is positioned here because it depends on ArrayIterator
var arrayOfSupportsSubclassing = Array.of === ArrayShims.of || (function () {
// Detects a bug in Webkit nightly r181886
var Foo = function Foo(len) { this.length = len; };
Foo.prototype = [];
var fooArr = Array.of.apply(Foo, [1, 2]);
return fooArr instanceof Foo && fooArr.length === 2;
}());
if (!arrayOfSupportsSubclassing) {
overrideNative(Array, 'of', ArrayShims.of);
}
var ArrayPrototypeShims = {
copyWithin: function copyWithin(target, start) {
var o = ES.ToObject(this);
var len = ES.ToLength(o.length);
var relativeTarget = ES.ToInteger(target);
var relativeStart = ES.ToInteger(start);
var to = relativeTarget < 0 ? _max(len + relativeTarget, 0) : _min(relativeTarget, len);
var from = relativeStart < 0 ? _max(len + relativeStart, 0) : _min(relativeStart, len);
var end;
if (arguments.length > 2) {
end = arguments[2];
}
var relativeEnd = typeof end === 'undefined' ? len : ES.ToInteger(end);
var finalItem = relativeEnd < 0 ? _max(len + relativeEnd, 0) : _min(relativeEnd, len);
var count = _min(finalItem - from, len - to);
var direction = 1;
if (from < to && to < (from + count)) {
direction = -1;
from += count - 1;
to += count - 1;
}
while (count > 0) {
if (from in o) {
o[to] = o[from];
} else {
delete o[to];
}
from += direction;
to += direction;
count -= 1;
}
return o;
},
fill: function fill(value) {
var start;
if (arguments.length > 1) {
start = arguments[1];
}
var end;
if (arguments.length > 2) {
end = arguments[2];
}
var O = ES.ToObject(this);
var len = ES.ToLength(O.length);
start = ES.ToInteger(typeof start === 'undefined' ? 0 : start);
end = ES.ToInteger(typeof end === 'undefined' ? len : end);
var relativeStart = start < 0 ? _max(len + start, 0) : _min(start, len);
var relativeEnd = end < 0 ? len + end : end;
for (var i = relativeStart; i < len && i < relativeEnd; ++i) {
O[i] = value;
}
return O;
},
find: function find(predicate) {
var list = ES.ToObject(this);
var length = ES.ToLength(list.length);
if (!ES.IsCallable(predicate)) {
throw new TypeError('Array#find: predicate must be a function');
}
var thisArg = arguments.length > 1 ? arguments[1] : null;
for (var i = 0, value; i < length; i++) {
value = list[i];
if (thisArg) {
if (_call(predicate, thisArg, value, i, list)) {
return value;
}
} else if (predicate(value, i, list)) {
return value;
}
}
},
findIndex: function findIndex(predicate) {
var list = ES.ToObject(this);
var length = ES.ToLength(list.length);
if (!ES.IsCallable(predicate)) {
throw new TypeError('Array#findIndex: predicate must be a function');
}
var thisArg = arguments.length > 1 ? arguments[1] : null;
for (var i = 0; i < length; i++) {
if (thisArg) {
if (_call(predicate, thisArg, list[i], i, list)) {
return i;
}
} else if (predicate(list[i], i, list)) {
return i;
}
}
return -1;
},
keys: function keys() {
return new ArrayIterator(this, 'key');
},
values: function values() {
return new ArrayIterator(this, 'value');
},
entries: function entries() {
return new ArrayIterator(this, 'entry');
}
};
// Safari 7.1 defines Array#keys and Array#entries natively,
// but the resulting ArrayIterator objects don't have a "next" method.
if (Array.prototype.keys && !ES.IsCallable([1].keys().next)) {
delete Array.prototype.keys;
}
if (Array.prototype.entries && !ES.IsCallable([1].entries().next)) {
delete Array.prototype.entries;
}
// Chrome 38 defines Array#keys and Array#entries, and Array#@@iterator, but not Array#values
if (Array.prototype.keys && Array.prototype.entries && !Array.prototype.values && Array.prototype[$iterator$]) {
defineProperties(Array.prototype, {
values: Array.prototype[$iterator$]
});
if (Type.symbol(Symbol.unscopables)) {
Array.prototype[Symbol.unscopables].values = true;
}
}
// Chrome 40 defines Array#values with the incorrect name, although Array#{keys,entries} have the correct name
if (functionsHaveNames && Array.prototype.values && Array.prototype.values.name !== 'values') {
var originalArrayPrototypeValues = Array.prototype.values;
overrideNative(Array.prototype, 'values', function values() { return ES.Call(originalArrayPrototypeValues, this, arguments); });
defineProperty(Array.prototype, $iterator$, Array.prototype.values, true);
}
defineProperties(Array.prototype, ArrayPrototypeShims);
if (1 / [true].indexOf(true, -0) < 0) {
// indexOf when given a position arg of -0 should return +0.
// https://github.com/tc39/ecma262/pull/316
defineProperty(Array.prototype, 'indexOf', function indexOf(searchElement) {
var value = _arrayIndexOfApply(this, arguments);
if (value === 0 && (1 / value) < 0) {
return 0;
}
return value;
}, true);
}
addIterator(Array.prototype, function () { return this.values(); });
// Chrome defines keys/values/entries on Array, but doesn't give us
// any way to identify its iterator. So add our own shimmed field.
if (Object.getPrototypeOf) {
addIterator(Object.getPrototypeOf([].values()));
}
// note: this is positioned here because it relies on Array#entries
var arrayFromSwallowsNegativeLengths = (function () {
// Detects a Firefox bug in v32
// https://bugzilla.mozilla.org/show_bug.cgi?id=1063993
return valueOrFalseIfThrows(function () {
return Array.from({ length: -1 }).length === 0;
});
}());
var arrayFromHandlesIterables = (function () {
// Detects a bug in Webkit nightly r181886
var arr = Array.from([0].entries());
return arr.length === 1 && isArray(arr[0]) && arr[0][0] === 0 && arr[0][1] === 0;
}());
if (!arrayFromSwallowsNegativeLengths || !arrayFromHandlesIterables) {
overrideNative(Array, 'from', ArrayShims.from);
}
var arrayFromHandlesUndefinedMapFunction = (function () {
// Microsoft Edge v0.11 throws if the mapFn argument is *provided* but undefined,
// but the spec doesn't care if it's provided or not - undefined doesn't throw.
return valueOrFalseIfThrows(function () {
return Array.from([0], void 0);
});
}());
if (!arrayFromHandlesUndefinedMapFunction) {
var origArrayFrom = Array.from;
overrideNative(Array, 'from', function from(items) {
if (arguments.length > 1 && typeof arguments[1] !== 'undefined') {
return ES.Call(origArrayFrom, this, arguments);
} else {
return _call(origArrayFrom, this, items);
}
});
}
var int32sAsOne = -(Math.pow(2, 32) - 1);
var toLengthsCorrectly = function (method, reversed) {
var obj = { length: int32sAsOne };
obj[reversed ? (obj.length >>> 0) - 1 : 0] = true;
return valueOrFalseIfThrows(function () {
_call(method, obj, function () {
// note: in nonconforming browsers, this will be called
// -1 >>> 0 times, which is 4294967295, so the throw matters.
throw new RangeError('should not reach here');
}, []);
return true;
});
};
if (!toLengthsCorrectly(Array.prototype.forEach)) {
var originalForEach = Array.prototype.forEach;
overrideNative(Array.prototype, 'forEach', function forEach(callbackFn) {
return ES.Call(originalForEach, this.length >= 0 ? this : [], arguments);
}, true);
}
if (!toLengthsCorrectly(Array.prototype.map)) {
var originalMap = Array.prototype.map;
overrideNative(Array.prototype, 'map', function map(callbackFn) {
return ES.Call(originalMap, this.length >= 0 ? this : [], arguments);
}, true);
}
if (!toLengthsCorrectly(Array.prototype.filter)) {
var originalFilter = Array.prototype.filter;
overrideNative(Array.prototype, 'filter', function filter(callbackFn) {
return ES.Call(originalFilter, this.length >= 0 ? this : [], arguments);
}, true);
}
if (!toLengthsCorrectly(Array.prototype.some)) {
var originalSome = Array.prototype.some;
overrideNative(Array.prototype, 'some', function some(callbackFn) {
return ES.Call(originalSome, this.length >= 0 ? this : [], arguments);
}, true);
}
if (!toLengthsCorrectly(Array.prototype.every)) {
var originalEvery = Array.prototype.every;
overrideNative(Array.prototype, 'every', function every(callbackFn) {
return ES.Call(originalEvery, this.length >= 0 ? this : [], arguments);
}, true);
}
if (!toLengthsCorrectly(Array.prototype.reduce)) {
var originalReduce = Array.prototype.reduce;
overrideNative(Array.prototype, 'reduce', function reduce(callbackFn) {
return ES.Call(originalReduce, this.length >= 0 ? this : [], arguments);
}, true);
}
if (!toLengthsCorrectly(Array.prototype.reduceRight, true)) {
var originalReduceRight = Array.prototype.reduceRight;
overrideNative(Array.prototype, 'reduceRight', function reduceRight(callbackFn) {
return ES.Call(originalReduceRight, this.length >= 0 ? this : [], arguments);
}, true);
}
var lacksOctalSupport = Number('0o10') !== 8;
var lacksBinarySupport = Number('0b10') !== 2;
var trimsNonWhitespace = _some(nonWS, function (c) {
return Number(c + 0 + c) === 0;
});
if (lacksOctalSupport || lacksBinarySupport || trimsNonWhitespace) {
var OrigNumber = Number;
var binaryRegex = /^0b[01]+$/i;
var octalRegex = /^0o[0-7]+$/i;
// Note that in IE 8, RegExp.prototype.test doesn't seem to exist: ie, "test" is an own property of regexes. wtf.
var isBinary = binaryRegex.test.bind(binaryRegex);
var isOctal = octalRegex.test.bind(octalRegex);
var toPrimitive = function (O) { // need to replace this with `es-to-primitive/es6`
var result;
if (typeof O.valueOf === 'function') {
result = O.valueOf();
if (Type.primitive(result)) {
return result;
}
}
if (typeof O.toString === 'function') {
result = O.toString();
if (Type.primitive(result)) {
return result;
}
}
throw new TypeError('No default value');
};
var hasNonWS = nonWSregex.test.bind(nonWSregex);
var isBadHex = isBadHexRegex.test.bind(isBadHexRegex);
var NumberShim = (function () {
// this is wrapped in an IIFE because of IE 6-8's wacky scoping issues with named function expressions.
var NumberShim = function Number(value) {
var primValue;
if (arguments.length > 0) {
primValue = Type.primitive(value) ? value : toPrimitive(value, 'number');
} else {
primValue = 0;
}
if (typeof primValue === 'string') {
primValue = ES.Call(trimShim, primValue);
if (isBinary(primValue)) {
primValue = parseInt(_strSlice(primValue, 2), 2);
} else if (isOctal(primValue)) {
primValue = parseInt(_strSlice(primValue, 2), 8);
} else if (hasNonWS(primValue) || isBadHex(primValue)) {
primValue = NaN;
}
}
var receiver = this;
var valueOfSucceeds = valueOrFalseIfThrows(function () {
OrigNumber.prototype.valueOf.call(receiver);
return true;
});
if (receiver instanceof NumberShim && !valueOfSucceeds) {
return new OrigNumber(primValue);
}
/* jshint newcap: false */
return OrigNumber(primValue);
/* jshint newcap: true */
};
return NumberShim;
}());
wrapConstructor(OrigNumber, NumberShim, {});
// this is necessary for ES3 browsers, where these properties are non-enumerable.
defineProperties(NumberShim, {
NaN: OrigNumber.NaN,
MAX_VALUE: OrigNumber.MAX_VALUE,
MIN_VALUE: OrigNumber.MIN_VALUE,
NEGATIVE_INFINITY: OrigNumber.NEGATIVE_INFINITY,
POSITIVE_INFINITY: OrigNumber.POSITIVE_INFINITY
});
/* globals Number: true */
/* eslint-disable no-undef, no-global-assign */
/* jshint -W020 */
Number = NumberShim;
Value.redefine(globals, 'Number', NumberShim);
/* jshint +W020 */
/* eslint-enable no-undef, no-global-assign */
/* globals Number: false */
}
var maxSafeInteger = Math.pow(2, 53) - 1;
defineProperties(Number, {
MAX_SAFE_INTEGER: maxSafeInteger,
MIN_SAFE_INTEGER: -maxSafeInteger,
EPSILON: 2.220446049250313e-16,
parseInt: globals.parseInt,
parseFloat: globals.parseFloat,
isFinite: numberIsFinite,
isInteger: function isInteger(value) {
return numberIsFinite(value) && ES.ToInteger(value) === value;
},
isSafeInteger: function isSafeInteger(value) {
return Number.isInteger(value) && _abs(value) <= Number.MAX_SAFE_INTEGER;
},
isNaN: numberIsNaN
});
// Firefox 37 has a conforming Number.parseInt, but it's not === to the global parseInt (fixed in v40)
defineProperty(Number, 'parseInt', globals.parseInt, Number.parseInt !== globals.parseInt);
// Work around bugs in Array#find and Array#findIndex -- early
// implementations skipped holes in sparse arrays. (Note that the
// implementations of find/findIndex indirectly use shimmed
// methods of Number, so this test has to happen down here.)
/*jshint elision: true */
/* eslint-disable no-sparse-arrays */
if ([, 1].find(function () { return true; }) === 1) {
overrideNative(Array.prototype, 'find', ArrayPrototypeShims.find);
}
if ([, 1].findIndex(function () { return true; }) !== 0) {
overrideNative(Array.prototype, 'findIndex', ArrayPrototypeShims.findIndex);
}
/* eslint-enable no-sparse-arrays */
/*jshint elision: false */
var isEnumerableOn = Function.bind.call(Function.bind, Object.prototype.propertyIsEnumerable);
var ensureEnumerable = function ensureEnumerable(obj, prop) {
if (supportsDescriptors && isEnumerableOn(obj, prop)) {
Object.defineProperty(obj, prop, { enumerable: false });
}
};
var sliceArgs = function sliceArgs() {
// per https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments
// and https://gist.github.com/WebReflection/4327762cb87a8c634a29
var initial = Number(this);
var len = arguments.length;
var desiredArgCount = len - initial;
var args = new Array(desiredArgCount < 0 ? 0 : desiredArgCount);
for (var i = initial; i < len; ++i) {
args[i - initial] = arguments[i];
}
return args;
};
var assignTo = function assignTo(source) {
return function assignToSource(target, key) {
target[key] = source[key];
return target;
};
};
var assignReducer = function (target, source) {
var sourceKeys = keys(Object(source));
var symbols;
if (ES.IsCallable(Object.getOwnPropertySymbols)) {
symbols = _filter(Object.getOwnPropertySymbols(Object(source)), isEnumerableOn(source));
}
return _reduce(_concat(sourceKeys, symbols || []), assignTo(source), target);
};
var ObjectShims = {
// 19.1.3.1
assign: function (target, source) {
var to = ES.ToObject(target, 'Cannot convert undefined or null to object');
return _reduce(ES.Call(sliceArgs, 1, arguments), assignReducer, to);
},
// Added in WebKit in https://bugs.webkit.org/show_bug.cgi?id=143865
is: function is(a, b) {
return ES.SameValue(a, b);
}
};
var assignHasPendingExceptions = Object.assign && Object.preventExtensions && (function () {
// Firefox 37 still has "pending exception" logic in its Object.assign implementation,
// which is 72% slower than our shim, and Firefox 40's native implementation.
var thrower = Object.preventExtensions({ 1: 2 });
try {
Object.assign(thrower, 'xy');
} catch (e) {
return thrower[1] === 'y';
}
}());
if (assignHasPendingExceptions) {
overrideNative(Object, 'assign', ObjectShims.assign);
}
defineProperties(Object, ObjectShims);
if (supportsDescriptors) {
var ES5ObjectShims = {
// 19.1.3.9
// shim from https://gist.github.com/WebReflection/5593554
setPrototypeOf: (function (Object, magic) {
var set;
var checkArgs = function (O, proto) {
if (!ES.TypeIsObject(O)) {
throw new TypeError('cannot set prototype on a non-object');
}
if (!(proto === null || ES.TypeIsObject(proto))) {
throw new TypeError('can only set prototype to an object or null' + proto);
}
};
var setPrototypeOf = function (O, proto) {
checkArgs(O, proto);
_call(set, O, proto);
return O;
};
try {
// this works already in Firefox and Safari
set = Object.getOwnPropertyDescriptor(Object.prototype, magic).set;
_call(set, {}, null);
} catch (e) {
if (Object.prototype !== {}[magic]) {
// IE < 11 cannot be shimmed
return;
}
// probably Chrome or some old Mobile stock browser
set = function (proto) {
this[magic] = proto;
};
// please note that this will **not** work
// in those browsers that do not inherit
// __proto__ by mistake from Object.prototype
// in these cases we should probably throw an error
// or at least be informed about the issue
setPrototypeOf.polyfill = setPrototypeOf(
setPrototypeOf({}, null),
Object.prototype
) instanceof Object;
// setPrototypeOf.polyfill === true means it works as meant
// setPrototypeOf.polyfill === false means it's not 100% reliable
// setPrototypeOf.polyfill === undefined
// or
// setPrototypeOf.polyfill == null means it's not a polyfill
// which means it works as expected
// we can even delete Object.prototype.__proto__;
}
return setPrototypeOf;
}(Object, '__proto__'))
};
defineProperties(Object, ES5ObjectShims);
}
// Workaround bug in Opera 12 where setPrototypeOf(x, null) doesn't work,
// but Object.create(null) does.
if (Object.setPrototypeOf && Object.getPrototypeOf &&
Object.getPrototypeOf(Object.setPrototypeOf({}, null)) !== null &&
Object.getPrototypeOf(Object.create(null)) === null) {
(function () {
var FAKENULL = Object.create(null);
var gpo = Object.getPrototypeOf;
var spo = Object.setPrototypeOf;
Object.getPrototypeOf = function (o) {
var result = gpo(o);
return result === FAKENULL ? null : result;
};
Object.setPrototypeOf = function (o, p) {
var proto = p === null ? FAKENULL : p;
return spo(o, proto);
};
Object.setPrototypeOf.polyfill = false;
}());
}
var objectKeysAcceptsPrimitives = !throwsError(function () { Object.keys('foo'); });
if (!objectKeysAcceptsPrimitives) {
var originalObjectKeys = Object.keys;
overrideNative(Object, 'keys', function keys(value) {
return originalObjectKeys(ES.ToObject(value));
});
keys = Object.keys;
}
var objectKeysRejectsRegex = throwsError(function () { Object.keys(/a/g); });
if (objectKeysRejectsRegex) {
var regexRejectingObjectKeys = Object.keys;
overrideNative(Object, 'keys', function keys(value) {
if (Type.regex(value)) {
var regexKeys = [];
for (var k in value) {
if (_hasOwnProperty(value, k)) {
_push(regexKeys, k);
}
}
return regexKeys;
}
return regexRejectingObjectKeys(value);
});
keys = Object.keys;
}
if (Object.getOwnPropertyNames) {
var objectGOPNAcceptsPrimitives = !throwsError(function () { Object.getOwnPropertyNames('foo'); });
if (!objectGOPNAcceptsPrimitives) {
var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : [];
var originalObjectGetOwnPropertyNames = Object.getOwnPropertyNames;
overrideNative(Object, 'getOwnPropertyNames', function getOwnPropertyNames(value) {
var val = ES.ToObject(value);
if (_toString(val) === '[object Window]') {
try {
return originalObjectGetOwnPropertyNames(val);
} catch (e) {
// IE bug where layout engine calls userland gOPN for cross-domain `window` objects
return _concat([], cachedWindowNames);
}
}
return originalObjectGetOwnPropertyNames(val);
});
}
}
if (Object.getOwnPropertyDescriptor) {
var objectGOPDAcceptsPrimitives = !throwsError(function () { Object.getOwnPropertyDescriptor('foo', 'bar'); });
if (!objectGOPDAcceptsPrimitives) {
var originalObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
overrideNative(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(value, property) {
return originalObjectGetOwnPropertyDescriptor(ES.ToObject(value), property);
});
}
}
if (Object.seal) {
var objectSealAcceptsPrimitives = !throwsError(function () { Object.seal('foo'); });
if (!objectSealAcceptsPrimitives) {
var originalObjectSeal = Object.seal;
overrideNative(Object, 'seal', function seal(value) {
if (!ES.TypeIsObject(value)) { return value; }
return originalObjectSeal(value);
});
}
}
if (Object.isSealed) {
var objectIsSealedAcceptsPrimitives = !throwsError(function () { Object.isSealed('foo'); });
if (!objectIsSealedAcceptsPrimitives) {
var originalObjectIsSealed = Object.isSealed;
overrideNative(Object, 'isSealed', function isSealed(value) {
if (!ES.TypeIsObject(value)) { return true; }
return originalObjectIsSealed(value);
});
}
}
if (Object.freeze) {
var objectFreezeAcceptsPrimitives = !throwsError(function () { Object.freeze('foo'); });
if (!objectFreezeAcceptsPrimitives) {
var originalObjectFreeze = Object.freeze;
overrideNative(Object, 'freeze', function freeze(value) {
if (!ES.TypeIsObject(value)) { return value; }
return originalObjectFreeze(value);
});
}
}
if (Object.isFrozen) {
var objectIsFrozenAcceptsPrimitives = !throwsError(function () { Object.isFrozen('foo'); });
if (!objectIsFrozenAcceptsPrimitives) {
var originalObjectIsFrozen = Object.isFrozen;
overrideNative(Object, 'isFrozen', function isFrozen(value) {
if (!ES.TypeIsObject(value)) { return true; }
return originalObjectIsFrozen(value);
});
}
}
if (Object.preventExtensions) {
var objectPreventExtensionsAcceptsPrimitives = !throwsError(function () { Object.preventExtensions('foo'); });
if (!objectPreventExtensionsAcceptsPrimitives) {
var originalObjectPreventExtensions = Object.preventExtensions;
overrideNative(Object, 'preventExtensions', function preventExtensions(value) {
if (!ES.TypeIsObject(value)) { return value; }
return originalObjectPreventExtensions(value);
});
}
}
if (Object.isExtensible) {
var objectIsExtensibleAcceptsPrimitives = !throwsError(function () { Object.isExtensible('foo'); });
if (!objectIsExtensibleAcceptsPrimitives) {
var originalObjectIsExtensible = Object.isExtensible;
overrideNative(Object, 'isExtensible', function isExtensible(value) {
if (!ES.TypeIsObject(value)) { return false; }
return originalObjectIsExtensible(value);
});
}
}
if (Object.getPrototypeOf) {
var objectGetProtoAcceptsPrimitives = !throwsError(function () { Object.getPrototypeOf('foo'); });
if (!objectGetProtoAcceptsPrimitives) {
var originalGetProto = Object.getPrototypeOf;
overrideNative(Object, 'getPrototypeOf', function getPrototypeOf(value) {
return originalGetProto(ES.ToObject(value));
});
}
}
var hasFlags = supportsDescriptors && (function () {
var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags');
return desc && ES.IsCallable(desc.get);
}());
if (supportsDescriptors && !hasFlags) {
var regExpFlagsGetter = function flags() {
if (!ES.TypeIsObject(this)) {
throw new TypeError('Method called on incompatible type: must be an object.');
}
var result = '';
if (this.global) {
result += 'g';
}
if (this.ignoreCase) {
result += 'i';
}
if (this.multiline) {
result += 'm';
}
if (this.unicode) {
result += 'u';
}
if (this.sticky) {
result += 'y';
}
return result;
};
Value.getter(RegExp.prototype, 'flags', regExpFlagsGetter);
}
var regExpSupportsFlagsWithRegex = supportsDescriptors && valueOrFalseIfThrows(function () {
return String(new RegExp(/a/g, 'i')) === '/a/i';
});
var regExpNeedsToSupportSymbolMatch = hasSymbols && supportsDescriptors && (function () {
// Edge 0.12 supports flags fully, but does not support Symbol.match
var regex = /./;
regex[Symbol.match] = false;
return RegExp(regex) === regex;
}());
var regexToStringIsGeneric = valueOrFalseIfThrows(function () {
return RegExp.prototype.toString.call({ source: 'abc' }) === '/abc/';
});
var regexToStringSupportsGenericFlags = regexToStringIsGeneric && valueOrFalseIfThrows(function () {
return RegExp.prototype.toString.call({ source: 'a', flags: 'b' }) === '/a/b';
});
if (!regexToStringIsGeneric || !regexToStringSupportsGenericFlags) {
var origRegExpToString = RegExp.prototype.toString;
defineProperty(RegExp.prototype, 'toString', function toString() {
var R = ES.RequireObjectCoercible(this);
if (Type.regex(R)) {
return _call(origRegExpToString, R);
}
var pattern = $String(R.source);
var flags = $String(R.flags);
return '/' + pattern + '/' + flags;
}, true);
Value.preserveToString(RegExp.prototype.toString, origRegExpToString);
}
if (supportsDescriptors && (!regExpSupportsFlagsWithRegex || regExpNeedsToSupportSymbolMatch)) {
var flagsGetter = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get;
var sourceDesc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source') || {};
var legacySourceGetter = function () {
// prior to it being a getter, it's own + nonconfigurable
return this.source;
};
var sourceGetter = ES.IsCallable(sourceDesc.get) ? sourceDesc.get : legacySourceGetter;
var OrigRegExp = RegExp;
var RegExpShim = (function () {
return function RegExp(pattern, flags) {
var patternIsRegExp = ES.IsRegExp(pattern);
var calledWithNew = this instanceof RegExp;
if (!calledWithNew && patternIsRegExp && typeof flags === 'undefined' && pattern.constructor === RegExp) {
return pattern;
}
var P = pattern;
var F = flags;
if (Type.regex(pattern)) {
P = ES.Call(sourceGetter, pattern);
F = typeof flags === 'undefined' ? ES.Call(flagsGetter, pattern) : flags;
return new RegExp(P, F);
} else if (patternIsRegExp) {
P = pattern.source;
F = typeof flags === 'undefined' ? pattern.flags : flags;
}
return new OrigRegExp(pattern, flags);
};
}());
wrapConstructor(OrigRegExp, RegExpShim, {
$input: true // Chrome < v39 & Opera < 26 have a nonstandard "$input" property
});
/* globals RegExp: true */
/* eslint-disable no-undef, no-global-assign */
/* jshint -W020 */
RegExp = RegExpShim;
Value.redefine(globals, 'RegExp', RegExpShim);
/* jshint +W020 */
/* eslint-enable no-undef, no-global-assign */
/* globals RegExp: false */
}
if (supportsDescriptors) {
var regexGlobals = {
input: '$_',
lastMatch: '$&',
lastParen: '$+',
leftContext: '$`',
rightContext: '$\''
};
_forEach(keys(regexGlobals), function (prop) {
if (prop in RegExp && !(regexGlobals[prop] in RegExp)) {
Value.getter(RegExp, regexGlobals[prop], function get() {
return RegExp[prop];
});
}
});
}
addDefaultSpecies(RegExp);
var inverseEpsilon = 1 / Number.EPSILON;
var roundTiesToEven = function roundTiesToEven(n) {
// Even though this reduces down to `return n`, it takes advantage of built-in rounding.
return (n + inverseEpsilon) - inverseEpsilon;
};
var BINARY_32_EPSILON = Math.pow(2, -23);
var BINARY_32_MAX_VALUE = Math.pow(2, 127) * (2 - BINARY_32_EPSILON);
var BINARY_32_MIN_VALUE = Math.pow(2, -126);
var E = Math.E;
var LOG2E = Math.LOG2E;
var LOG10E = Math.LOG10E;
var numberCLZ = Number.prototype.clz;
delete Number.prototype.clz; // Safari 8 has Number#clz
var MathShims = {
acosh: function acosh(value) {
var x = Number(value);
if (numberIsNaN(x) || value < 1) { return NaN; }
if (x === 1) { return 0; }
if (x === Infinity) { return x; }
return _log((x / E) + (_sqrt(x + 1) * _sqrt(x - 1) / E)) + 1;
},
asinh: function asinh(value) {
var x = Number(value);
if (x === 0 || !globalIsFinite(x)) {
return x;
}
return x < 0 ? -asinh(-x) : _log(x + _sqrt((x * x) + 1));
},
atanh: function atanh(value) {
var x = Number(value);
if (numberIsNaN(x) || x < -1 || x > 1) {
return NaN;
}
if (x === -1) { return -Infinity; }
if (x === 1) { return Infinity; }
if (x === 0) { return x; }
return 0.5 * _log((1 + x) / (1 - x));
},
cbrt: function cbrt(value) {
var x = Number(value);
if (x === 0) { return x; }
var negate = x < 0;
var result;
if (negate) { x = -x; }
if (x === Infinity) {
result = Infinity;
} else {
result = _exp(_log(x) / 3);
// from http://en.wikipedia.org/wiki/Cube_root#Numerical_methods
result = ((x / (result * result)) + (2 * result)) / 3;
}
return negate ? -result : result;
},
clz32: function clz32(value) {
// See https://bugs.ecmascript.org/show_bug.cgi?id=2465
var x = Number(value);
var number = ES.ToUint32(x);
if (number === 0) {
return 32;
}
return numberCLZ ? ES.Call(numberCLZ, number) : 31 - _floor(_log(number + 0.5) * LOG2E);
},
cosh: function cosh(value) {
var x = Number(value);
if (x === 0) { return 1; } // +0 or -0
if (numberIsNaN(x)) { return NaN; }
if (!globalIsFinite(x)) { return Infinity; }
if (x < 0) { x = -x; }
if (x > 21) { return _exp(x) / 2; }
return (_exp(x) + _exp(-x)) / 2;
},
expm1: function expm1(value) {
var x = Number(value);
if (x === -Infinity) { return -1; }
if (!globalIsFinite(x) || x === 0) { return x; }
if (_abs(x) > 0.5) {
return _exp(x) - 1;
}
// A more precise approximation using Taylor series expansion
// from https://github.com/paulmillr/es6-shim/issues/314#issuecomment-70293986
var t = x;
var sum = 0;
var n = 1;
while (sum + t !== sum) {
sum += t;
n += 1;
t *= x / n;
}
return sum;
},
hypot: function hypot(x, y) {
var result = 0;
var largest = 0;
for (var i = 0; i < arguments.length; ++i) {
var value = _abs(Number(arguments[i]));
if (largest < value) {
result *= (largest / value) * (largest / value);
result += 1;
largest = value;
} else {
result += value > 0 ? (value / largest) * (value / largest) : value;
}
}
return largest === Infinity ? Infinity : largest * _sqrt(result);
},
log2: function log2(value) {
return _log(value) * LOG2E;
},
log10: function log10(value) {
return _log(value) * LOG10E;
},
log1p: function log1p(value) {
var x = Number(value);
if (x < -1 || numberIsNaN(x)) { return NaN; }
if (x === 0 || x === Infinity) { return x; }
if (x === -1) { return -Infinity; }
return (1 + x) - 1 === 0 ? x : x * (_log(1 + x) / ((1 + x) - 1));
},
sign: _sign,
sinh: function sinh(value) {
var x = Number(value);
if (!globalIsFinite(x) || x === 0) { return x; }
if (_abs(x) < 1) {
return (Math.expm1(x) - Math.expm1(-x)) / 2;
}
return (_exp(x - 1) - _exp(-x - 1)) * E / 2;
},
tanh: function tanh(value) {
var x = Number(value);
if (numberIsNaN(x) || x === 0) { return x; }
// can exit early at +-20 as JS loses precision for true value at this integer
if (x >= 20) { return 1; }
if (x <= -20) { return -1; }
return (Math.expm1(x) - Math.expm1(-x)) / (_exp(x) + _exp(-x));
},
trunc: function trunc(value) {
var x = Number(value);
return x < 0 ? -_floor(-x) : _floor(x);
},
imul: function imul(x, y) {
// taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
var a = ES.ToUint32(x);
var b = ES.ToUint32(y);
var ah = (a >>> 16) & 0xffff;
var al = a & 0xffff;
var bh = (b >>> 16) & 0xffff;
var bl = b & 0xffff;
// the shift by 0 fixes the sign on the high part
// the final |0 converts the unsigned value into a signed value
return (al * bl) + ((((ah * bl) + (al * bh)) << 16) >>> 0) | 0;
},
fround: function fround(x) {
var v = Number(x);
if (v === 0 || v === Infinity || v === -Infinity || numberIsNaN(v)) {
return v;
}
var sign = _sign(v);
var abs = _abs(v);
if (abs < BINARY_32_MIN_VALUE) {
return sign * roundTiesToEven(
abs / BINARY_32_MIN_VALUE / BINARY_32_EPSILON
) * BINARY_32_MIN_VALUE * BINARY_32_EPSILON;
}
// Veltkamp's splitting (?)
var a = (1 + (BINARY_32_EPSILON / Number.EPSILON)) * abs;
var result = a - (a - abs);
if (result > BINARY_32_MAX_VALUE || numberIsNaN(result)) {
return sign * Infinity;
}
return sign * result;
}
};
defineProperties(Math, MathShims);
// IE 11 TP has an imprecise log1p: reports Math.log1p(-1e-17) as 0
defineProperty(Math, 'log1p', MathShims.log1p, Math.log1p(-1e-17) !== -1e-17);
// IE 11 TP has an imprecise asinh: reports Math.asinh(-1e7) as not exactly equal to -Math.asinh(1e7)
defineProperty(Math, 'asinh', MathShims.asinh, Math.asinh(-1e7) !== -Math.asinh(1e7));
// Chrome 40 has an imprecise Math.tanh with very small numbers
defineProperty(Math, 'tanh', MathShims.tanh, Math.tanh(-2e-17) !== -2e-17);
// Chrome 40 loses Math.acosh precision with high numbers
defineProperty(Math, 'acosh', MathShims.acosh, Math.acosh(Number.MAX_VALUE) === Infinity);
// Firefox 38 on Windows
defineProperty(Math, 'cbrt', MathShims.cbrt, Math.abs(1 - (Math.cbrt(1e-300) / 1e-100)) / Number.EPSILON > 8);
// node 0.11 has an imprecise Math.sinh with very small numbers
defineProperty(Math, 'sinh', MathShims.sinh, Math.sinh(-2e-17) !== -2e-17);
// FF 35 on Linux reports 22025.465794806725 for Math.expm1(10)
var expm1OfTen = Math.expm1(10);
defineProperty(Math, 'expm1', MathShims.expm1, expm1OfTen > 22025.465794806719 || expm1OfTen < 22025.4657948067165168);
var origMathRound = Math.round;
// breaks in e.g. Safari 8, Internet Explorer 11, Opera 12
var roundHandlesBoundaryConditions = Math.round(0.5 - (Number.EPSILON / 4)) === 0 &&
Math.round(-0.5 + (Number.EPSILON / 3.99)) === 1;
// When engines use Math.floor(x + 0.5) internally, Math.round can be buggy for large integers.
// This behavior should be governed by "round to nearest, ties to even mode"
// see http://www.ecma-international.org/ecma-262/6.0/#sec-terms-and-definitions-number-type
// These are the boundary cases where it breaks.
var smallestPositiveNumberWhereRoundBreaks = inverseEpsilon + 1;
var largestPositiveNumberWhereRoundBreaks = (2 * inverseEpsilon) - 1;
var roundDoesNotIncreaseIntegers = [
smallestPositiveNumberWhereRoundBreaks,
largestPositiveNumberWhereRoundBreaks
].every(function (num) {
return Math.round(num) === num;
});
defineProperty(Math, 'round', function round(x) {
var floor = _floor(x);
var ceil = floor === -1 ? -0 : floor + 1;
return x - floor < 0.5 ? floor : ceil;
}, !roundHandlesBoundaryConditions || !roundDoesNotIncreaseIntegers);
Value.preserveToString(Math.round, origMathRound);
var origImul = Math.imul;
if (Math.imul(0xffffffff, 5) !== -5) {
// Safari 6.1, at least, reports "0" for this value
Math.imul = MathShims.imul;
Value.preserveToString(Math.imul, origImul);
}
if (Math.imul.length !== 2) {
// Safari 8.0.4 has a length of 1
// fixed in https://bugs.webkit.org/show_bug.cgi?id=143658
overrideNative(Math, 'imul', function imul(x, y) {
return ES.Call(origImul, Math, arguments);
});
}
// Promises
// Simplest possible implementation; use a 3rd-party library if you
// want the best possible speed and/or long stack traces.
var PromiseShim = (function () {
var setTimeout = globals.setTimeout;
// some environments don't have setTimeout - no way to shim here.
if (typeof setTimeout !== 'function' && typeof setTimeout !== 'object') { return; }
ES.IsPromise = function (promise) {
if (!ES.TypeIsObject(promise)) {
return false;
}
if (typeof promise._promise === 'undefined') {
return false; // uninitialized, or missing our hidden field.
}
return true;
};
// "PromiseCapability" in the spec is what most promise implementations
// call a "deferred".
var PromiseCapability = function (C) {
if (!ES.IsConstructor(C)) {
throw new TypeError('Bad promise constructor');
}
var capability = this;
var resolver = function (resolve, reject) {
if (capability.resolve !== void 0 || capability.reject !== void 0) {
throw new TypeError('Bad Promise implementation!');
}
capability.resolve = resolve;
capability.reject = reject;
};
// Initialize fields to inform optimizers about the object shape.
capability.resolve = void 0;
capability.reject = void 0;
capability.promise = new C(resolver);
if (!(ES.IsCallable(capability.resolve) && ES.IsCallable(capability.reject))) {
throw new TypeError('Bad promise constructor');
}
};
// find an appropriate setImmediate-alike
var makeZeroTimeout;
/*global window */
if (typeof window !== 'undefined' && ES.IsCallable(window.postMessage)) {
makeZeroTimeout = function () {
// from http://dbaron.org/log/20100309-faster-timeouts
var timeouts = [];
var messageName = 'zero-timeout-message';
var setZeroTimeout = function (fn) {
_push(timeouts, fn);
window.postMessage(messageName, '*');
};
var handleMessage = function (event) {
if (event.source === window && event.data === messageName) {
event.stopPropagation();
if (timeouts.length === 0) { return; }
var fn = _shift(timeouts);
fn();
}
};
window.addEventListener('message', handleMessage, true);
return setZeroTimeout;
};
}
var makePromiseAsap = function () {
// An efficient task-scheduler based on a pre-existing Promise
// implementation, which we can use even if we override the
// global Promise below (in order to workaround bugs)
// https://github.com/Raynos/observ-hash/issues/2#issuecomment-35857671
var P = globals.Promise;
var pr = P && P.resolve && P.resolve();
return pr && function (task) {
return pr.then(task);
};
};
/*global process */
/* jscs:disable disallowMultiLineTernary */
var enqueue = ES.IsCallable(globals.setImmediate) ?
globals.setImmediate :
typeof process === 'object' && process.nextTick ? process.nextTick :
makePromiseAsap() ||
(ES.IsCallable(makeZeroTimeout) ? makeZeroTimeout() :
function (task) { setTimeout(task, 0); }); // fallback
/* jscs:enable disallowMultiLineTernary */
// Constants for Promise implementation
var PROMISE_IDENTITY = function (x) { return x; };
var PROMISE_THROWER = function (e) { throw e; };
var PROMISE_PENDING = 0;
var PROMISE_FULFILLED = 1;
var PROMISE_REJECTED = 2;
// We store fulfill/reject handlers and capabilities in a single array.
var PROMISE_FULFILL_OFFSET = 0;
var PROMISE_REJECT_OFFSET = 1;
var PROMISE_CAPABILITY_OFFSET = 2;
// This is used in an optimization for chaining promises via then.
var PROMISE_FAKE_CAPABILITY = {};
var enqueuePromiseReactionJob = function (handler, capability, argument) {
enqueue(function () {
promiseReactionJob(handler, capability, argument);
});
};
var promiseReactionJob = function (handler, promiseCapability, argument) {
var handlerResult, f;
if (promiseCapability === PROMISE_FAKE_CAPABILITY) {
// Fast case, when we don't actually need to chain through to a
// (real) promiseCapability.
return handler(argument);
}
try {
handlerResult = handler(argument);
f = promiseCapability.resolve;
} catch (e) {
handlerResult = e;
f = promiseCapability.reject;
}
f(handlerResult);
};
var fulfillPromise = function (promise, value) {
var _promise = promise._promise;
var length = _promise.reactionLength;
if (length > 0) {
enqueuePromiseReactionJob(
_promise.fulfillReactionHandler0,
_promise.reactionCapability0,
value
);
_promise.fulfillReactionHandler0 = void 0;
_promise.rejectReactions0 = void 0;
_promise.reactionCapability0 = void 0;
if (length > 1) {
for (var i = 1, idx = 0; i < length; i++, idx += 3) {
enqueuePromiseReactionJob(
_promise[idx + PROMISE_FULFILL_OFFSET],
_promise[idx + PROMISE_CAPABILITY_OFFSET],
value
);
promise[idx + PROMISE_FULFILL_OFFSET] = void 0;
promise[idx + PROMISE_REJECT_OFFSET] = void 0;
promise[idx + PROMISE_CAPABILITY_OFFSET] = void 0;
}
}
}
_promise.result = value;
_promise.state = PROMISE_FULFILLED;
_promise.reactionLength = 0;
};
var rejectPromise = function (promise, reason) {
var _promise = promise._promise;
var length = _promise.reactionLength;
if (length > 0) {
enqueuePromiseReactionJob(
_promise.rejectReactionHandler0,
_promise.reactionCapability0,
reason
);
_promise.fulfillReactionHandler0 = void 0;
_promise.rejectReactions0 = void 0;
_promise.reactionCapability0 = void 0;
if (length > 1) {
for (var i = 1, idx = 0; i < length; i++, idx += 3) {
enqueuePromiseReactionJob(
_promise[idx + PROMISE_REJECT_OFFSET],
_promise[idx + PROMISE_CAPABILITY_OFFSET],
reason
);
promise[idx + PROMISE_FULFILL_OFFSET] = void 0;
promise[idx + PROMISE_REJECT_OFFSET] = void 0;
promise[idx + PROMISE_CAPABILITY_OFFSET] = void 0;
}
}
}
_promise.result = reason;
_promise.state = PROMISE_REJECTED;
_promise.reactionLength = 0;
};
var createResolvingFunctions = function (promise) {
var alreadyResolved = false;
var resolve = function (resolution) {
var then;
if (alreadyResolved) { return; }
alreadyResolved = true;
if (resolution === promise) {
return rejectPromise(promise, new TypeError('Self resolution'));
}
if (!ES.TypeIsObject(resolution)) {
return fulfillPromise(promise, resolution);
}
try {
then = resolution.then;
} catch (e) {
return rejectPromise(promise, e);
}
if (!ES.IsCallable(then)) {
return fulfillPromise(promise, resolution);
}
enqueue(function () {
promiseResolveThenableJob(promise, resolution, then);
});
};
var reject = function (reason) {
if (alreadyResolved) { return; }
alreadyResolved = true;
return rejectPromise(promise, reason);
};
return { resolve: resolve, reject: reject };
};
var optimizedThen = function (then, thenable, resolve, reject) {
// Optimization: since we discard the result, we can pass our
// own then implementation a special hint to let it know it
// doesn't have to create it. (The PROMISE_FAKE_CAPABILITY
// object is local to this implementation and unforgeable outside.)
if (then === Promise$prototype$then) {
_call(then, thenable, resolve, reject, PROMISE_FAKE_CAPABILITY);
} else {
_call(then, thenable, resolve, reject);
}
};
var promiseResolveThenableJob = function (promise, thenable, then) {
var resolvingFunctions = createResolvingFunctions(promise);
var resolve = resolvingFunctions.resolve;
var reject = resolvingFunctions.reject;
try {
optimizedThen(then, thenable, resolve, reject);
} catch (e) {
reject(e);
}
};
var Promise$prototype, Promise$prototype$then;
var Promise = (function () {
var PromiseShim = function Promise(resolver) {
if (!(this instanceof PromiseShim)) {
throw new TypeError('Constructor Promise requires "new"');
}
if (this && this._promise) {
throw new TypeError('Bad construction');
}
// see https://bugs.ecmascript.org/show_bug.cgi?id=2482
if (!ES.IsCallable(resolver)) {
throw new TypeError('not a valid resolver');
}
var promise = emulateES6construct(this, PromiseShim, Promise$prototype, {
_promise: {
result: void 0,
state: PROMISE_PENDING,
// The first member of the "reactions" array is inlined here,
// since most promises only have one reaction.
// We've also exploded the 'reaction' object to inline the
// "handler" and "capability" fields, since both fulfill and
// reject reactions share the same capability.
reactionLength: 0,
fulfillReactionHandler0: void 0,
rejectReactionHandler0: void 0,
reactionCapability0: void 0
}
});
var resolvingFunctions = createResolvingFunctions(promise);
var reject = resolvingFunctions.reject;
try {
resolver(resolvingFunctions.resolve, reject);
} catch (e) {
reject(e);
}
return promise;
};
return PromiseShim;
}());
Promise$prototype = Promise.prototype;
var _promiseAllResolver = function (index, values, capability, remaining) {
var alreadyCalled = false;
return function (x) {
if (alreadyCalled) { return; }
alreadyCalled = true;
values[index] = x;
if ((--remaining.count) === 0) {
var resolve = capability.resolve;
resolve(values); // call w/ this===undefined
}
};
};
var performPromiseAll = function (iteratorRecord, C, resultCapability) {
var it = iteratorRecord.iterator;
var values = [];
var remaining = { count: 1 };
var next, nextValue;
var index = 0;
while (true) {
try {
next = ES.IteratorStep(it);
if (next === false) {
iteratorRecord.done = true;
break;
}
nextValue = next.value;
} catch (e) {
iteratorRecord.done = true;
throw e;
}
values[index] = void 0;
var nextPromise = C.resolve(nextValue);
var resolveElement = _promiseAllResolver(
index, values, resultCapability, remaining
);
remaining.count += 1;
optimizedThen(nextPromise.then, nextPromise, resolveElement, resultCapability.reject);
index += 1;
}
if ((--remaining.count) === 0) {
var resolve = resultCapability.resolve;
resolve(values); // call w/ this===undefined
}
return resultCapability.promise;
};
var performPromiseRace = function (iteratorRecord, C, resultCapability) {
var it = iteratorRecord.iterator;
var next, nextValue, nextPromise;
while (true) {
try {
next = ES.IteratorStep(it);
if (next === false) {
// NOTE: If iterable has no items, resulting promise will never
// resolve; see:
// https://github.com/domenic/promises-unwrapping/issues/75
// https://bugs.ecmascript.org/show_bug.cgi?id=2515
iteratorRecord.done = true;
break;
}
nextValue = next.value;
} catch (e) {
iteratorRecord.done = true;
throw e;
}
nextPromise = C.resolve(nextValue);
optimizedThen(nextPromise.then, nextPromise, resultCapability.resolve, resultCapability.reject);
}
return resultCapability.promise;
};
defineProperties(Promise, {
all: function all(iterable) {
var C = this;
if (!ES.TypeIsObject(C)) {
throw new TypeError('Promise is not object');
}
var capability = new PromiseCapability(C);
var iterator, iteratorRecord;
try {
iterator = ES.GetIterator(iterable);
iteratorRecord = { iterator: iterator, done: false };
return performPromiseAll(iteratorRecord, C, capability);
} catch (e) {
var exception = e;
if (iteratorRecord && !iteratorRecord.done) {
try {
ES.IteratorClose(iterator, true);
} catch (ee) {
exception = ee;
}
}
var reject = capability.reject;
reject(exception);
return capability.promise;
}
},
race: function race(iterable) {
var C = this;
if (!ES.TypeIsObject(C)) {
throw new TypeError('Promise is not object');
}
var capability = new PromiseCapability(C);
var iterator, iteratorRecord;
try {
iterator = ES.GetIterator(iterable);
iteratorRecord = { iterator: iterator, done: false };
return performPromiseRace(iteratorRecord, C, capability);
} catch (e) {
var exception = e;
if (iteratorRecord && !iteratorRecord.done) {
try {
ES.IteratorClose(iterator, true);
} catch (ee) {
exception = ee;
}
}
var reject = capability.reject;
reject(exception);
return capability.promise;
}
},
reject: function reject(reason) {
var C = this;
if (!ES.TypeIsObject(C)) {
throw new TypeError('Bad promise constructor');
}
var capability = new PromiseCapability(C);
var rejectFunc = capability.reject;
rejectFunc(reason); // call with this===undefined
return capability.promise;
},
resolve: function resolve(v) {
// See https://esdiscuss.org/topic/fixing-promise-resolve for spec
var C = this;
if (!ES.TypeIsObject(C)) {
throw new TypeError('Bad promise constructor');
}
if (ES.IsPromise(v)) {
var constructor = v.constructor;
if (constructor === C) {
return v;
}
}
var capability = new PromiseCapability(C);
var resolveFunc = capability.resolve;
resolveFunc(v); // call with this===undefined
return capability.promise;
}
});
defineProperties(Promise$prototype, {
'catch': function (onRejected) {
return this.then(null, onRejected);
},
then: function then(onFulfilled, onRejected) {
var promise = this;
if (!ES.IsPromise(promise)) { throw new TypeError('not a promise'); }
var C = ES.SpeciesConstructor(promise, Promise);
var resultCapability;
var returnValueIsIgnored = arguments.length > 2 && arguments[2] === PROMISE_FAKE_CAPABILITY;
if (returnValueIsIgnored && C === Promise) {
resultCapability = PROMISE_FAKE_CAPABILITY;
} else {
resultCapability = new PromiseCapability(C);
}
// PerformPromiseThen(promise, onFulfilled, onRejected, resultCapability)
// Note that we've split the 'reaction' object into its two
// components, "capabilities" and "handler"
// "capabilities" is always equal to `resultCapability`
var fulfillReactionHandler = ES.IsCallable(onFulfilled) ? onFulfilled : PROMISE_IDENTITY;
var rejectReactionHandler = ES.IsCallable(onRejected) ? onRejected : PROMISE_THROWER;
var _promise = promise._promise;
var value;
if (_promise.state === PROMISE_PENDING) {
if (_promise.reactionLength === 0) {
_promise.fulfillReactionHandler0 = fulfillReactionHandler;
_promise.rejectReactionHandler0 = rejectReactionHandler;
_promise.reactionCapability0 = resultCapability;
} else {
var idx = 3 * (_promise.reactionLength - 1);
_promise[idx + PROMISE_FULFILL_OFFSET] = fulfillReactionHandler;
_promise[idx + PROMISE_REJECT_OFFSET] = rejectReactionHandler;
_promise[idx + PROMISE_CAPABILITY_OFFSET] = resultCapability;
}
_promise.reactionLength += 1;
} else if (_promise.state === PROMISE_FULFILLED) {
value = _promise.result;
enqueuePromiseReactionJob(
fulfillReactionHandler, resultCapability, value
);
} else if (_promise.state === PROMISE_REJECTED) {
value = _promise.result;
enqueuePromiseReactionJob(
rejectReactionHandler, resultCapability, value
);
} else {
throw new TypeError('unexpected Promise state');
}
return resultCapability.promise;
}
});
// This helps the optimizer by ensuring that methods which take
// capabilities aren't polymorphic.
PROMISE_FAKE_CAPABILITY = new PromiseCapability(Promise);
Promise$prototype$then = Promise$prototype.then;
return Promise;
}());
// Chrome's native Promise has extra methods that it shouldn't have. Let's remove them.
if (globals.Promise) {
delete globals.Promise.accept;
delete globals.Promise.defer;
delete globals.Promise.prototype.chain;
}
if (typeof PromiseShim === 'function') {
// export the Promise constructor.
defineProperties(globals, { Promise: PromiseShim });
// In Chrome 33 (and thereabouts) Promise is defined, but the
// implementation is buggy in a number of ways. Let's check subclassing
// support to see if we have a buggy implementation.
var promiseSupportsSubclassing = supportsSubclassing(globals.Promise, function (S) {
return S.resolve(42).then(function () {}) instanceof S;
});
var promiseIgnoresNonFunctionThenCallbacks = !throwsError(function () {
globals.Promise.reject(42).then(null, 5).then(null, noop);
});
var promiseRequiresObjectContext = throwsError(function () { globals.Promise.call(3, noop); });
// Promise.resolve() was errata'ed late in the ES6 process.
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1170742
// https://code.google.com/p/v8/issues/detail?id=4161
// It serves as a proxy for a number of other bugs in early Promise
// implementations.
var promiseResolveBroken = (function (Promise) {
var p = Promise.resolve(5);
p.constructor = {};
var p2 = Promise.resolve(p);
try {
p2.then(null, noop).then(null, noop); // avoid "uncaught rejection" warnings in console
} catch (e) {
return true; // v8 native Promises break here https://code.google.com/p/chromium/issues/detail?id=575314
}
return p === p2; // This *should* be false!
}(globals.Promise));
// Chrome 46 (probably older too) does not retrieve a thenable's .then synchronously
var getsThenSynchronously = supportsDescriptors && (function () {
var count = 0;
var thenable = Object.defineProperty({}, 'then', { get: function () { count += 1; } });
Promise.resolve(thenable);
return count === 1;
}());
var BadResolverPromise = function BadResolverPromise(executor) {
var p = new Promise(executor);
executor(3, function () {});
this.then = p.then;
this.constructor = BadResolverPromise;
};
BadResolverPromise.prototype = Promise.prototype;
BadResolverPromise.all = Promise.all;
// Chrome Canary 49 (probably older too) has some implementation bugs
var hasBadResolverPromise = valueOrFalseIfThrows(function () {
return !!BadResolverPromise.all([1, 2]);
});
if (!promiseSupportsSubclassing || !promiseIgnoresNonFunctionThenCallbacks ||
!promiseRequiresObjectContext || promiseResolveBroken ||
!getsThenSynchronously || hasBadResolverPromise) {
/* globals Promise: true */
/* eslint-disable no-undef, no-global-assign */
/* jshint -W020 */
Promise = PromiseShim;
/* jshint +W020 */
/* eslint-enable no-undef, no-global-assign */
/* globals Promise: false */
overrideNative(globals, 'Promise', PromiseShim);
}
if (Promise.all.length !== 1) {
var origAll = Promise.all;
overrideNative(Promise, 'all', function all(iterable) {
return ES.Call(origAll, this, arguments);
});
}
if (Promise.race.length !== 1) {
var origRace = Promise.race;
overrideNative(Promise, 'race', function race(iterable) {
return ES.Call(origRace, this, arguments);
});
}
if (Promise.resolve.length !== 1) {
var origResolve = Promise.resolve;
overrideNative(Promise, 'resolve', function resolve(x) {
return ES.Call(origResolve, this, arguments);
});
}
if (Promise.reject.length !== 1) {
var origReject = Promise.reject;
overrideNative(Promise, 'reject', function reject(r) {
return ES.Call(origReject, this, arguments);
});
}
ensureEnumerable(Promise, 'all');
ensureEnumerable(Promise, 'race');
ensureEnumerable(Promise, 'resolve');
ensureEnumerable(Promise, 'reject');
addDefaultSpecies(Promise);
}
// Map and Set require a true ES5 environment
// Their fast path also requires that the environment preserve
// property insertion order, which is not guaranteed by the spec.
var testOrder = function (a) {
var b = keys(_reduce(a, function (o, k) {
o[k] = true;
return o;
}, {}));
return a.join(':') === b.join(':');
};
var preservesInsertionOrder = testOrder(['z', 'a', 'bb']);
// some engines (eg, Chrome) only preserve insertion order for string keys
var preservesNumericInsertionOrder = testOrder(['z', 1, 'a', '3', 2]);
if (supportsDescriptors) {
var fastkey = function fastkey(key, skipInsertionOrderCheck) {
if (!skipInsertionOrderCheck && !preservesInsertionOrder) {
return null;
}
if (isNullOrUndefined(key)) {
return '^' + ES.ToString(key);
} else if (typeof key === 'string') {
return '$' + key;
} else if (typeof key === 'number') {
// note that -0 will get coerced to "0" when used as a property key
if (!preservesNumericInsertionOrder) {
return 'n' + key;
}
return key;
} else if (typeof key === 'boolean') {
return 'b' + key;
}
return null;
};
var emptyObject = function emptyObject() {
// accomodate some older not-quite-ES5 browsers
return Object.create ? Object.create(null) : {};
};
var addIterableToMap = function addIterableToMap(MapConstructor, map, iterable) {
if (isArray(iterable) || Type.string(iterable)) {
_forEach(iterable, function (entry) {
if (!ES.TypeIsObject(entry)) {
throw new TypeError('Iterator value ' + entry + ' is not an entry object');
}
map.set(entry[0], entry[1]);
});
} else if (iterable instanceof MapConstructor) {
_call(MapConstructor.prototype.forEach, iterable, function (value, key) {
map.set(key, value);
});
} else {
var iter, adder;
if (!isNullOrUndefined(iterable)) {
adder = map.set;
if (!ES.IsCallable(adder)) { throw new TypeError('bad map'); }
iter = ES.GetIterator(iterable);
}
if (typeof iter !== 'undefined') {
while (true) {
var next = ES.IteratorStep(iter);
if (next === false) { break; }
var nextItem = next.value;
try {
if (!ES.TypeIsObject(nextItem)) {
throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
}
_call(adder, map, nextItem[0], nextItem[1]);
} catch (e) {
ES.IteratorClose(iter, true);
throw e;
}
}
}
}
};
var addIterableToSet = function addIterableToSet(SetConstructor, set, iterable) {
if (isArray(iterable) || Type.string(iterable)) {
_forEach(iterable, function (value) {
set.add(value);
});
} else if (iterable instanceof SetConstructor) {
_call(SetConstructor.prototype.forEach, iterable, function (value) {
set.add(value);
});
} else {
var iter, adder;
if (!isNullOrUndefined(iterable)) {
adder = set.add;
if (!ES.IsCallable(adder)) { throw new TypeError('bad set'); }
iter = ES.GetIterator(iterable);
}
if (typeof iter !== 'undefined') {
while (true) {
var next = ES.IteratorStep(iter);
if (next === false) { break; }
var nextValue = next.value;
try {
_call(adder, set, nextValue);
} catch (e) {
ES.IteratorClose(iter, true);
throw e;
}
}
}
}
};
var collectionShims = {
Map: (function () {
var empty = {};
var MapEntry = function MapEntry(key, value) {
this.key = key;
this.value = value;
this.next = null;
this.prev = null;
};
MapEntry.prototype.isRemoved = function isRemoved() {
return this.key === empty;
};
var isMap = function isMap(map) {
return !!map._es6map;
};
var requireMapSlot = function requireMapSlot(map, method) {
if (!ES.TypeIsObject(map) || !isMap(map)) {
throw new TypeError('Method Map.prototype.' + method + ' called on incompatible receiver ' + ES.ToString(map));
}
};
var MapIterator = function MapIterator(map, kind) {
requireMapSlot(map, '[[MapIterator]]');
this.head = map._head;
this.i = this.head;
this.kind = kind;
};
MapIterator.prototype = {
next: function next() {
var i = this.i;
var kind = this.kind;
var head = this.head;
if (typeof this.i === 'undefined') {
return iteratorResult();
}
while (i.isRemoved() && i !== head) {
// back up off of removed entries
i = i.prev;
}
// advance to next unreturned element.
var result;
while (i.next !== head) {
i = i.next;
if (!i.isRemoved()) {
if (kind === 'key') {
result = i.key;
} else if (kind === 'value') {
result = i.value;
} else {
result = [i.key, i.value];
}
this.i = i;
return iteratorResult(result);
}
}
// once the iterator is done, it is done forever.
this.i = void 0;
return iteratorResult();
}
};
addIterator(MapIterator.prototype);
var Map$prototype;
var MapShim = function Map() {
if (!(this instanceof Map)) {
throw new TypeError('Constructor Map requires "new"');
}
if (this && this._es6map) {
throw new TypeError('Bad construction');
}
var map = emulateES6construct(this, Map, Map$prototype, {
_es6map: true,
_head: null,
_map: OrigMap ? new OrigMap() : null,
_size: 0,
_storage: emptyObject()
});
var head = new MapEntry(null, null);
// circular doubly-linked list.
/* eslint no-multi-assign: 1 */
head.next = head.prev = head;
map._head = head;
// Optionally initialize map from iterable
if (arguments.length > 0) {
addIterableToMap(Map, map, arguments[0]);
}
return map;
};
Map$prototype = MapShim.prototype;
Value.getter(Map$prototype, 'size', function () {
if (typeof this._size === 'undefined') {
throw new TypeError('size method called on incompatible Map');
}
return this._size;
});
defineProperties(Map$prototype, {
get: function get(key) {
requireMapSlot(this, 'get');
var entry;
var fkey = fastkey(key, true);
if (fkey !== null) {
// fast O(1) path
entry = this._storage[fkey];
if (entry) {
return entry.value;
} else {
return;
}
}
if (this._map) {
// fast object key path
entry = origMapGet.call(this._map, key);
if (entry) {
return entry.value;
} else {
return;
}
}
var head = this._head;
var i = head;
while ((i = i.next) !== head) {
if (ES.SameValueZero(i.key, key)) {
return i.value;
}
}
},
has: function has(key) {
requireMapSlot(this, 'has');
var fkey = fastkey(key, true);
if (fkey !== null) {
// fast O(1) path
return typeof this._storage[fkey] !== 'undefined';
}
if (this._map) {
// fast object key path
return origMapHas.call(this._map, key);
}
var head = this._head;
var i = head;
while ((i = i.next) !== head) {
if (ES.SameValueZero(i.key, key)) {
return true;
}
}
return false;
},
set: function set(key, value) {
requireMapSlot(this, 'set');
var head = this._head;
var i = head;
var entry;
var fkey = fastkey(key, true);
if (fkey !== null) {
// fast O(1) path
if (typeof this._storage[fkey] !== 'undefined') {
this._storage[fkey].value = value;
return this;
} else {
entry = this._storage[fkey] = new MapEntry(key, value); /* eslint no-multi-assign: 1 */
i = head.prev;
// fall through
}
} else if (this._map) {
// fast object key path
if (origMapHas.call(this._map, key)) {
origMapGet.call(this._map, key).value = value;
} else {
entry = new MapEntry(key, value);
origMapSet.call(this._map, key, entry);
i = head.prev;
// fall through
}
}
while ((i = i.next) !== head) {
if (ES.SameValueZero(i.key, key)) {
i.value = value;
return this;
}
}
entry = entry || new MapEntry(key, value);
if (ES.SameValue(-0, key)) {
entry.key = +0; // coerce -0 to +0 in entry
}
entry.next = this._head;
entry.prev = this._head.prev;
entry.prev.next = entry;
entry.next.prev = entry;
this._size += 1;
return this;
},
'delete': function (key) {
requireMapSlot(this, 'delete');
var head = this._head;
var i = head;
var fkey = fastkey(key, true);
if (fkey !== null) {
// fast O(1) path
if (typeof this._storage[fkey] === 'undefined') {
return false;
}
i = this._storage[fkey].prev;
delete this._storage[fkey];
// fall through
} else if (this._map) {
// fast object key path
if (!origMapHas.call(this._map, key)) {
return false;
}
i = origMapGet.call(this._map, key).prev;
origMapDelete.call(this._map, key);
// fall through
}
while ((i = i.next) !== head) {
if (ES.SameValueZero(i.key, key)) {
i.key = empty;
i.value = empty;
i.prev.next = i.next;
i.next.prev = i.prev;
this._size -= 1;
return true;
}
}
return false;
},
clear: function clear() {
/* eslint no-multi-assign: 1 */
requireMapSlot(this, 'clear');
this._map = OrigMap ? new OrigMap() : null;
this._size = 0;
this._storage = emptyObject();
var head = this._head;
var i = head;
var p = i.next;
while ((i = p) !== head) {
i.key = empty;
i.value = empty;
p = i.next;
i.next = i.prev = head;
}
head.next = head.prev = head;
},
keys: function keys() {
requireMapSlot(this, 'keys');
return new MapIterator(this, 'key');
},
values: function values() {
requireMapSlot(this, 'values');
return new MapIterator(this, 'value');
},
entries: function entries() {
requireMapSlot(this, 'entries');
return new MapIterator(this, 'key+value');
},
forEach: function forEach(callback) {
requireMapSlot(this, 'forEach');
var context = arguments.length > 1 ? arguments[1] : null;
var it = this.entries();
for (var entry = it.next(); !entry.done; entry = it.next()) {
if (context) {
_call(callback, context, entry.value[1], entry.value[0], this);
} else {
callback(entry.value[1], entry.value[0], this);
}
}
}
});
addIterator(Map$prototype, Map$prototype.entries);
return MapShim;
}()),
Set: (function () {
var isSet = function isSet(set) {
return set._es6set && typeof set._storage !== 'undefined';
};
var requireSetSlot = function requireSetSlot(set, method) {
if (!ES.TypeIsObject(set) || !isSet(set)) {
// https://github.com/paulmillr/es6-shim/issues/176
throw new TypeError('Set.prototype.' + method + ' called on incompatible receiver ' + ES.ToString(set));
}
};
// Creating a Map is expensive. To speed up the common case of
// Sets containing only string or numeric keys, we use an object
// as backing storage and lazily create a full Map only when
// required.
var Set$prototype;
var SetShim = function Set() {
if (!(this instanceof Set)) {
throw new TypeError('Constructor Set requires "new"');
}
if (this && this._es6set) {
throw new TypeError('Bad construction');
}
var set = emulateES6construct(this, Set, Set$prototype, {
_es6set: true,
'[[SetData]]': null,
_storage: emptyObject()
});
if (!set._es6set) {
throw new TypeError('bad set');
}
// Optionally initialize Set from iterable
if (arguments.length > 0) {
addIterableToSet(Set, set, arguments[0]);
}
return set;
};
Set$prototype = SetShim.prototype;
var decodeKey = function (key) {
var k = key;
if (k === '^null') {
return null;
} else if (k === '^undefined') {
return void 0;
} else {
var first = k.charAt(0);
if (first === '$') {
return _strSlice(k, 1);
} else if (first === 'n') {
return +_strSlice(k, 1);
} else if (first === 'b') {
return k === 'btrue';
}
}
return +k;
};
// Switch from the object backing storage to a full Map.
var ensureMap = function ensureMap(set) {
if (!set['[[SetData]]']) {
var m = new collectionShims.Map();
set['[[SetData]]'] = m;
_forEach(keys(set._storage), function (key) {
var k = decodeKey(key);
m.set(k, k);
});
set['[[SetData]]'] = m;
}
set._storage = null; // free old backing storage
};
Value.getter(SetShim.prototype, 'size', function () {
requireSetSlot(this, 'size');
if (this._storage) {
return keys(this._storage).length;
}
ensureMap(this);
return this['[[SetData]]'].size;
});
defineProperties(SetShim.prototype, {
has: function has(key) {
requireSetSlot(this, 'has');
var fkey;
if (this._storage && (fkey = fastkey(key)) !== null) {
return !!this._storage[fkey];
}
ensureMap(this);
return this['[[SetData]]'].has(key);
},
add: function add(key) {
requireSetSlot(this, 'add');
var fkey;
if (this._storage && (fkey = fastkey(key)) !== null) {
this._storage[fkey] = true;
return this;
}
ensureMap(this);
this['[[SetData]]'].set(key, key);
return this;
},
'delete': function (key) {
requireSetSlot(this, 'delete');
var fkey;
if (this._storage && (fkey = fastkey(key)) !== null) {
var hasFKey = _hasOwnProperty(this._storage, fkey);
return (delete this._storage[fkey]) && hasFKey;
}
ensureMap(this);
return this['[[SetData]]']['delete'](key);
},
clear: function clear() {
requireSetSlot(this, 'clear');
if (this._storage) {
this._storage = emptyObject();
}
if (this['[[SetData]]']) {
this['[[SetData]]'].clear();
}
},
values: function values() {
requireSetSlot(this, 'values');
ensureMap(this);
return this['[[SetData]]'].values();
},
entries: function entries() {
requireSetSlot(this, 'entries');
ensureMap(this);
return this['[[SetData]]'].entries();
},
forEach: function forEach(callback) {
requireSetSlot(this, 'forEach');
var context = arguments.length > 1 ? arguments[1] : null;
var entireSet = this;
ensureMap(entireSet);
this['[[SetData]]'].forEach(function (value, key) {
if (context) {
_call(callback, context, key, key, entireSet);
} else {
callback(key, key, entireSet);
}
});
}
});
defineProperty(SetShim.prototype, 'keys', SetShim.prototype.values, true);
addIterator(SetShim.prototype, SetShim.prototype.values);
return SetShim;
}())
};
if (globals.Map || globals.Set) {
// Safari 8, for example, doesn't accept an iterable.
var mapAcceptsArguments = valueOrFalseIfThrows(function () { return new Map([[1, 2]]).get(1) === 2; });
if (!mapAcceptsArguments) {
globals.Map = function Map() {
if (!(this instanceof Map)) {
throw new TypeError('Constructor Map requires "new"');
}
var m = new OrigMap();
if (arguments.length > 0) {
addIterableToMap(Map, m, arguments[0]);
}
delete m.constructor;
Object.setPrototypeOf(m, globals.Map.prototype);
return m;
};
globals.Map.prototype = create(OrigMap.prototype);
defineProperty(globals.Map.prototype, 'constructor', globals.Map, true);
Value.preserveToString(globals.Map, OrigMap);
}
var testMap = new Map();
var mapUsesSameValueZero = (function () {
// Chrome 38-42, node 0.11/0.12, iojs 1/2 also have a bug when the Map has a size > 4
var m = new Map([[1, 0], [2, 0], [3, 0], [4, 0]]);
m.set(-0, m);
return m.get(0) === m && m.get(-0) === m && m.has(0) && m.has(-0);
}());
var mapSupportsChaining = testMap.set(1, 2) === testMap;
if (!mapUsesSameValueZero || !mapSupportsChaining) {
overrideNative(Map.prototype, 'set', function set(k, v) {
_call(origMapSet, this, k === 0 ? 0 : k, v);
return this;
});
}
if (!mapUsesSameValueZero) {
defineProperties(Map.prototype, {
get: function get(k) {
return _call(origMapGet, this, k === 0 ? 0 : k);
},
has: function has(k) {
return _call(origMapHas, this, k === 0 ? 0 : k);
}
}, true);
Value.preserveToString(Map.prototype.get, origMapGet);
Value.preserveToString(Map.prototype.has, origMapHas);
}
var testSet = new Set();
var setUsesSameValueZero = (function (s) {
s['delete'](0);
s.add(-0);
return !s.has(0);
}(testSet));
var setSupportsChaining = testSet.add(1) === testSet;
if (!setUsesSameValueZero || !setSupportsChaining) {
var origSetAdd = Set.prototype.add;
Set.prototype.add = function add(v) {
_call(origSetAdd, this, v === 0 ? 0 : v);
return this;
};
Value.preserveToString(Set.prototype.add, origSetAdd);
}
if (!setUsesSameValueZero) {
var origSetHas = Set.prototype.has;
Set.prototype.has = function has(v) {
return _call(origSetHas, this, v === 0 ? 0 : v);
};
Value.preserveToString(Set.prototype.has, origSetHas);
var origSetDel = Set.prototype['delete'];
Set.prototype['delete'] = function SetDelete(v) {
return _call(origSetDel, this, v === 0 ? 0 : v);
};
Value.preserveToString(Set.prototype['delete'], origSetDel);
}
var mapSupportsSubclassing = supportsSubclassing(globals.Map, function (M) {
var m = new M([]);
// Firefox 32 is ok with the instantiating the subclass but will
// throw when the map is used.
m.set(42, 42);
return m instanceof M;
});
// without Object.setPrototypeOf, subclassing is not possible
var mapFailsToSupportSubclassing = Object.setPrototypeOf && !mapSupportsSubclassing;
var mapRequiresNew = (function () {
try {
return !(globals.Map() instanceof globals.Map);
} catch (e) {
return e instanceof TypeError;
}
}());
if (globals.Map.length !== 0 || mapFailsToSupportSubclassing || !mapRequiresNew) {
globals.Map = function Map() {
if (!(this instanceof Map)) {
throw new TypeError('Constructor Map requires "new"');
}
var m = new OrigMap();
if (arguments.length > 0) {
addIterableToMap(Map, m, arguments[0]);
}
delete m.constructor;
Object.setPrototypeOf(m, Map.prototype);
return m;
};
globals.Map.prototype = OrigMap.prototype;
defineProperty(globals.Map.prototype, 'constructor', globals.Map, true);
Value.preserveToString(globals.Map, OrigMap);
}
var setSupportsSubclassing = supportsSubclassing(globals.Set, function (S) {
var s = new S([]);
s.add(42, 42);
return s instanceof S;
});
// without Object.setPrototypeOf, subclassing is not possible
var setFailsToSupportSubclassing = Object.setPrototypeOf && !setSupportsSubclassing;
var setRequiresNew = (function () {
try {
return !(globals.Set() instanceof globals.Set);
} catch (e) {
return e instanceof TypeError;
}
}());
if (globals.Set.length !== 0 || setFailsToSupportSubclassing || !setRequiresNew) {
var OrigSet = globals.Set;
globals.Set = function Set() {
if (!(this instanceof Set)) {
throw new TypeError('Constructor Set requires "new"');
}
var s = new OrigSet();
if (arguments.length > 0) {
addIterableToSet(Set, s, arguments[0]);
}
delete s.constructor;
Object.setPrototypeOf(s, Set.prototype);
return s;
};
globals.Set.prototype = OrigSet.prototype;
defineProperty(globals.Set.prototype, 'constructor', globals.Set, true);
Value.preserveToString(globals.Set, OrigSet);
}
var newMap = new globals.Map();
var mapIterationThrowsStopIterator = !valueOrFalseIfThrows(function () {
return newMap.keys().next().done;
});
/*
- In Firefox < 23, Map#size is a function.
- In all current Firefox, Set#entries/keys/values & Map#clear do not exist
- https://bugzilla.mozilla.org/show_bug.cgi?id=869996
- In Firefox 24, Map and Set do not implement forEach
- In Firefox 25 at least, Map and Set are callable without "new"
*/
if (
typeof globals.Map.prototype.clear !== 'function' ||
new globals.Set().size !== 0 ||
newMap.size !== 0 ||
typeof globals.Map.prototype.keys !== 'function' ||
typeof globals.Set.prototype.keys !== 'function' ||
typeof globals.Map.prototype.forEach !== 'function' ||
typeof globals.Set.prototype.forEach !== 'function' ||
isCallableWithoutNew(globals.Map) ||
isCallableWithoutNew(globals.Set) ||
typeof newMap.keys().next !== 'function' || // Safari 8
mapIterationThrowsStopIterator || // Firefox 25
!mapSupportsSubclassing
) {
defineProperties(globals, {
Map: collectionShims.Map,
Set: collectionShims.Set
}, true);
}
if (globals.Set.prototype.keys !== globals.Set.prototype.values) {
// Fixed in WebKit with https://bugs.webkit.org/show_bug.cgi?id=144190
defineProperty(globals.Set.prototype, 'keys', globals.Set.prototype.values, true);
}
// Shim incomplete iterator implementations.
addIterator(Object.getPrototypeOf((new globals.Map()).keys()));
addIterator(Object.getPrototypeOf((new globals.Set()).keys()));
if (functionsHaveNames && globals.Set.prototype.has.name !== 'has') {
// Microsoft Edge v0.11.10074.0 is missing a name on Set#has
var anonymousSetHas = globals.Set.prototype.has;
overrideNative(globals.Set.prototype, 'has', function has(key) {
return _call(anonymousSetHas, this, key);
});
}
}
defineProperties(globals, collectionShims);
addDefaultSpecies(globals.Map);
addDefaultSpecies(globals.Set);
}
var throwUnlessTargetIsObject = function throwUnlessTargetIsObject(target) {
if (!ES.TypeIsObject(target)) {
throw new TypeError('target must be an object');
}
};
// Some Reflect methods are basically the same as
// those on the Object global, except that a TypeError is thrown if
// target isn't an object. As well as returning a boolean indicating
// the success of the operation.
var ReflectShims = {
// Apply method in a functional form.
apply: function apply() {
return ES.Call(ES.Call, null, arguments);
},
// New operator in a functional form.
construct: function construct(constructor, args) {
if (!ES.IsConstructor(constructor)) {
throw new TypeError('First argument must be a constructor.');
}
var newTarget = arguments.length > 2 ? arguments[2] : constructor;
if (!ES.IsConstructor(newTarget)) {
throw new TypeError('new.target must be a constructor.');
}
return ES.Construct(constructor, args, newTarget, 'internal');
},
// When deleting a non-existent or configurable property,
// true is returned.
// When attempting to delete a non-configurable property,
// it will return false.
deleteProperty: function deleteProperty(target, key) {
throwUnlessTargetIsObject(target);
if (supportsDescriptors) {
var desc = Object.getOwnPropertyDescriptor(target, key);
if (desc && !desc.configurable) {
return false;
}
}
// Will return true.
return delete target[key];
},
has: function has(target, key) {
throwUnlessTargetIsObject(target);
return key in target;
}
};
if (Object.getOwnPropertyNames) {
Object.assign(ReflectShims, {
// Basically the result of calling the internal [[OwnPropertyKeys]].
// Concatenating propertyNames and propertySymbols should do the trick.
// This should continue to work together with a Symbol shim
// which overrides Object.getOwnPropertyNames and implements
// Object.getOwnPropertySymbols.
ownKeys: function ownKeys(target) {
throwUnlessTargetIsObject(target);
var keys = Object.getOwnPropertyNames(target);
if (ES.IsCallable(Object.getOwnPropertySymbols)) {
_pushApply(keys, Object.getOwnPropertySymbols(target));
}
return keys;
}
});
}
var callAndCatchException = function ConvertExceptionToBoolean(func) {
return !throwsError(func);
};
if (Object.preventExtensions) {
Object.assign(ReflectShims, {
isExtensible: function isExtensible(target) {
throwUnlessTargetIsObject(target);
return Object.isExtensible(target);
},
preventExtensions: function preventExtensions(target) {
throwUnlessTargetIsObject(target);
return callAndCatchException(function () {
Object.preventExtensions(target);
});
}
});
}
if (supportsDescriptors) {
var internalGet = function get(target, key, receiver) {
var desc = Object.getOwnPropertyDescriptor(target, key);
if (!desc) {
var parent = Object.getPrototypeOf(target);
if (parent === null) {
return void 0;
}
return internalGet(parent, key, receiver);
}
if ('value' in desc) {
return desc.value;
}
if (desc.get) {
return ES.Call(desc.get, receiver);
}
return void 0;
};
var internalSet = function set(target, key, value, receiver) {
var desc = Object.getOwnPropertyDescriptor(target, key);
if (!desc) {
var parent = Object.getPrototypeOf(target);
if (parent !== null) {
return internalSet(parent, key, value, receiver);
}
desc = {
value: void 0,
writable: true,
enumerable: true,
configurable: true
};
}
if ('value' in desc) {
if (!desc.writable) {
return false;
}
if (!ES.TypeIsObject(receiver)) {
return false;
}
var existingDesc = Object.getOwnPropertyDescriptor(receiver, key);
if (existingDesc) {
return Reflect.defineProperty(receiver, key, {
value: value
});
} else {
return Reflect.defineProperty(receiver, key, {
value: value,
writable: true,
enumerable: true,
configurable: true
});
}
}
if (desc.set) {
_call(desc.set, receiver, value);
return true;
}
return false;
};
Object.assign(ReflectShims, {
defineProperty: function defineProperty(target, propertyKey, attributes) {
throwUnlessTargetIsObject(target);
return callAndCatchException(function () {
Object.defineProperty(target, propertyKey, attributes);
});
},
getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) {
throwUnlessTargetIsObject(target);
return Object.getOwnPropertyDescriptor(target, propertyKey);
},
// Syntax in a functional form.
get: function get(target, key) {
throwUnlessTargetIsObject(target);
var receiver = arguments.length > 2 ? arguments[2] : target;
return internalGet(target, key, receiver);
},
set: function set(target, key, value) {
throwUnlessTargetIsObject(target);
var receiver = arguments.length > 3 ? arguments[3] : target;
return internalSet(target, key, value, receiver);
}
});
}
if (Object.getPrototypeOf) {
var objectDotGetPrototypeOf = Object.getPrototypeOf;
ReflectShims.getPrototypeOf = function getPrototypeOf(target) {
throwUnlessTargetIsObject(target);
return objectDotGetPrototypeOf(target);
};
}
if (Object.setPrototypeOf && ReflectShims.getPrototypeOf) {
var willCreateCircularPrototype = function (object, lastProto) {
var proto = lastProto;
while (proto) {
if (object === proto) {
return true;
}
proto = ReflectShims.getPrototypeOf(proto);
}
return false;
};
Object.assign(ReflectShims, {
// Sets the prototype of the given object.
// Returns true on success, otherwise false.
setPrototypeOf: function setPrototypeOf(object, proto) {
throwUnlessTargetIsObject(object);
if (proto !== null && !ES.TypeIsObject(proto)) {
throw new TypeError('proto must be an object or null');
}
// If they already are the same, we're done.
if (proto === Reflect.getPrototypeOf(object)) {
return true;
}
// Cannot alter prototype if object not extensible.
if (Reflect.isExtensible && !Reflect.isExtensible(object)) {
return false;
}
// Ensure that we do not create a circular prototype chain.
if (willCreateCircularPrototype(object, proto)) {
return false;
}
Object.setPrototypeOf(object, proto);
return true;
}
});
}
var defineOrOverrideReflectProperty = function (key, shim) {
if (!ES.IsCallable(globals.Reflect[key])) {
defineProperty(globals.Reflect, key, shim);
} else {
var acceptsPrimitives = valueOrFalseIfThrows(function () {
globals.Reflect[key](1);
globals.Reflect[key](NaN);
globals.Reflect[key](true);
return true;
});
if (acceptsPrimitives) {
overrideNative(globals.Reflect, key, shim);
}
}
};
Object.keys(ReflectShims).forEach(function (key) {
defineOrOverrideReflectProperty(key, ReflectShims[key]);
});
var originalReflectGetProto = globals.Reflect.getPrototypeOf;
if (functionsHaveNames && originalReflectGetProto && originalReflectGetProto.name !== 'getPrototypeOf') {
overrideNative(globals.Reflect, 'getPrototypeOf', function getPrototypeOf(target) {
return _call(originalReflectGetProto, globals.Reflect, target);
});
}
if (globals.Reflect.setPrototypeOf) {
if (valueOrFalseIfThrows(function () {
globals.Reflect.setPrototypeOf(1, {});
return true;
})) {
overrideNative(globals.Reflect, 'setPrototypeOf', ReflectShims.setPrototypeOf);
}
}
if (globals.Reflect.defineProperty) {
if (!valueOrFalseIfThrows(function () {
var basic = !globals.Reflect.defineProperty(1, 'test', { value: 1 });
// "extensible" fails on Edge 0.12
var extensible = typeof Object.preventExtensions !== 'function' || !globals.Reflect.defineProperty(Object.preventExtensions({}), 'test', {});
return basic && extensible;
})) {
overrideNative(globals.Reflect, 'defineProperty', ReflectShims.defineProperty);
}
}
if (globals.Reflect.construct) {
if (!valueOrFalseIfThrows(function () {
var F = function F() {};
return globals.Reflect.construct(function () {}, [], F) instanceof F;
})) {
overrideNative(globals.Reflect, 'construct', ReflectShims.construct);
}
}
if (String(new Date(NaN)) !== 'Invalid Date') {
var dateToString = Date.prototype.toString;
var shimmedDateToString = function toString() {
var valueOf = +this;
if (valueOf !== valueOf) {
return 'Invalid Date';
}
return ES.Call(dateToString, this);
};
overrideNative(Date.prototype, 'toString', shimmedDateToString);
}
// Annex B HTML methods
// http://www.ecma-international.org/ecma-262/6.0/#sec-additional-properties-of-the-string.prototype-object
var stringHTMLshims = {
anchor: function anchor(name) { return ES.CreateHTML(this, 'a', 'name', name); },
big: function big() { return ES.CreateHTML(this, 'big', '', ''); },
blink: function blink() { return ES.CreateHTML(this, 'blink', '', ''); },
bold: function bold() { return ES.CreateHTML(this, 'b', '', ''); },
fixed: function fixed() { return ES.CreateHTML(this, 'tt', '', ''); },
fontcolor: function fontcolor(color) { return ES.CreateHTML(this, 'font', 'color', color); },
fontsize: function fontsize(size) { return ES.CreateHTML(this, 'font', 'size', size); },
italics: function italics() { return ES.CreateHTML(this, 'i', '', ''); },
link: function link(url) { return ES.CreateHTML(this, 'a', 'href', url); },
small: function small() { return ES.CreateHTML(this, 'small', '', ''); },
strike: function strike() { return ES.CreateHTML(this, 'strike', '', ''); },
sub: function sub() { return ES.CreateHTML(this, 'sub', '', ''); },
sup: function sub() { return ES.CreateHTML(this, 'sup', '', ''); }
};
_forEach(Object.keys(stringHTMLshims), function (key) {
var method = String.prototype[key];
var shouldOverwrite = false;
if (ES.IsCallable(method)) {
var output = _call(method, '', ' " ');
var quotesCount = _concat([], output.match(/"/g)).length;
shouldOverwrite = output !== output.toLowerCase() || quotesCount > 2;
} else {
shouldOverwrite = true;
}
if (shouldOverwrite) {
overrideNative(String.prototype, key, stringHTMLshims[key]);
}
});
var JSONstringifiesSymbols = (function () {
// Microsoft Edge v0.12 stringifies Symbols incorrectly
if (!hasSymbols) { return false; } // Symbols are not supported
var stringify = typeof JSON === 'object' && typeof JSON.stringify === 'function' ? JSON.stringify : null;
if (!stringify) { return false; } // JSON.stringify is not supported
if (typeof stringify(Symbol()) !== 'undefined') { return true; } // Symbols should become `undefined`
if (stringify([Symbol()]) !== '[null]') { return true; } // Symbols in arrays should become `null`
var obj = { a: Symbol() };
obj[Symbol()] = true;
if (stringify(obj) !== '{}') { return true; } // Symbol-valued keys *and* Symbol-valued properties should be omitted
return false;
}());
var JSONstringifyAcceptsObjectSymbol = valueOrFalseIfThrows(function () {
// Chrome 45 throws on stringifying object symbols
if (!hasSymbols) { return true; } // Symbols are not supported
return JSON.stringify(Object(Symbol())) === '{}' && JSON.stringify([Object(Symbol())]) === '[{}]';
});
if (JSONstringifiesSymbols || !JSONstringifyAcceptsObjectSymbol) {
var origStringify = JSON.stringify;
overrideNative(JSON, 'stringify', function stringify(value) {
if (typeof value === 'symbol') { return; }
var replacer;
if (arguments.length > 1) {
replacer = arguments[1];
}
var args = [value];
if (!isArray(replacer)) {
var replaceFn = ES.IsCallable(replacer) ? replacer : null;
var wrappedReplacer = function (key, val) {
var parsedValue = replaceFn ? _call(replaceFn, this, key, val) : val;
if (typeof parsedValue !== 'symbol') {
if (Type.symbol(parsedValue)) {
return assignTo({})(parsedValue);
} else {
return parsedValue;
}
}
};
args.push(wrappedReplacer);
} else {
// create wrapped replacer that handles an array replacer?
args.push(replacer);
}
if (arguments.length > 2) {
args.push(arguments[2]);
}
return origStringify.apply(this, args);
});
}
return globals;
}));
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"_process":40}],21:[function(require,module,exports){
var hasOwn = Object.prototype.hasOwnProperty;
var toString = Object.prototype.toString;
module.exports = function forEach (obj, fn, ctx) {
if (toString.call(fn) !== '[object Function]') {
throw new TypeError('iterator must be a function');
}
var l = obj.length;
if (l === +l) {
for (var i = 0; i < l; i++) {
fn.call(ctx, obj[i], i, obj);
}
} else {
for (var k in obj) {
if (hasOwn.call(obj, k)) {
fn.call(ctx, obj[k], k, obj);
}
}
}
};
},{}],22:[function(require,module,exports){
var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
var slice = Array.prototype.slice;
var toStr = Object.prototype.toString;
var funcType = '[object Function]';
module.exports = function bind(that) {
var target = this;
if (typeof target !== 'function' || toStr.call(target) !== funcType) {
throw new TypeError(ERROR_MESSAGE + target);
}
var args = slice.call(arguments, 1);
var bound;
var binder = function () {
if (this instanceof bound) {
var result = target.apply(
this,
args.concat(slice.call(arguments))
);
if (Object(result) === result) {
return result;
}
return this;
} else {
return target.apply(
that,
args.concat(slice.call(arguments))
);
}
};
var boundLength = Math.max(0, target.length - args.length);
var boundArgs = [];
for (var i = 0; i < boundLength; i++) {
boundArgs.push('$' + i);
}
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
if (target.prototype) {
var Empty = function Empty() {};
Empty.prototype = target.prototype;
bound.prototype = new Empty();
Empty.prototype = null;
}
return bound;
};
},{}],23:[function(require,module,exports){
var implementation = require('./implementation');
module.exports = Function.prototype.bind || implementation;
},{"./implementation":22}],24:[function(require,module,exports){
var bind = require('function-bind');
module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
},{"function-bind":23}],25:[function(require,module,exports){
'use strict';
var fnToStr = Function.prototype.toString;
var constructorRegex = /^\s*class /;
var isES6ClassFn = function isES6ClassFn(value) {
try {
var fnStr = fnToStr.call(value);
var singleStripped = fnStr.replace(/\/\/.*\n/g, '');
var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, '');
var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' ');
return constructorRegex.test(spaceStripped);
} catch (e) {
return false; // not a function
}
};
var tryFunctionObject = function tryFunctionObject(value) {
try {
if (isES6ClassFn(value)) { return false; }
fnToStr.call(value);
return true;
} catch (e) {
return false;
}
};
var toStr = Object.prototype.toString;
var fnClass = '[object Function]';
var genClass = '[object GeneratorFunction]';
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
module.exports = function isCallable(value) {
if (!value) { return false; }
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
if (hasToStringTag) { return tryFunctionObject(value); }
if (isES6ClassFn(value)) { return false; }
var strClass = toStr.call(value);
return strClass === fnClass || strClass === genClass;
};
},{}],26:[function(require,module,exports){
'use strict';
var getDay = Date.prototype.getDay;
var tryDateObject = function tryDateObject(value) {
try {
getDay.call(value);
return true;
} catch (e) {
return false;
}
};
var toStr = Object.prototype.toString;
var dateClass = '[object Date]';
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
module.exports = function isDateObject(value) {
if (typeof value !== 'object' || value === null) { return false; }
return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
};
},{}],27:[function(require,module,exports){
'use strict';
var regexExec = RegExp.prototype.exec;
var tryRegexExec = function tryRegexExec(value) {
try {
regexExec.call(value);
return true;
} catch (e) {
return false;
}
};
var toStr = Object.prototype.toString;
var regexClass = '[object RegExp]';
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
module.exports = function isRegex(value) {
if (typeof value !== 'object') { return false; }
return hasToStringTag ? tryRegexExec(value) : toStr.call(value) === regexClass;
};
},{}],28:[function(require,module,exports){
'use strict';
var toStr = Object.prototype.toString;
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
if (hasSymbols) {
var symToStr = Symbol.prototype.toString;
var symStringRegex = /^Symbol\(.*\)$/;
var isSymbolObject = function isSymbolObject(value) {
if (typeof value.valueOf() !== 'symbol') { return false; }
return symStringRegex.test(symToStr.call(value));
};
module.exports = function isSymbol(value) {
if (typeof value === 'symbol') { return true; }
if (toStr.call(value) !== '[object Symbol]') { return false; }
try {
return isSymbolObject(value);
} catch (e) {
return false;
}
};
} else {
module.exports = function isSymbol(value) {
// this environment does not support Symbols.
return false;
};
}
},{}],29:[function(require,module,exports){
'use strict';
// modified from https://github.com/es-shims/es5-shim
var has = Object.prototype.hasOwnProperty;
var toStr = Object.prototype.toString;
var slice = Array.prototype.slice;
var isArgs = require('./isArguments');
var isEnumerable = Object.prototype.propertyIsEnumerable;
var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
var dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
];
var equalsConstructorPrototype = function (o) {
var ctor = o.constructor;
return ctor && ctor.prototype === o;
};
var excludedKeys = {
$console: true,
$external: true,
$frame: true,
$frameElement: true,
$frames: true,
$innerHeight: true,
$innerWidth: true,
$outerHeight: true,
$outerWidth: true,
$pageXOffset: true,
$pageYOffset: true,
$parent: true,
$scrollLeft: true,
$scrollTop: true,
$scrollX: true,
$scrollY: true,
$self: true,
$webkitIndexedDB: true,
$webkitStorageInfo: true,
$window: true
};
var hasAutomationEqualityBug = (function () {
/* global window */
if (typeof window === 'undefined') { return false; }
for (var k in window) {
try {
if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
try {
equalsConstructorPrototype(window[k]);
} catch (e) {
return true;
}
}
} catch (e) {
return true;
}
}
return false;
}());
var equalsConstructorPrototypeIfNotBuggy = function (o) {
/* global window */
if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
return equalsConstructorPrototype(o);
}
try {
return equalsConstructorPrototype(o);
} catch (e) {
return false;
}
};
var keysShim = function keys(object) {
var isObject = object !== null && typeof object === 'object';
var isFunction = toStr.call(object) === '[object Function]';
var isArguments = isArgs(object);
var isString = isObject && toStr.call(object) === '[object String]';
var theKeys = [];
if (!isObject && !isFunction && !isArguments) {
throw new TypeError('Object.keys called on a non-object');
}
var skipProto = hasProtoEnumBug && isFunction;
if (isString && object.length > 0 && !has.call(object, 0)) {
for (var i = 0; i < object.length; ++i) {
theKeys.push(String(i));
}
}
if (isArguments && object.length > 0) {
for (var j = 0; j < object.length; ++j) {
theKeys.push(String(j));
}
} else {
for (var name in object) {
if (!(skipProto && name === 'prototype') && has.call(object, name)) {
theKeys.push(String(name));
}
}
}
if (hasDontEnumBug) {
var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
for (var k = 0; k < dontEnums.length; ++k) {
if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
theKeys.push(dontEnums[k]);
}
}
}
return theKeys;
};
keysShim.shim = function shimObjectKeys() {
if (Object.keys) {
var keysWorksWithArguments = (function () {
// Safari 5.0 bug
return (Object.keys(arguments) || '').length === 2;
}(1, 2));
if (!keysWorksWithArguments) {
var originalKeys = Object.keys;
Object.keys = function keys(object) {
if (isArgs(object)) {
return originalKeys(slice.call(object));
} else {
return originalKeys(object);
}
};
}
} else {
Object.keys = keysShim;
}
return Object.keys || keysShim;
};
module.exports = keysShim;
},{"./isArguments":30}],30:[function(require,module,exports){
'use strict';
var toStr = Object.prototype.toString;
module.exports = function isArguments(value) {
var str = toStr.call(value);
var isArgs = str === '[object Arguments]';
if (!isArgs) {
isArgs = str !== '[object Array]' &&
value !== null &&
typeof value === 'object' &&
typeof value.length === 'number' &&
value.length >= 0 &&
toStr.call(value.callee) === '[object Function]';
}
return isArgs;
};
},{}],31:[function(require,module,exports){
'use strict';
var ES = require('es-abstract/es7');
var has = require('has');
var bind = require('function-bind');
var isEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
module.exports = function entries(O) {
var obj = ES.RequireObjectCoercible(O);
var entrys = [];
for (var key in obj) {
if (has(obj, key) && isEnumerable(obj, key)) {
entrys.push([key, obj[key]]);
}
}
return entrys;
};
},{"es-abstract/es7":8,"function-bind":23,"has":24}],32:[function(require,module,exports){
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof Object.entries === 'function' ? Object.entries : implementation;
};
},{"./implementation":31}],33:[function(require,module,exports){
'use strict';
var getPolyfill = require('./polyfill');
var define = require('define-properties');
module.exports = function shimEntries() {
var polyfill = getPolyfill();
define(Object, { entries: polyfill }, {
entries: function testEntries() {
return Object.entries !== polyfill;
}
});
return polyfill;
};
},{"./polyfill":32,"define-properties":5}],34:[function(require,module,exports){
'use strict';
var ES = require('es-abstract/es7');
var defineProperty = Object.defineProperty;
var getDescriptor = Object.getOwnPropertyDescriptor;
var getOwnNames = Object.getOwnPropertyNames;
var getSymbols = Object.getOwnPropertySymbols;
var concat = Function.call.bind(Array.prototype.concat);
var reduce = Function.call.bind(Array.prototype.reduce);
var getAll = getSymbols ? function (obj) {
return concat(getOwnNames(obj), getSymbols(obj));
} : getOwnNames;
var isES5 = ES.IsCallable(getDescriptor) && ES.IsCallable(getOwnNames);
var safePut = function put(obj, prop, val) { // eslint-disable-line max-params
if (defineProperty && prop in obj) {
defineProperty(obj, prop, {
configurable: true,
enumerable: true,
value: val,
writable: true
});
} else {
obj[prop] = val;
}
};
module.exports = function getOwnPropertyDescriptors(value) {
ES.RequireObjectCoercible(value);
if (!isES5) {
throw new TypeError('getOwnPropertyDescriptors requires Object.getOwnPropertyDescriptor');
}
var O = ES.ToObject(value);
return reduce(getAll(O), function (acc, key) {
var descriptor = getDescriptor(O, key);
if (typeof descriptor !== 'undefined') {
safePut(acc, key, descriptor);
}
return acc;
}, {});
};
},{"es-abstract/es7":8}],35:[function(require,module,exports){
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof Object.getOwnPropertyDescriptors === 'function' ? Object.getOwnPropertyDescriptors : implementation;
};
},{"./implementation":34}],36:[function(require,module,exports){
'use strict';
var getPolyfill = require('./polyfill');
var define = require('define-properties');
module.exports = function shimGetOwnPropertyDescriptors() {
var polyfill = getPolyfill();
define(
Object,
{ getOwnPropertyDescriptors: polyfill },
{ getOwnPropertyDescriptors: function () { return Object.getOwnPropertyDescriptors !== polyfill; } }
);
return polyfill;
};
},{"./polyfill":35,"define-properties":5}],37:[function(require,module,exports){
'use strict';
var ES = require('es-abstract/es7');
var has = require('has');
var bind = require('function-bind');
var isEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
module.exports = function values(O) {
var obj = ES.RequireObjectCoercible(O);
var vals = [];
for (var key in obj) {
if (has(obj, key) && isEnumerable(obj, key)) {
vals.push(obj[key]);
}
}
return vals;
};
},{"es-abstract/es7":8,"function-bind":23,"has":24}],38:[function(require,module,exports){
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof Object.values === 'function' ? Object.values : implementation;
};
},{"./implementation":37}],39:[function(require,module,exports){
'use strict';
var getPolyfill = require('./polyfill');
var define = require('define-properties');
module.exports = function shimValues() {
var polyfill = getPolyfill();
define(Object, { values: polyfill }, {
values: function testValues() {
return Object.values !== polyfill;
}
});
return polyfill;
};
},{"./polyfill":38,"define-properties":5}],40:[function(require,module,exports){
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
},{}],41:[function(require,module,exports){
'use strict';
var bind = require('function-bind');
var ES = require('es-abstract/es7');
var slice = bind.call(Function.call, String.prototype.slice);
module.exports = function padEnd(maxLength) {
var O = ES.RequireObjectCoercible(this);
var S = ES.ToString(O);
var stringLength = ES.ToLength(S.length);
var fillString;
if (arguments.length > 1) {
fillString = arguments[1];
}
var filler = typeof fillString === 'undefined' ? '' : ES.ToString(fillString);
if (filler === '') {
filler = ' ';
}
var intMaxLength = ES.ToLength(maxLength);
if (intMaxLength <= stringLength) {
return S;
}
var fillLen = intMaxLength - stringLength;
while (filler.length < fillLen) {
var fLen = filler.length;
var remainingCodeUnits = fillLen - fLen;
filler += fLen > remainingCodeUnits ? slice(filler, 0, remainingCodeUnits) : filler;
}
var truncatedStringFiller = filler.length > fillLen ? slice(filler, 0, fillLen) : filler;
return S + truncatedStringFiller;
};
},{"es-abstract/es7":8,"function-bind":23}],42:[function(require,module,exports){
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof String.prototype.padEnd === 'function' ? String.prototype.padEnd : implementation;
};
},{"./implementation":41}],43:[function(require,module,exports){
'use strict';
var getPolyfill = require('./polyfill');
var define = require('define-properties');
module.exports = function shimPadEnd() {
var polyfill = getPolyfill();
define(String.prototype, { padEnd: polyfill }, { padEnd: function () { return String.prototype.padEnd !== polyfill; } });
return polyfill;
};
},{"./polyfill":42,"define-properties":5}],44:[function(require,module,exports){
'use strict';
var bind = require('function-bind');
var ES = require('es-abstract/es7');
var slice = bind.call(Function.call, String.prototype.slice);
module.exports = function padStart(maxLength) {
var O = ES.RequireObjectCoercible(this);
var S = ES.ToString(O);
var stringLength = ES.ToLength(S.length);
var fillString;
if (arguments.length > 1) {
fillString = arguments[1];
}
var filler = typeof fillString === 'undefined' ? '' : ES.ToString(fillString);
if (filler === '') {
filler = ' ';
}
var intMaxLength = ES.ToLength(maxLength);
if (intMaxLength <= stringLength) {
return S;
}
var fillLen = intMaxLength - stringLength;
while (filler.length < fillLen) {
var fLen = filler.length;
var remainingCodeUnits = fillLen - fLen;
filler += fLen > remainingCodeUnits ? slice(filler, 0, remainingCodeUnits) : filler;
}
var truncatedStringFiller = filler.length > fillLen ? slice(filler, 0, fillLen) : filler;
return truncatedStringFiller + S;
};
},{"es-abstract/es7":8,"function-bind":23}],45:[function(require,module,exports){
'use strict';
var implementation = require('./implementation');
module.exports = function getPolyfill() {
return typeof String.prototype.padStart === 'function' ? String.prototype.padStart : implementation;
};
},{"./implementation":44}],46:[function(require,module,exports){
'use strict';
var getPolyfill = require('./polyfill');
var define = require('define-properties');
module.exports = function shimPadStart() {
var polyfill = getPolyfill();
define(String.prototype, { padStart: polyfill }, { padStart: function () { return String.prototype.padStart !== polyfill; } });
return polyfill;
};
},{"./polyfill":45,"define-properties":5}]},{},[1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment