[Pkg-javascript-commits] [node-es6-shim] 04/09: Imported Upstream version 0.35.1+ds
Julien Puydt
julien.puydt at laposte.net
Sun May 29 11:36:11 UTC 2016
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to branch master
in repository node-es6-shim.
commit 92d1b66cb61a74f0f3af2755a6c84f13e0e5c7b3
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Sat May 14 16:02:35 2016 +0200
Imported Upstream version 0.35.1+ds
---
.eslintrc | 9 +-
.jscs.json | 17 +++-
.travis.yml | 14 ++-
CHANGELOG.md | 16 ++++
component.json | 2 +-
es6-sham.js | 8 +-
es6-sham.map | 2 +-
es6-sham.min.js | 4 +-
es6-shim.js | 219 +++++++++++++++++++++++++------------------
es6-shim.map | 2 +-
es6-shim.min.js | 8 +-
package.json | 43 ++++-----
test-sham/function.js | 2 +-
test/.eslintrc | 6 ++
test/array.js | 38 ++++++--
test/browser-onload.js | 2 +-
test/map.js | 8 +-
test/math.js | 18 ++--
test/number.js | 10 +-
test/promise/all.js | 42 ++++-----
test/promise/promises-es6.js | 33 ++++---
test/promise/race.js | 4 +-
test/promise/reject.js | 4 +-
test/promise/resolve.js | 4 +-
test/promise/simple.js | 4 +-
test/promise/subclass.js | 2 +-
test/reflect.js | 3 +-
test/regexp.js | 7 +-
test/string.js | 31 +++---
29 files changed, 348 insertions(+), 214 deletions(-)
diff --git a/.eslintrc b/.eslintrc
index e83d7a2..aaa44b4 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -3,11 +3,6 @@
"extends": "@ljharb",
- "ecmaFeatures": {
- "regexYFlag": true,
- "regexUFlag": true
- },
-
"rules": {
"callback-return": [0],
"complexity": [1],
@@ -16,6 +11,7 @@
"eqeqeq": [2, "allow-null"],
"global-require": [0],
"id-length": [2, { "min": 1, "max": 40 }],
+ "indent": [2, 2],
"max-depth": [2, 5],
"max-params": [2, 4],
"max-nested-callbacks": [2, 5],
@@ -24,7 +20,7 @@
"no-constant-condition": [1],
"no-continue": [1],
"no-extend-native": [2, { "exceptions": ["Set"] }],
- "no-extra-parens": [0],
+ "no-extra-parens": [1],
"no-func-assign": [1],
"no-implicit-coercion": [2, {
"boolean": false,
@@ -32,6 +28,7 @@
"string": true
}],
"no-invalid-this": [0],
+ "no-invalid-regexp": [2, { "allowConstructorFlags": ["u", "y"] }],
"no-magic-numbers": [0],
"no-native-reassign": [2, { "exceptions": ["Number", "Promise", "RegExp"] }],
"no-negated-condition": [1],
diff --git a/.jscs.json b/.jscs.json
index e457533..1d98325 100644
--- a/.jscs.json
+++ b/.jscs.json
@@ -44,7 +44,7 @@
"disallowSpacesInsideArrayBrackets": true,
- "disallowQuotedKeysInObjects": "allButReserved",
+ "disallowQuotedKeysInObjects": { "allExcept": ["reserved"] },
"disallowSpaceAfterObjectKeys": true,
@@ -157,6 +157,19 @@
"requireImportAlphabetized": false,
- "disallowSpacesInsideTemplateStringPlaceholders": true
+ "requireSpaceBeforeObjectValues": true,
+ "requireSpaceBeforeDestructuredValues": true,
+
+ "disallowSpacesInsideTemplateStringPlaceholders": true,
+
+ "disallowArrayDestructuringReturn": false,
+
+ "requireNewlineBeforeSingleStatementsInIf": false,
+
+ "disallowUnusedVariables": true,
+
+ "requireSpacesInsideImportedObjectBraces": true,
+
+ "requireUseStrict": false
}
diff --git a/.travis.yml b/.travis.yml
index a96127e..fa8eab8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,11 @@
language: node_js
node_js:
+ - "6.1"
+ - "6.0"
+ - "5.11"
+ - "5.10"
+ - "5.9"
+ - "5.8"
- "5.7"
- "5.6"
- "5.5"
@@ -8,6 +14,7 @@ node_js:
- "5.2"
- "5.1"
- "5.0"
+ - "4.4"
- "4.3"
- "4.2"
- "4.1"
@@ -58,6 +65,11 @@ matrix:
- node_js: "0.12"
env: TRAVIS_RUN_SAUCE=false TRAVIS_RUN_LINT_ONLY=false
allow_failures:
+ - node_js: "6.0"
+ - node_js: "5.10"
+ - node_js: "5.9"
+ - node_js: "5.8"
+ - node_js: "5.7"
- node_js: "5.6"
- node_js: "5.5"
- node_js: "5.4"
@@ -65,6 +77,7 @@ matrix:
- node_js: "5.2"
- node_js: "5.1"
- node_js: "5.0"
+ - node_js: "4.3"
- node_js: "4.2"
- node_js: "4.1"
- node_js: "4.0"
@@ -86,7 +99,6 @@ matrix:
- node_js: "iojs-v1.0"
- node_js: "0.11"
- node_js: "0.9"
- - node_js: "0.8"
- node_js: "0.6"
- node_js: "0.4"
- node_js: "0.12"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 33d5312..184c526 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,19 @@
+# es6-shim 0.35.1 (12 May 2016)
+* [Fix] Functions are objects (#418)
+* [Fix] use `createDataPropertyOrThrow` in `Array.from`, rather than `[[Put]]` (#415)
+* [Refactor] Use `iteratorResult` internally for iterator result objects
+* [Refactor] Simplify logic for Math.tanh (#412)
+* [Robustness] cache `Math` constants
+* [Robustness] cache `Math.exp`
+* [Robustness] don’t rely on a `Math` lookup inside `Math.asinh`
+* [Robustness] use cached `Number.isNaN`
+* [Robustness] cache `Math.sign`
+* [Dev Deps] update `es5-shim`, `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js`, `grunt-contrib-connect`, `grunt-contrib-watch`, `evalmd`, `jshint`
+* [Tests] up to `node` `v6.1`, `v5.10`, `v4.4`
+* [Tests] `npm run --silent`, use “pretest” for linting
+* [Tests] `RegExp#toString`: Chrome Canary 51 produces `/undefined/`
+* [Docs] update ES6 draft comment URLs to point to the published spec
+
# es6-shim 0.35.0 (29 Feb 2016)
* [Breaking] remove `Reflect.enumerate` (#405)
* [New] Add `Array#indexOf` from post-ES6 errata
diff --git a/component.json b/component.json
index 14307f9..5438e24 100644
--- a/component.json
+++ b/component.json
@@ -1,6 +1,6 @@
{
"name": "es6-shim",
- "version": "0.35.0",
+ "version": "0.35.1",
"repo": "paulmillr/es6-shim",
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
"keywords": [
diff --git a/es6-sham.js b/es6-sham.js
index ec8025a..00f6b55 100644
--- a/es6-sham.js
+++ b/es6-sham.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-sham: v0.35.0
- * see https://github.com/paulmillr/es6-shim/blob/0.35.0/LICENSE
+ * es6-sham: v0.35.1
+ * see https://github.com/paulmillr/es6-shim/blob/0.35.1/LICENSE
* Details and documentation:
* https://github.com/paulmillr/es6-shim/
*/
@@ -49,7 +49,9 @@
};
var arePropertyDescriptorsSupported = function () {
// if Object.defineProperty exists but throws, it's IE 8
- return !throwsError(function () { Object.defineProperty({}, 'x', { get: function () {} }); });
+ return !throwsError(function () {
+ Object.defineProperty({}, 'x', { get: function () {} });
+ });
};
var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
diff --git a/es6-sham.map b/es6-sham.map
index dbca586..3362c81 100644
--- a/es6-sham.map
+++ b/es6-sham.map
@@ -1 +1 @@
-{"version":3,"sources":["es6-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","getGlobal","Function","globals","Object","_call","call","bind","functionToString","toString","_strMatch","String","prototype","match","throwsError","func","e","arePropertyDescriptorsSupported","defineProperty","get","supportsDescriptors","setPrototypeOf","getOwnPropertyNames","getOwnPropertyDescriptor","create","getPrototypeOf","objProto","copyDescriptors","target"," [...]
\ No newline at end of file
+{"version":3,"sources":["es6-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","getGlobal","Function","globals","Object","_call","call","bind","functionToString","toString","_strMatch","String","prototype","match","throwsError","func","e","arePropertyDescriptorsSupported","defineProperty","get","supportsDescriptors","setPrototypeOf","getOwnPropertyNames","getOwnPropertyDescriptor","create","getPrototypeOf","objProto","copyDescriptors","target"," [...]
\ No newline at end of file
diff --git a/es6-sham.min.js b/es6-sham.min.js
index d8d3c36..d31f374 100644
--- a/es6-sham.min.js
+++ b/es6-sham.min.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-sham: v0.35.0
- * see https://github.com/paulmillr/es6-shim/blob/0.35.0/LICENSE
+ * es6-sham: v0.35.1
+ * see https://github.com/paulmillr/es6-shim/blob/0.35.1/LICENSE
* Details and documentation:
* https://github.com/paulmillr/es6-shim/
*/
diff --git a/es6-shim.js b/es6-shim.js
index 1f49f68..d9b8758 100644
--- a/es6-shim.js
+++ b/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.35.0
- * see https://github.com/paulmillr/es6-shim/blob/0.35.0/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/
*/
@@ -33,7 +33,9 @@
var keys = Object.keys;
var not = function notThunker(func) {
- return function notThunk() { return !_apply(func, this, arguments); };
+ return function notThunk() {
+ return !_apply(func, this, arguments);
+ };
};
var throwsError = function (func) {
try {
@@ -54,10 +56,12 @@
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 () {} }); });
+ return !throwsError(function () {
+ Object.defineProperty({}, 'x', { get: function () {} });
+ });
};
var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
- var functionsHaveNames = (function foo() {}).name === 'foo';
+ 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);
@@ -185,7 +189,7 @@
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 _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);
@@ -194,6 +198,7 @@
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);
@@ -214,6 +219,12 @@
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
@@ -232,7 +243,6 @@
var Type = {
primitive: function (x) { return x === null || (typeof x !== 'function' && typeof x !== 'object'); },
- object: function (x) { return x !== null && typeof x === 'object'; },
string: function (x) { return _toString(x) === '[object String]'; },
regex: function (x) { return _toString(x) === '[object RegExp]'; },
symbol: function (x) {
@@ -270,7 +280,7 @@
var $String = String;
var ES = {
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args
+ // 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)) {
@@ -390,7 +400,7 @@
},
IteratorComplete: function (iterResult) {
- return !!(iterResult.done);
+ return !!iterResult.done;
},
IteratorClose: function (iterator, completionIsThrow) {
@@ -685,7 +695,9 @@
// 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); });
+ overrideNative(String, 'fromCodePoint', function fromCodePoint(codePoints) {
+ return ES.Call(originalFromCodePoint, this, arguments);
+ });
}
var StringShims = {
@@ -811,7 +823,7 @@
var length = thisStr.length;
if (position >= 0 && position < length) {
var first = thisStr.charCodeAt(position);
- var isEnd = (position + 1 === length);
+ 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; }
@@ -883,19 +895,28 @@
var hasStringTrimBug = nonWS.trim().length !== nonWS.length;
defineProperty(String.prototype, 'trim', trimShim, hasStringTrimBug);
- // see https://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype-@@iterator
+ // 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, i = this._i;
+ var s = this._s;
+ var i = this._i;
if (typeof s === 'undefined' || i >= s.length) {
this._s = void 0;
- return { value: void 0, done: true };
+ return iteratorResult();
}
- var first = s.charCodeAt(i), second, len;
+ var first = s.charCodeAt(i);
+ var second, len;
if (first < 0xD800 || first > 0xDBFF || (i + 1) === s.length) {
len = 1;
} else {
@@ -903,7 +924,7 @@
len = (second < 0xDC00 || second > 0xDFFF) ? 1 : 2;
}
this._i = i + len;
- return { value: s.substr(i, len), done: false };
+ return iteratorResult(s.substr(i, len));
};
addIterator(StringIterator.prototype);
addIterator(String.prototype, function () {
@@ -969,7 +990,7 @@
if (mapping) {
value = typeof T === 'undefined' ? mapFn(value, i) : _call(mapFn, T, value, i);
}
- result[i] = value;
+ createDataPropertyOrThrow(result, i, value);
}
}
@@ -991,24 +1012,18 @@
defineProperties(Array, ArrayShims);
addDefaultSpecies(Array);
- // 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 };
- };
-
// 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;
+ this.i = 0;
+ this.array = array;
+ this.kind = kind;
};
defineProperties(ArrayIterator.prototype, {
next: function () {
- var i = this.i, array = this.array;
+ var i = this.i;
+ var array = this.array;
if (!(this instanceof ArrayIterator)) {
throw new TypeError('Not an ArrayIterator');
}
@@ -1025,15 +1040,16 @@
retval = [i, array[i]];
}
this.i = i + 1;
- return { value: retval, done: false };
+ return iteratorResult(retval);
}
}
this.array = void 0;
- return { value: void 0, done: true };
+ 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;
@@ -1047,6 +1063,7 @@
return a.localeCompare(b);
}
};
+
var getAllKeys = function getAllKeys(object) {
var ownKeys = [];
var keys = [];
@@ -1059,6 +1076,7 @@
return _concat(ownKeys, keys);
};
+ */
// note: this is positioned here because it depends on ArrayIterator
var arrayOfSupportsSubclassing = Array.of === ArrayShims.of || (function () {
@@ -1139,7 +1157,9 @@
for (var i = 0, value; i < length; i++) {
value = list[i];
if (thisArg) {
- if (_call(predicate, thisArg, value, i, list)) { return value; }
+ if (_call(predicate, thisArg, value, i, list)) {
+ return value;
+ }
} else if (predicate(value, i, list)) {
return value;
}
@@ -1155,7 +1175,9 @@
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; }
+ if (_call(predicate, thisArg, list[i], i, list)) {
+ return i;
+ }
} else if (predicate(list[i], i, list)) {
return i;
}
@@ -1224,7 +1246,9 @@
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; });
+ return valueOrFalseIfThrows(function () {
+ return Array.from({ length: -1 }).length === 0;
+ });
}());
var arrayFromHandlesIterables = (function () {
// Detects a bug in Webkit nightly r181886
@@ -1237,7 +1261,9 @@
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); });
+ return valueOrFalseIfThrows(function () {
+ return Array.from([0], void 0);
+ });
}());
if (!arrayFromHandlesUndefinedMapFunction) {
var origArrayFrom = Array.from;
@@ -1253,7 +1279,7 @@
var int32sAsOne = -(Math.pow(2, 32) - 1);
var toLengthsCorrectly = function (method, reversed) {
var obj = { length: int32sAsOne };
- obj[reversed ? ((obj.length >>> 0) - 1) : 0] = true;
+ obj[reversed ? (obj.length >>> 0) - 1 : 0] = true;
return valueOrFalseIfThrows(function () {
_call(method, obj, function () {
// note: in nonconforming browsers, this will be called
@@ -1553,7 +1579,8 @@
Object.getPrototypeOf(Object.create(null)) === null) {
(function () {
var FAKENULL = Object.create(null);
- var gpo = Object.getPrototypeOf, spo = Object.setPrototypeOf;
+ var gpo = Object.getPrototypeOf;
+ var spo = Object.setPrototypeOf;
Object.getPrototypeOf = function (o) {
var result = gpo(o);
return result === FAKENULL ? null : result;
@@ -1585,7 +1612,7 @@
_push(regexKeys, k);
}
}
- return regexKeys;
+ return regexKeys;
}
return regexRejectingObjectKeys(value);
});
@@ -1625,7 +1652,7 @@
if (!objectSealAcceptsPrimitives) {
var originalObjectSeal = Object.seal;
overrideNative(Object, 'seal', function seal(value) {
- if (!Type.object(value)) { return value; }
+ if (!ES.TypeIsObject(value)) { return value; }
return originalObjectSeal(value);
});
}
@@ -1635,7 +1662,7 @@
if (!objectIsSealedAcceptsPrimitives) {
var originalObjectIsSealed = Object.isSealed;
overrideNative(Object, 'isSealed', function isSealed(value) {
- if (!Type.object(value)) { return true; }
+ if (!ES.TypeIsObject(value)) { return true; }
return originalObjectIsSealed(value);
});
}
@@ -1645,7 +1672,7 @@
if (!objectFreezeAcceptsPrimitives) {
var originalObjectFreeze = Object.freeze;
overrideNative(Object, 'freeze', function freeze(value) {
- if (!Type.object(value)) { return value; }
+ if (!ES.TypeIsObject(value)) { return value; }
return originalObjectFreeze(value);
});
}
@@ -1655,7 +1682,7 @@
if (!objectIsFrozenAcceptsPrimitives) {
var originalObjectIsFrozen = Object.isFrozen;
overrideNative(Object, 'isFrozen', function isFrozen(value) {
- if (!Type.object(value)) { return true; }
+ if (!ES.TypeIsObject(value)) { return true; }
return originalObjectIsFrozen(value);
});
}
@@ -1665,7 +1692,7 @@
if (!objectPreventExtensionsAcceptsPrimitives) {
var originalObjectPreventExtensions = Object.preventExtensions;
overrideNative(Object, 'preventExtensions', function preventExtensions(value) {
- if (!Type.object(value)) { return value; }
+ if (!ES.TypeIsObject(value)) { return value; }
return originalObjectPreventExtensions(value);
});
}
@@ -1675,7 +1702,7 @@
if (!objectIsExtensibleAcceptsPrimitives) {
var originalObjectIsExtensible = Object.isExtensible;
overrideNative(Object, 'isExtensible', function isExtensible(value) {
- if (!Type.object(value)) { return false; }
+ if (!ES.TypeIsObject(value)) { return false; }
return originalObjectIsExtensible(value);
});
}
@@ -1818,16 +1845,19 @@
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 (Number.isNaN(x) || value < 1) { return NaN; }
+ if (numberIsNaN(x) || value < 1) { return NaN; }
if (x === 1) { return 0; }
if (x === Infinity) { return x; }
- return _log(x / Math.E + _sqrt(x + 1) * _sqrt(x - 1) / Math.E) + 1;
+ return _log(x / E + _sqrt(x + 1) * _sqrt(x - 1) / E) + 1;
},
asinh: function asinh(value) {
@@ -1835,12 +1865,12 @@
if (x === 0 || !globalIsFinite(x)) {
return x;
}
- return x < 0 ? -Math.asinh(-x) : _log(x + _sqrt(x * x + 1));
+ return x < 0 ? -asinh(-x) : _log(x + _sqrt(x * x + 1));
},
atanh: function atanh(value) {
var x = Number(value);
- if (Number.isNaN(x) || x < -1 || x > 1) {
+ if (numberIsNaN(x) || x < -1 || x > 1) {
return NaN;
}
if (x === -1) { return -Infinity; }
@@ -1852,12 +1882,13 @@
cbrt: function cbrt(value) {
var x = Number(value);
if (x === 0) { return x; }
- var negate = x < 0, result;
+ var negate = x < 0;
+ var result;
if (negate) { x = -x; }
if (x === Infinity) {
result = Infinity;
} else {
- result = Math.exp(_log(x) / 3);
+ result = _exp(_log(x) / 3);
// from http://en.wikipedia.org/wiki/Cube_root#Numerical_methods
result = (x / (result * result) + (2 * result)) / 3;
}
@@ -1871,17 +1902,17 @@
if (number === 0) {
return 32;
}
- return numberCLZ ? ES.Call(numberCLZ, number) : 31 - _floor(_log(number + 0.5) * Math.LOG2E);
+ 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 (Number.isNaN(x)) { return NaN; }
+ if (numberIsNaN(x)) { return NaN; }
if (!globalIsFinite(x)) { return Infinity; }
if (x < 0) { x = -x; }
- if (x > 21) { return Math.exp(x) / 2; }
- return (Math.exp(x) + Math.exp(-x)) / 2;
+ if (x > 21) { return _exp(x) / 2; }
+ return (_exp(x) + _exp(-x)) / 2;
},
expm1: function expm1(value) {
@@ -1889,7 +1920,7 @@
if (x === -Infinity) { return -1; }
if (!globalIsFinite(x) || x === 0) { return x; }
if (_abs(x) > 0.5) {
- return Math.exp(x) - 1;
+ return _exp(x) - 1;
}
// A more precise approximation using Taylor series expansion
// from https://github.com/paulmillr/es6-shim/issues/314#issuecomment-70293986
@@ -1914,35 +1945,30 @@
result += 1;
largest = value;
} else {
- result += (value > 0 ? (value / largest) * (value / largest) : value);
+ result += value > 0 ? (value / largest) * (value / largest) : value;
}
}
return largest === Infinity ? Infinity : largest * _sqrt(result);
},
log2: function log2(value) {
- return _log(value) * Math.LOG2E;
+ return _log(value) * LOG2E;
},
log10: function log10(value) {
- return _log(value) * Math.LOG10E;
+ return _log(value) * LOG10E;
},
log1p: function log1p(value) {
var x = Number(value);
- if (x < -1 || Number.isNaN(x)) { return NaN; }
+ 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: function sign(value) {
- var number = Number(value);
- if (number === 0) { return number; }
- if (Number.isNaN(number)) { return number; }
- return number < 0 ? -1 : 1;
- },
+ sign: _sign,
sinh: function sinh(value) {
var x = Number(value);
@@ -1951,20 +1977,17 @@
if (_abs(x) < 1) {
return (Math.expm1(x) - Math.expm1(-x)) / 2;
}
- return (Math.exp(x - 1) - Math.exp(-x - 1)) * Math.E / 2;
+ return (_exp(x - 1) - _exp(-x - 1)) * E / 2;
},
tanh: function tanh(value) {
var x = Number(value);
- if (Number.isNaN(x) || x === 0) { return x; }
+ 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; }
- var a = Math.expm1(x);
- var b = Math.expm1(-x);
- if (a === Infinity) { return 1; }
- if (b === Infinity) { return -1; }
- return (a - b) / (Math.exp(x) + Math.exp(-x));
+
+ return (Math.expm1(x) - Math.expm1(-x)) / (_exp(x) + _exp(-x));
},
trunc: function trunc(value) {
@@ -1982,7 +2005,7 @@
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);
+ return (al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0;
},
fround: function fround(x) {
@@ -1990,7 +2013,7 @@
if (v === 0 || v === Infinity || v === -Infinity || numberIsNaN(v)) {
return v;
}
- var sign = Math.sign(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;
@@ -2027,7 +2050,7 @@
// 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 https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-number-type
+ // 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;
@@ -2347,7 +2370,9 @@
var performPromiseAll = function (iteratorRecord, C, resultCapability) {
var it = iteratorRecord.iterator;
- var values = [], remaining = { count: 1 }, next, nextValue;
+ var values = [];
+ var remaining = { count: 1 };
+ var next, nextValue;
var index = 0;
while (true) {
try {
@@ -2378,7 +2403,8 @@
};
var performPromiseRace = function (iteratorRecord, C, resultCapability) {
- var it = iteratorRecord.iterator, next, nextValue, nextPromise;
+ var it = iteratorRecord.iterator;
+ var next, nextValue, nextPromise;
while (true) {
try {
next = ES.IteratorStep(it);
@@ -2473,7 +2499,9 @@
}
if (ES.IsPromise(v)) {
var constructor = v.constructor;
- if (constructor === C) { return v; }
+ if (constructor === C) {
+ return v;
+ }
}
var capability = new PromiseCapability(C);
var resolveFunc = capability.resolve;
@@ -2786,15 +2814,18 @@
MapIterator.prototype = {
next: function next() {
- var i = this.i, kind = this.kind, head = this.head, result;
+ var i = this.i;
+ var kind = this.kind;
+ var head = this.head;
if (typeof this.i === 'undefined') {
- return { value: void 0, done: true };
+ 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()) {
@@ -2806,12 +2837,12 @@
result = [i.key, i.value];
}
this.i = i;
- return { value: result, done: false };
+ return iteratorResult(result);
}
}
// once the iterator is done, it is done forever.
this.i = void 0;
- return { value: void 0, done: true };
+ return iteratorResult();
}
};
addIterator(MapIterator.prototype);
@@ -2864,7 +2895,8 @@
return;
}
}
- var head = this._head, i = head;
+ var head = this._head;
+ var i = head;
while ((i = i.next) !== head) {
if (ES.SameValueZero(i.key, key)) {
return i.value;
@@ -2879,7 +2911,8 @@
// fast O(1) path
return typeof this._storage[fkey] !== 'undefined';
}
- var head = this._head, i = head;
+ var head = this._head;
+ var i = head;
while ((i = i.next) !== head) {
if (ES.SameValueZero(i.key, key)) {
return true;
@@ -2890,7 +2923,9 @@
set: function set(key, value) {
requireMapSlot(this, 'set');
- var head = this._head, i = head, entry;
+ var head = this._head;
+ var i = head;
+ var entry;
var fkey = fastkey(key);
if (fkey !== null) {
// fast O(1) path
@@ -2923,7 +2958,8 @@
'delete': function (key) {
requireMapSlot(this, 'delete');
- var head = this._head, i = head;
+ var head = this._head;
+ var i = head;
var fkey = fastkey(key);
if (fkey !== null) {
// fast O(1) path
@@ -2950,7 +2986,9 @@
requireMapSlot(this, 'clear');
this._size = 0;
this._storage = emptyObject();
- var head = this._head, i = head, p = i.next;
+ var head = this._head;
+ var i = head;
+ var p = i.next;
while ((i = p) !== head) {
i.key = i.value = empty;
p = i.next;
@@ -3290,8 +3328,9 @@
defineProperty(globals.Set.prototype, 'constructor', globals.Set, true);
Value.preserveToString(globals.Set, OrigSet);
}
+ var newMap = new globals.Map();
var mapIterationThrowsStopIterator = !valueOrFalseIfThrows(function () {
- return (new Map()).keys().next().done;
+ return newMap.keys().next().done;
});
/*
- In Firefox < 23, Map#size is a function.
@@ -3303,14 +3342,14 @@
if (
typeof globals.Map.prototype.clear !== 'function' ||
new globals.Set().size !== 0 ||
- new globals.Map().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 (new globals.Map().keys().next) !== 'function' || // Safari 8
+ typeof newMap.keys().next !== 'function' || // Safari 8
mapIterationThrowsStopIterator || // Firefox 25
!mapSupportsSubclassing
) {
@@ -3653,7 +3692,7 @@
}
// Annex B HTML methods
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-additional-properties-of-the-string.prototype-object
+ // 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', '', ''); },
diff --git a/es6-shim.map b/es6-shim.map
index 2fa4e11..d75ac61 100644
--- a/es6-shim.map
+++ b/es6-shim.map
@@ -1 +1 @@
-{"version":3,"sources":["es6-shim.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","_apply","Function","call","bind","apply","_call","isArray","Array","keys","Object","not","notThunker","func","notThunk","arguments","throwsError","e","valueOrFalseIfThrows","isCallableWithoutNew","arePropertyDescriptorsSupported","defineProperty","get","supportsDescriptors","functionsHaveNames","foo","name","_forEach","prototype","forEach","_reduce","reduce","_filter [...]
\ No newline at end of file
+{"version":3,"sources":["es6-shim.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","_apply","Function","call","bind","apply","_call","isArray","Array","keys","Object","not","notThunker","func","notThunk","arguments","throwsError","e","valueOrFalseIfThrows","isCallableWithoutNew","arePropertyDescriptorsSupported","defineProperty","get","supportsDescriptors","functionsHaveNames","foo","name","_forEach","prototype","forEach","_reduce","reduce","_filter [...]
\ No newline at end of file
diff --git a/es6-shim.min.js b/es6-shim.min.js
index 6f0d3de..0ca6daf 100644
--- a/es6-shim.min.js
+++ b/es6-shim.min.js
@@ -2,11 +2,11 @@
* 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.0
- * see https://github.com/paulmillr/es6-shim/blob/0.35.0/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/
*/
-(function(e,t){if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){"use strict";var e=Function.call.bind(Function.apply);var t=Function.call.bind(Function.call);var r=Array.isArray;var n=Object.keys;var o=function notThunker(t){return function notThunk(){return!e(t,this,arguments)}};var i=function(e){try{e();return false}catch(t){return true}};var a=function valueOrFalseIfThrows(e){try{retu [...]
-var mr=Math.round;var wr=Math.round(.5-Number.EPSILON/4)===0&&Math.round(-.5+Number.EPSILON/3.99)===1;var jr=pr+1;var Sr=2*pr-1;var Tr=[jr,Sr].every(function(e){return Math.round(e)===e});h(Math,"round",function round(e){var t=k(e);var r=t===-1?-0:t+1;return e-t<.5?t:r},!wr||!Tr);O.preserveToString(Math.round,mr);var Ir=Math.imul;if(Math.imul(4294967295,5)!==-5){Math.imul=dr.imul;O.preserveToString(Math.imul,Ir)}if(Math.imul.length!==2){X(Math,"imul",function imul(e,t){return te.Call(Ir, [...]
+(function(e,t){if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){"use strict";var e=Function.call.bind(Function.apply);var t=Function.call.bind(Function.call);var r=Array.isArray;var n=Object.keys;var o=function notThunker(t){return function notThunk(){return!e(t,this,arguments)}};var i=function(e){try{e();return false}catch(t){return true}};var a=function valueOrFalseIfThrows(e){try{retu [...]
+})}var Cr=function(){var e=S.setTimeout;if(typeof e!=="function"&&typeof e!=="object"){return}re.IsPromise=function(e){if(!re.TypeIsObject(e)){return false}if(typeof e._promise==="undefined"){return false}return true};var r=function(e){if(!re.IsConstructor(e)){throw new TypeError("Bad promise constructor")}var t=this;var r=function(e,r){if(t.resolve!==void 0||t.reject!==void 0){throw new TypeError("Bad Promise implementation!")}t.resolve=e;t.reject=r};t.resolve=void 0;t.reject=void 0;t.p [...]
//# sourceMappingURL=es6-shim.map
diff --git a/package.json b/package.json
index 6d28eea..a5f8f26 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "es6-shim",
- "version": "0.35.0",
+ "version": "0.35.1",
"author": "Paul Miller (http://paulmillr.com)",
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
"keywords": [
@@ -23,28 +23,29 @@
},
"main": "es6-shim",
"scripts": {
- "test": "npm run lint && evalmd *.md && npm run tests-only",
- "tests-only": "npm run test:shim && npm run test:sham",
+ "pretest": "npm run --silent lint",
+ "test": "evalmd *.md && npm run --silent tests-only",
+ "tests-only": "npm run --silent test:shim && npm run --silent test:sham",
"test:shim": "mocha test/*.js test/*/*.js",
"test:sham": "mocha test-sham/*.js",
- "test:native": "NO_ES6_SHIM=1 npm run tests-only",
- "lint": "npm run lint:shim && npm run lint:sham",
- "lint:shim": "npm run jshint:shim && npm run jscs:shim && npm run eslint:shim",
- "lint:sham": "npm run jshint:sham && npm run jscs:sham && npm run eslint:sham",
- "eslint": "npm run eslint:shim && npm run eslint:sham",
+ "test:native": "NO_ES6_SHIM=1 npm run --silent tests-only",
+ "lint": "npm run --silent lint:shim && npm run --silent lint:sham",
+ "lint:shim": "npm run --silent jshint:shim && npm run --silent jscs:shim && npm run --silent eslint:shim",
+ "lint:sham": "npm run --silent jshint:sham && npm run --silent jscs:sham && npm run --silent eslint:sham",
+ "eslint": "npm run --silent eslint:shim && npm run --silent eslint:sham",
"eslint:shim": "eslint es6-shim.js test/*.js test/*/*.js",
"eslint:sham": "eslint es6-sham.js test-sham/*.js",
- "jshint": "npm run jshint:shim && npm run jshint:sham",
+ "jshint": "npm run --silent jshint:shim && npm run --silent jshint:sham",
"jshint:shim": "jshint es6-shim.js test/*.js test/*/*.js",
"jshint:sham": "jshint es6-sham.js test-sham/*.js",
- "jscs": "npm run jscs:shim && npm run jscs:sham",
+ "jscs": "npm run --silent jscs:shim && npm run --silent jscs:sham",
"jscs:shim": "jscs es6-shim.js test/*.js test/*/*.js",
"jscs:sham": "jscs es6-sham.js test-sham/*.js",
- "minify": "npm run minify:shim && npm run minify:sham",
+ "minify": "npm run --silent minify:shim && npm run --silent minify:sham",
"minify:shim": "uglifyjs es6-shim.js --keep-fnames --comments --source-map=es6-shim.map -m -b ascii_only=true,beautify=false > es6-shim.min.js",
"minify:sham": "uglifyjs es6-sham.js --keep-fnames --comments --source-map=es6-sham.map -m -b ascii_only=true,beautify=false > es6-sham.min.js",
"sauce-connect": "curl -L https://gist.githubusercontent.com/henrikhodne/9322897/raw/sauce-connect.sh | bash && export TRAVIS_SAUCE_CONNECT=true",
- "sauce": "npm run sauce-connect && grunt sauce"
+ "sauce": "npm run --silent sauce-connect && grunt sauce"
},
"testling": {
"html": "testling.html",
@@ -68,19 +69,19 @@
"dependencies": {},
"devDependencies": {
"chai": "^3.5.0",
- "es5-shim": "^4.5.2",
- "eslint": "^1.10.3",
- "@ljharb/eslint-config": "^1.6.1",
+ "es5-shim": "^4.5.8",
+ "eslint": "^2.9.0",
+ "@ljharb/eslint-config": "^4.0.0",
"grunt": "^0.4.5",
- "grunt-contrib-connect": "^0.11.2",
- "grunt-contrib-watch": "^0.6.1",
+ "grunt-contrib-connect": "^1.0.2",
+ "grunt-contrib-watch": "^1.0.0",
"grunt-saucelabs": "^8.6.2",
- "jscs": "^2.9.0",
- "jshint": "^2.9.1",
+ "jscs": "^3.0.3",
+ "jshint": "^2.9.2",
"mocha": "^2.4.5",
"promises-aplus-tests": "^2.1.1",
"promises-es6-tests": "^0.5.0",
- "uglify-js": "^2.6.1",
- "evalmd": "^0.0.16"
+ "uglify-js": "^2.6.2",
+ "evalmd": "^0.0.17"
}
}
diff --git a/test-sham/function.js b/test-sham/function.js
index 43d8459..4720d51 100644
--- a/test-sham/function.js
+++ b/test-sham/function.js
@@ -1,4 +1,4 @@
-/* global describe, it, xit, expect, require, beforeEach, afterEach */
+/* global describe, it, expect, require */
describe('Function', function () {
describe('#name', function () {
diff --git a/test/.eslintrc b/test/.eslintrc
new file mode 100644
index 0000000..55e2e45
--- /dev/null
+++ b/test/.eslintrc
@@ -0,0 +1,6 @@
+{
+ "rules": {
+ "array-callback-return": 0,
+ "max-statements-per-line": [2, { "max": 2 }]
+ }
+}
diff --git a/test/array.js b/test/array.js
index b8c2a4e..5b516bd 100644
--- a/test/array.js
+++ b/test/array.js
@@ -1,4 +1,4 @@
-/* global describe, it, xit, expect, require, beforeEach, afterEach */
+/* global describe, it, expect, require, beforeEach, afterEach */
var runArrayTests = function (it) {
'use strict';
@@ -8,11 +8,12 @@ var runArrayTests = function (it) {
return typeof Sym === 'function' && typeof sym === 'symbol';
};
var functionsHaveNames = (function foo() {}).name === 'foo';
- var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
- var ifSymbolIteratorIt = isSymbol(Sym.iterator) ? it : xit;
- var ifSymbolIteratorAndArrayValuesIt = isSymbol(Sym.iterator) && Array.prototype.values ? it : xit;
- var ifSymbolUnscopablesIt = isSymbol(Sym.unscopables) ? it : xit;
+ var ifFunctionsHaveNamesIt = functionsHaveNames ? it : it.skip;
+ var ifSymbolIteratorIt = isSymbol(Sym.iterator) ? it : it.skip;
+ var ifSymbolIteratorAndArrayValuesIt = isSymbol(Sym.iterator) && Array.prototype.values ? it : it.skip;
+ var ifSymbolUnscopablesIt = isSymbol(Sym.unscopables) ? it : it.skip;
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
+ var ifSupportsDescriptorsIt = Object.getOwnPropertyDescriptor ? it : it.skip;
var isNegativeZero = function (x) {
return (1 / x) < 0;
@@ -28,7 +29,8 @@ var runArrayTests = function (it) {
describe('@@iterator', function () {
ifSymbolIteratorIt('uses Symbol.iterator if available', function () {
- var b = {}, c = {};
+ var b = {};
+ var c = {};
var a = [b, c];
var iteratorFn = a[Sym.iterator];
var iterator = iteratorFn.call(a);
@@ -237,10 +239,12 @@ var runArrayTests = function (it) {
it('removes holes', function () {
/*jshint elision: true */
/* jscs:disable disallowSpaceBeforeComma */
+ /* jscs:disable requireSpaceAfterComma */
/* eslint-disable no-sparse-arrays */
var input = [0, , 2];
var result = Array.from([0, , 2]);
/* eslint-enable no-sparse-arrays */
+ /* jscs:enable requireSpaceAfterComma */
/* jscs:enable disallowSpaceBeforeComma */
/*jshint elision: false */
expect(1 in input).to.equal(false);
@@ -251,6 +255,22 @@ var runArrayTests = function (it) {
it('works with this flaky example', function () {
expect(Array.from([1, NaN, false])).to.eql([1, NaN, false]);
});
+
+ ifSupportsDescriptorsIt('works when Object.prototype has a throwing setter', function () {
+ var key = 10;
+ /* eslint no-extend-native: 0 */
+ Object.defineProperty(Object.prototype, key, {
+ configurable: true,
+ get: function () {},
+ set: function (v) { throw new EvalError('boom'); }
+ });
+ expect(function () { var arr = []; arr[key] = 42; }).to['throw'](EvalError); // assert thrower
+
+ expect(function () { Array.from({ length: key + 1 }); }).not.to['throw']();
+
+ delete Object.prototype[key];
+ expect(key in Object.prototype).to.equal(false); // assert cleanup
+ });
});
describe('.of()', function () {
@@ -371,9 +391,11 @@ var runArrayTests = function (it) {
it('should delete the target key if the source key is not present', function () {
/* jshint elision: true */
/* jscs:disable disallowSpaceBeforeComma */
+ /* jscs:disable requireSpaceAfterComma */
/* eslint-disable no-sparse-arrays */
expect([, 1, 2].copyWithin(1, 0)).to.eql([, , 1]);
/* jshint elision: false */
+ /* jscs:enable requireSpaceAfterComma */
/* jscs:enable disallowSpaceBeforeComma */
/* eslint-enable no-sparse-arrays */
});
@@ -457,9 +479,11 @@ var runArrayTests = function (it) {
it('should work with a sparse array', function () {
/*jshint elision: true */
/* jscs:disable disallowSpaceBeforeComma */
+ /* jscs:disable requireSpaceAfterComma */
/* eslint-disable no-sparse-arrays */
var obj = [1, , undefined];
/* eslint-enable no-sparse-arrays */
+ /* jscs:enable requireSpaceAfterComma */
/* jscs:enable disallowSpaceBeforeComma */
/*jshint elision: false */
expect(1 in obj).to.equal(false);
@@ -554,9 +578,11 @@ var runArrayTests = function (it) {
it('should work with a sparse array', function () {
/*jshint elision: true */
/* jscs:disable disallowSpaceBeforeComma */
+ /* jscs:disable requireSpaceAfterComma */
/* eslint-disable no-sparse-arrays */
var obj = [1, , undefined];
/* eslint-enable no-sparse-arrays */
+ /* jscs:enable requireSpaceAfterComma */
/* jscs:enable disallowSpaceBeforeComma */
/*jshint elision: false */
expect(1 in obj).to.equal(false);
diff --git a/test/browser-onload.js b/test/browser-onload.js
index 3a5352b..7a83647 100644
--- a/test/browser-onload.js
+++ b/test/browser-onload.js
@@ -8,7 +8,7 @@ if (typeof window !== 'undefined') {
var handleResults = function (runner) {
var failedTests = [];
if (runner.stats.end) {
- window.testsPassed = (runner.stats.failures === 0);
+ window.testsPassed = runner.stats.failures === 0;
}
runner.on('pass', function () {
window.completedTests += 1;
diff --git a/test/map.js b/test/map.js
index a16b086..d3d4476 100644
--- a/test/map.js
+++ b/test/map.js
@@ -205,12 +205,12 @@ describe('Map', function () {
'constructor',
'toString',
'isPrototypeOf',
- '__proto__',
+ '__proto__',
'__parent__',
'__count__'
- ].forEach(function (key) {
- testMapping(map, key, {});
- });
+ ].forEach(function (key) {
+ testMapping(map, key, {});
+ });
});
});
diff --git a/test/math.js b/test/math.js
index f81218f..9b2b47f 100644
--- a/test/math.js
+++ b/test/math.js
@@ -714,15 +714,15 @@ describe('Math', function () {
});
it('should be correct for objects with valueOf', function () {
- var x = {
- x: 0,
- valueOf: function () { this.x += 1; return this.x; }
- };
- expect(Math.imul(x, 1)).to.equal(1);
- expect(Math.imul(1, x)).to.equal(2);
- expect(Math.imul(x, 1)).to.equal(3);
- expect(Math.imul(1, x)).to.equal(4);
- expect(Math.imul(x, 1)).to.equal(5);
+ var x = {
+ x: 0,
+ valueOf: function () { this.x += 1; return this.x; }
+ };
+ expect(Math.imul(x, 1)).to.equal(1);
+ expect(Math.imul(1, x)).to.equal(2);
+ expect(Math.imul(x, 1)).to.equal(3);
+ expect(Math.imul(1, x)).to.equal(4);
+ expect(Math.imul(x, 1)).to.equal(5);
});
});
diff --git a/test/number.js b/test/number.js
index 508b3e3..fe11a0b 100644
--- a/test/number.js
+++ b/test/number.js
@@ -423,14 +423,20 @@ describe('Number', function () {
expect(Number(' 0b11')).to.equal(3);
expect(Number('0b11 ')).to.equal(3);
- expect(Number({ toString: function () { return '0b100'; }, valueOf: function () { return '0b101'; } })).to.equal(5);
+ expect(Number({
+ toString: function () { return '0b100'; },
+ valueOf: function () { return '0b101'; }
+ })).to.equal(5);
});
it('works with octal literals in string form', function () {
expect(Number('0o7')).to.equal(7);
expect(Number('0o10')).to.equal(8);
expect(Number('0o11')).to.equal(9);
- expect(Number({ toString: function () { return '0o12'; }, valueOf: function () { return '0o13'; } })).to.equal(11);
+ expect(Number({
+ toString: function () { return '0o12'; },
+ valueOf: function () { return '0o13'; }
+ })).to.equal(11);
});
it('should produce NaN', function () {
diff --git a/test/promise/all.js b/test/promise/all.js
index 0001ad8..f9662e2 100644
--- a/test/promise/all.js
+++ b/test/promise/all.js
@@ -3,7 +3,9 @@
var failIfThrows = function (done) {
'use strict';
- return function (e) { done(e || new Error()); };
+ return function (e) {
+ done(e || new Error());
+ };
};
describe('Promise.all', function () {
@@ -72,9 +74,11 @@ describe('Promise.all', function () {
it('fulfills when passed an sparse array, giving `undefined` for the omitted values', function (done) {
/* jshint elision: true */
/* jscs:disable disallowSpaceBeforeComma */
+ /* jscs:disable requireSpaceAfterComma */
/* eslint-disable no-sparse-arrays */
var iterable = [Promise.resolve(0), , , Promise.resolve(1)];
/* eslint-enable no-sparse-arrays */
+ /* jscs:enable requireSpaceAfterComma */
/* jscs:enable disallowSpaceBeforeComma */
/* jshint elision: false */
@@ -118,8 +122,10 @@ describe('Promise.all', function () {
it('should be robust against tampering (1)', function (done) {
var g = [tamper(Promise.resolve(0))];
// Prevent countdownHolder.[[Countdown]] from ever reaching zero
- Promise.all(g).
- then(function () { done(); }, failIfThrows(done));
+ Promise.all(g).then(
+ function () { done(); },
+ failIfThrows(done)
+ );
});
it('should be robust against tampering (2)', function (done) {
@@ -135,12 +141,10 @@ describe('Promise.all', function () {
assert(!fulfillCalled, 'should be resolved before all()');
})['catch'](failIfThrows(done))
];
- Promise.all(g).
- then(function () {
- assert(!fulfillCalled, 'should be resolved last');
- fulfillCalled = true;
- }).
- then(done, failIfThrows(done));
+ Promise.all(g).then(function () {
+ assert(!fulfillCalled, 'should be resolved last');
+ fulfillCalled = true;
+ }).then(done, failIfThrows(done));
});
it('should be robust against tampering (3)', function (done) {
@@ -150,12 +154,11 @@ describe('Promise.all', function () {
Promise.reject(2)
];
// Promise from Promise.all resolved despite rejected promise in arguments
- Promise.all(g).
- then(function () {
- throw new Error('should not reach here!');
- }, function (e) {
- assert.strictEqual(e, 2);
- }).then(done, failIfThrows(done));
+ Promise.all(g).then(function () {
+ throw new Error('should not reach here!');
+ }, function (e) {
+ assert.strictEqual(e, 2);
+ }).then(done, failIfThrows(done));
});
it('should be robust against tampering (4)', function (done) {
@@ -193,11 +196,8 @@ describe('Promise.all', function () {
// Promise.all calls resolver twice
P.all(g)['catch'](failIfThrows(done));
- Promise.
- resolve().
- then(function () {
- assert.deepEqual(actualArguments, [[0, 'tampered', 2]]);
- }).
- then(done, failIfThrows(done));
+ Promise.resolve().then(function () {
+ assert.deepEqual(actualArguments, [[0, 'tampered', 2]]);
+ }).then(done, failIfThrows(done));
});
});
diff --git a/test/promise/promises-es6.js b/test/promise/promises-es6.js
index c0f0635..b3f7c8b 100644
--- a/test/promise/promises-es6.js
+++ b/test/promise/promises-es6.js
@@ -1,25 +1,24 @@
-/* global describe, require */
+/* global describe, require, Promise */
// tests from promises-es6-tests
(function () {
- 'use strict';
+ 'use strict';
- if (typeof Promise === 'undefined') {
- return;
- }
+ if (typeof Promise === 'undefined') {
+ return;
+ }
- describe('Promises/ES6 Tests', function () {
+ describe('Promises/ES6 Tests', function () {
- // an adapter that sets up global.Promise
- // since it's already set up, empty functions will suffice
- var adapter = {
- defineGlobalPromise: function () {
- },
- removeGlobalPromise: function () {
- }
- };
-
- require('promises-es6-tests').mocha(adapter);
- });
+ // an adapter that sets up global.Promise
+ // since it's already set up, empty functions will suffice
+ var adapter = {
+ defineGlobalPromise: function () {
+ },
+ removeGlobalPromise: function () {
+ }
+ };
+ require('promises-es6-tests').mocha(adapter);
+ });
}());
diff --git a/test/promise/race.js b/test/promise/race.js
index 59155f5..fc4e69c 100644
--- a/test/promise/race.js
+++ b/test/promise/race.js
@@ -3,7 +3,9 @@
var failIfThrows = function (done) {
'use strict';
- return function (e) { done(e || new Error()); };
+ return function (e) {
+ done(e || new Error());
+ };
};
var delayPromise = function (value, ms) {
diff --git a/test/promise/reject.js b/test/promise/reject.js
index bd3ad46..5702b80 100644
--- a/test/promise/reject.js
+++ b/test/promise/reject.js
@@ -3,7 +3,9 @@
var failIfThrows = function (done) {
'use strict';
- return function (e) { done(e || new Error()); };
+ return function (e) {
+ done(e || new Error());
+ };
};
describe('Promise.reject', function () {
diff --git a/test/promise/resolve.js b/test/promise/resolve.js
index 4e0c814..786038d 100644
--- a/test/promise/resolve.js
+++ b/test/promise/resolve.js
@@ -3,7 +3,9 @@
var failIfThrows = function (done) {
'use strict';
- return function (e) { done(e || new Error()); };
+ return function (e) {
+ done(e || new Error());
+ };
};
describe('Promise.resolve', function () {
diff --git a/test/promise/simple.js b/test/promise/simple.js
index 563ba4a..9ef22e1 100644
--- a/test/promise/simple.js
+++ b/test/promise/simple.js
@@ -3,7 +3,9 @@
var failIfThrows = function (done) {
'use strict';
- return function (e) { done(e || new Error()); };
+ return function (e) {
+ done(e || new Error());
+ };
};
describe('Promise', function () {
diff --git a/test/promise/subclass.js b/test/promise/subclass.js
index 4309e1d..8ff3bed 100644
--- a/test/promise/subclass.js
+++ b/test/promise/subclass.js
@@ -35,7 +35,7 @@ describe('Support user subclassing of Promise', function () {
var p3 = MyPromise.all([p1, p2]);
assert.strictEqual(p3.mine, 'yeah');
- p3 = p3.then(function () { done(); }, done);
+ p3.then(function () { done(); }, done);
});
it("should throw if you don't inherit at all", function () {
diff --git a/test/reflect.js b/test/reflect.js
index 0a745d4..a9a1d7a 100644
--- a/test/reflect.js
+++ b/test/reflect.js
@@ -189,7 +189,8 @@ describe('Reflect', function () {
});
it('can return true, even for non-configurable, non-writable properties', function () {
- var o = {}, desc = {
+ var o = {};
+ var desc = {
value: 13,
enumerable: false,
writable: false,
diff --git a/test/regexp.js b/test/regexp.js
index b7521e1..02c423f 100644
--- a/test/regexp.js
+++ b/test/regexp.js
@@ -16,8 +16,10 @@ var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.
var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && typeof Symbol() === 'symbol';
var ifSymbolsDescribe = hasSymbols ? describe : describe.skip;
var defaultRegex = (function () {
+ // Chrome Canary 51 has an undefined RegExp#toSource, and
+ // RegExp#toString produces `/undefined/`
try {
- return String(RegExp.prototype);
+ return RegExp.prototype.source ? String(RegExp.prototype) : '/(?:)/';
} catch (e) {
return '/(?:)/';
}
@@ -352,7 +354,8 @@ describe('RegExp', function () {
});
describe('updates RegExp globals', function () {
- var re, str = 'abcdefghijklmnopq';
+ var str = 'abcdefghijklmnopq';
+ var re;
beforeEach(function () {
re = /(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)/;
re.exec(str);
diff --git a/test/string.js b/test/string.js
index 5a714cd..4fb46cc 100644
--- a/test/string.js
+++ b/test/string.js
@@ -60,7 +60,9 @@ var runStringTests = function (it) {
expect('test'.repeat(NaN)).to.eql('');
expect('test'.repeat({})).to.eql('');
expect('test'.repeat([])).to.eql('');
- expect('test'.repeat({ valueOf: function () { return 2; } })).to.eql('testtest');
+ expect('test'.repeat({
+ valueOf: function () { return 2; }
+ })).to.eql('testtest');
});
it('should work', function () {
expect('test'.repeat(3)).to.eql('testtesttest');
@@ -147,7 +149,8 @@ var runStringTests = function (it) {
expect(myobj.startsWith('abc')).to.equal(true);
expect(myobj.startsWith('bc')).to.equal(false);
- var gotStr = false, gotPos = false;
+ var gotStr = false;
+ var gotPos = false;
myobj = {
toString: function () {
@@ -185,9 +188,9 @@ var runStringTests = function (it) {
ifSymbolsDescribe('Symbol.match', function () {
if (!hasSymbols || !Symbol.match) {
- return it('exists', function () {
- expect(Symbol).to.have.property('match');
- });
+ return it('exists', function () {
+ expect(Symbol).to.have.property('match');
+ });
}
it('allows a regex with Symbol.match set to a falsy value', function () {
@@ -262,7 +265,8 @@ var runStringTests = function (it) {
};
expect(myobj.endsWith('abc')).to.equal(true);
expect(myobj.endsWith('ab')).to.equal(false);
- var gotStr = false, gotPos = false;
+ var gotStr = false;
+ var gotPos = false;
myobj = {
toString: function () {
@@ -310,9 +314,9 @@ var runStringTests = function (it) {
ifSymbolsDescribe('Symbol.match', function () {
if (!hasSymbols || !Symbol.match) {
- return it('exists', function () {
- expect(Symbol).to.have.property('match');
- });
+ return it('exists', function () {
+ expect(Symbol).to.have.property('match');
+ });
}
it('allows a regex with Symbol.match set to a falsy value', function () {
@@ -382,7 +386,8 @@ var runStringTests = function (it) {
expect(myobj.includes('abc')).to.equal(true);
expect(myobj.includes('cd')).to.equal(false);
- var gotStr = false, gotPos = false;
+ var gotStr = false;
+ var gotPos = false;
myobj = {
toString: function () {
@@ -424,9 +429,9 @@ var runStringTests = function (it) {
ifSymbolsDescribe('Symbol.match', function () {
if (!hasSymbols || !Symbol.match) {
- return it('exists', function () {
- expect(Symbol).to.have.property('match');
- });
+ return it('exists', function () {
+ expect(Symbol).to.have.property('match');
+ });
}
it('allows a regex with Symbol.match set to a falsy value', function () {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-es6-shim.git
More information about the Pkg-javascript-commits
mailing list