summaryrefslogtreecommitdiffstats
path: root/js/vendor/es6-shim/es6-shim.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/vendor/es6-shim/es6-shim.js')
-rw-r--r--js/vendor/es6-shim/es6-shim.js112
1 files changed, 58 insertions, 54 deletions
diff --git a/js/vendor/es6-shim/es6-shim.js b/js/vendor/es6-shim/es6-shim.js
index 3d7de0c79..1f49f68d0 100644
--- a/js/vendor/es6-shim/es6-shim.js
+++ b/js/vendor/es6-shim/es6-shim.js
@@ -2,8 +2,8 @@
* 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.34.4
- * see https://github.com/paulmillr/es6-shim/blob/0.34.4/LICENSE
+ * es6-shim: v0.35.0
+ * see https://github.com/paulmillr/es6-shim/blob/0.35.0/LICENSE
* Details and documentation:
* https://github.com/paulmillr/es6-shim/
*/
@@ -183,6 +183,7 @@
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);
@@ -262,7 +263,7 @@
// Reflect
if (!globals.Reflect) {
- defineProperty(globals, 'Reflect', {});
+ defineProperty(globals, 'Reflect', {}, true);
}
var Reflect = globals.Reflect;
@@ -1059,48 +1060,6 @@
return _concat(ownKeys, keys);
};
- var ObjectIterator = function (object, kind) {
- defineProperties(this, {
- object: object,
- array: getAllKeys(object),
- kind: kind
- });
- };
-
- defineProperties(ObjectIterator.prototype, {
- next: function next() {
- var key;
- var array = this.array;
-
- if (!(this instanceof ObjectIterator)) {
- throw new TypeError('Not an ObjectIterator');
- }
-
- // Find next key in the object
- while (array.length > 0) {
- key = _shift(array);
-
- // The candidate key isn't defined on object.
- // Must have been deleted, or object[[Prototype]]
- // has been modified.
- if (!(key in this.object)) {
- continue;
- }
-
- if (this.kind === 'key') {
- return iteratorResult(key);
- } else if (this.kind === 'value') {
- return iteratorResult(this.object[key]);
- } else {
- return iteratorResult([key, this.object[key]]);
- }
- }
-
- return iteratorResult();
- }
- });
- addIterator(ObjectIterator.prototype);
-
// note: this is positioned here because it depends on ArrayIterator
var arrayOfSupportsSubclassing = Array.of === ArrayShims.of || (function () {
// Detects a bug in Webkit nightly r181886
@@ -1242,6 +1201,18 @@
}
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.
@@ -1603,6 +1574,23 @@
});
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'); });
@@ -1743,6 +1731,26 @@
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') || {};
@@ -1949,8 +1957,9 @@
tanh: function tanh(value) {
var x = Number(value);
if (Number.isNaN(x) || x === 0) { return x; }
- if (x === Infinity) { return 1; }
- if (x === -Infinity) { return -1; }
+ // 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; }
var a = Math.expm1(x);
var b = Math.expm1(-x);
if (a === Infinity) { return 1; }
@@ -3379,11 +3388,6 @@
return delete target[key];
},
- enumerate: function enumerate(target) {
- throwUnlessTargetIsObject(target);
- return new ObjectIterator(target, 'key');
- },
-
has: function has(target, key) {
throwUnlessTargetIsObject(target);
return key in target;
@@ -3603,8 +3607,8 @@
Object.keys(ReflectShims).forEach(function (key) {
defineOrOverrideReflectProperty(key, ReflectShims[key]);
});
- if (functionsHaveNames && globals.Reflect.getPrototypeOf.name !== 'getPrototypeOf') {
- var originalReflectGetProto = globals.Reflect.getPrototypeOf;
+ var originalReflectGetProto = globals.Reflect.getPrototypeOf;
+ if (functionsHaveNames && originalReflectGetProto && originalReflectGetProto.name !== 'getPrototypeOf') {
overrideNative(globals.Reflect, 'getPrototypeOf', function getPrototypeOf(target) {
return _call(originalReflectGetProto, globals.Reflect, target);
});