Skip to content

Commit

Permalink
[Robustness] use cached Number.isNaN
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 8, 2016
1 parent 28b803f commit 968ebdd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions es6-shim.js
Expand Up @@ -217,7 +217,7 @@
var _sign = isCallable(Math.sign) ? Math.sign : function sign(value) {
var number = Number(value);
if (number === 0) { return number; }
if (Number.isNaN(number)) { return number; }
if (numberIsNaN(number)) { return number; }
return number < 0 ? -1 : 1;
};

Expand Down Expand Up @@ -1834,7 +1834,7 @@
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;
Expand All @@ -1850,7 +1850,7 @@

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; }
Expand Down Expand Up @@ -1888,7 +1888,7 @@
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; }
Expand Down Expand Up @@ -1941,7 +1941,7 @@

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; }

Expand All @@ -1962,7 +1962,7 @@

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; }
Expand Down

0 comments on commit 968ebdd

Please sign in to comment.