summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2014-07-08 21:06:05 -0400
committerFedor Indutny <fedor@indutny.com>2014-07-10 15:21:50 +0300
commitb87ca794e31096b61ead46911baf92ba1c020a7d (patch)
treeb53844cf4fd4b44d3579353f72dd5ad39a83cea4
parent71fc4d9486ed13276e0f27ab755e6e233d91c714 (diff)
downloadnode-b87ca794e31096b61ead46911baf92ba1c020a7d.tar.gz
lib: remove and restructure calls to isNaN()
Switch condition order to check for null before calling isNaN(). Also remove two unnecessary calls to isNaN() that are already covered by calls to isFinite(). This commit targets v0.10, as opposed to #7891, which targets master (suggested by @bnoordhuis). Closes #7840. Signed-off-by: Fedor Indutny <fedor@indutny.com>
-rwxr-xr-xlib/_stream_readable.js2
-rw-r--r--lib/assert.js2
-rw-r--r--lib/net.js2
3 files changed, 3 insertions, 3 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js
index 1d486cf7b..bf47e5ec1 100755
--- a/lib/_stream_readable.js
+++ b/lib/_stream_readable.js
@@ -218,7 +218,7 @@ function howMuchToRead(n, state) {
if (state.objectMode)
return n === 0 ? 0 : 1;
- if (isNaN(n) || n === null) {
+ if (n === null || isNaN(n)) {
// only flow one buffer at a time
if (state.flowing && state.buffer.length)
return state.buffer[0].length;
diff --git a/lib/assert.js b/lib/assert.js
index 52b89baef..c9b71d449 100644
--- a/lib/assert.js
+++ b/lib/assert.js
@@ -54,7 +54,7 @@ function replacer(key, value) {
if (value === undefined) {
return '' + value;
}
- if (typeof value === 'number' && (isNaN(value) || !isFinite(value))) {
+ if (typeof value === 'number' && !isFinite(value)) {
return value.toString();
}
if (typeof value === 'function' || value instanceof RegExp) {
diff --git a/lib/net.js b/lib/net.js
index 047f8cd2f..bc336934b 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -306,7 +306,7 @@ Socket.prototype.listen = function() {
Socket.prototype.setTimeout = function(msecs, callback) {
- if (msecs > 0 && !isNaN(msecs) && isFinite(msecs)) {
+ if (msecs > 0 && isFinite(msecs)) {
timers.enroll(this, msecs);
timers._unrefActive(this);
if (callback) {