| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f3ab106 commit 16aeddd
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,6 +74,7 @@ rules: | |||
| 74 | 74 | message: __defineSetter__ is deprecated. | |
| 75 | 75 | no-return-await: error | |
| 76 | 76 | no-self-assign: error | |
| 77 | + no-self-compare: error | ||
| 77 | 78 | no-throw-literal: error | |
| 78 | 79 | no-unused-labels: error | |
| 79 | 80 | no-useless-call: error | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -348,7 +348,7 @@ function howMuchToRead(n, state) { | |||
| 348 | 348 | return 0; | |
| 349 | 349 | if (state.objectMode) | |
| 350 | 350 | return 1; | |
| 351 | - if (n !== n) { | ||
| 351 | + if (Number.isNaN(n)) { | ||
| 352 | 352 | // Only flow one buffer at a time | |
| 353 | 353 | if (state.flowing && state.length) | |
| 354 | 354 | return state.buffer.head.data.length; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -362,8 +362,7 @@ function fromArrayBuffer(obj, byteOffset, length) { | |||
| 362 | 362 | byteOffset = 0; | |
| 363 | 363 | } else { | |
| 364 | 364 | byteOffset = +byteOffset; | |
| 365 | - // check for NaN | ||
| 366 | - if (byteOffset !== byteOffset) | ||
| 365 | + if (Number.isNaN(byteOffset)) | ||
| 367 | 366 | byteOffset = 0; | |
| 368 | 367 | } | |
| 369 | 368 | ||
@@ -375,7 +374,7 @@ function fromArrayBuffer(obj, byteOffset, length) { | |||
| 375 | 374 | if (length === undefined) { | |
| 376 | 375 | length = maxLength; | |
| 377 | 376 | } else { | |
| 378 | - // convert length to non-negative integer | ||
| 377 | + // Convert length to non-negative integer. | ||
| 379 | 378 | length = +length; | |
| 380 | 379 | if (length > 0) { | |
| 381 | 380 | if (length > maxLength) | |
@@ -757,8 +756,7 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { | |||
| 757 | 756 | // Coerce to Number. Values like null and [] become 0. | |
| 758 | 757 | byteOffset = +byteOffset; | |
| 759 | 758 | // If the offset is undefined, "foo", {}, coerces to NaN, search whole buffer. | |
| 760 | - // `x !== x`-style conditionals are a faster form of `isNaN(x)` | ||
| 761 | - if (byteOffset !== byteOffset) { | ||
| 759 | + if (Number.isNaN(byteOffset)) { | ||
| 762 | 760 | byteOffset = dir ? 0 : buffer.length; | |
| 763 | 761 | } | |
| 764 | 762 | dir = !!dir; // Cast to bool. | |
@@ -989,15 +987,17 @@ function adjustOffset(offset, length) { | |||
| 989 | 987 | // Use Math.trunc() to convert offset to an integer value that can be larger | |
| 990 | 988 | // than an Int32. Hence, don't use offset | 0 or similar techniques. | |
| 991 | 989 | offset = Math.trunc(offset); | |
| 992 | - // `x !== x`-style conditionals are a faster form of `isNaN(x)` | ||
| 993 | - if (offset === 0 || offset !== offset) { | ||
| 990 | + if (offset === 0) { | ||
| 994 | 991 | return 0; | |
| 995 | - } else if (offset < 0) { | ||
| 992 | + } | ||
| 993 | + if (offset < 0) { | ||
| 996 | 994 | offset += length; | |
| 997 | 995 | return offset > 0 ? offset : 0; | |
| 998 | - } else { | ||
| 999 | - return offset < length ? offset : length; | ||
| 1000 | 996 | } | |
| 997 | + if (offset < length) { | ||
| 998 | + return offset; | ||
| 999 | + } | ||
| 1000 | + return Number.isNaN(offset) ? 0 : length; | ||
| 1001 | 1001 | } | |
| 1002 | 1002 | ||
| 1003 | 1003 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,9 +52,7 @@ Object.defineProperty(EventEmitter, 'defaultMaxListeners', { | |||
| 52 | 52 | return defaultMaxListeners; | |
| 53 | 53 | }, | |
| 54 | 54 | set: function(arg) { | |
| 55 | - // check whether the input is a positive number (whose value is zero or | ||
| 56 | - // greater and not a NaN). | ||
| 57 | - if (typeof arg !== 'number' || arg < 0 || arg !== arg) { | ||
| 55 | + if (typeof arg !== 'number' || arg < 0 || Number.isNaN(arg)) { | ||
| 58 | 56 | const errors = lazyErrors(); | |
| 59 | 57 | throw new errors.TypeError('ERR_OUT_OF_RANGE', 'defaultMaxListeners'); | |
| 60 | 58 | } | |
@@ -76,7 +74,7 @@ EventEmitter.init = function() { | |||
| 76 | 74 | // Obviously not all Emitters should be limited to 10. This function allows | |
| 77 | 75 | // that to be increased. Set to zero for unlimited. | |
| 78 | 76 | EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { | |
| 79 | - if (typeof n !== 'number' || n < 0 || isNaN(n)) { | ||
| 77 | + if (typeof n !== 'number' || n < 0 || Number.isNaN(n)) { | ||
| 80 | 78 | const errors = lazyErrors(); | |
| 81 | 79 | throw new errors.TypeError('ERR_OUT_OF_RANGE', 'n'); | |
| 82 | 80 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ const { kMaxLength } = require('buffer'); | |||
| 11 | 11 | const kMaxUint32 = Math.pow(2, 32) - 1; | |
| 12 | 12 | ||
| 13 | 13 | function assertOffset(offset, length) { | |
| 14 | - if (typeof offset !== 'number' || offset !== offset) { | ||
| 14 | + if (typeof offset !== 'number' || Number.isNaN(offset)) { | ||
| 15 | 15 | throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'offset', 'number'); | |
| 16 | 16 | } | |
| 17 | 17 | ||
@@ -25,7 +25,7 @@ function assertOffset(offset, length) { | |||
| 25 | 25 | } | |
| 26 | 26 | ||
| 27 | 27 | function assertSize(size, offset = 0, length = Infinity) { | |
| 28 | - if (typeof size !== 'number' || size !== size) { | ||
| 28 | + if (typeof size !== 'number' || Number.isNaN(size)) { | ||
| 29 | 29 | throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'size', 'number'); | |
| 30 | 30 | } | |
| 31 | 31 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,7 +51,7 @@ function createRepl(env, opts, cb) { | |||
| 51 | 51 | } | |
| 52 | 52 | ||
| 53 | 53 | const historySize = Number(env.NODE_REPL_HISTORY_SIZE); | |
| 54 | - if (!isNaN(historySize) && historySize > 0) { | ||
| 54 | + if (!Number.isNaN(historySize) && historySize > 0) { | ||
| 55 | 55 | opts.historySize = historySize; | |
| 56 | 56 | } else { | |
| 57 | 57 | // XXX(chrisdickinson): set here to avoid affecting existing applications | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1277,7 +1277,7 @@ function createServerHandle(address, port, addressType, fd) { | |||
| 1277 | 1277 | handle = new Pipe(PipeConstants.SERVER); | |
| 1278 | 1278 | if (process.platform === 'win32') { | |
| 1279 | 1279 | var instances = parseInt(process.env.NODE_PENDING_PIPE_INSTANCES); | |
| 1280 | - if (!isNaN(instances)) { | ||
| 1280 | + if (!Number.isNaN(instances)) { | ||
| 1281 | 1281 | handle.setPendingInstances(instances); | |
| 1282 | 1282 | } | |
| 1283 | 1283 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -103,7 +103,7 @@ function Interface(input, output, completer, terminal) { | |||
| 103 | 103 | } | |
| 104 | 104 | ||
| 105 | 105 | if (typeof historySize !== 'number' || | |
| 106 | - isNaN(historySize) || | ||
| 106 | + Number.isNaN(historySize) || | ||
| 107 | 107 | historySize < 0) { | |
| 108 | 108 | throw new errors.RangeError( | |
| 109 | 109 | 'ERR_INVALID_OPT_VALUE', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -476,7 +476,7 @@ function REPLServer(prompt, | |||
| 476 | 476 | // display next prompt and return. | |
| 477 | 477 | if (trimmedCmd) { | |
| 478 | 478 | if (trimmedCmd.charAt(0) === '.' && trimmedCmd.charAt(1) !== '.' && | |
| 479 | - isNaN(parseFloat(trimmedCmd))) { | ||
| 479 | + Number.isNaN(parseFloat(trimmedCmd))) { | ||
| 480 | 480 | const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/); | |
| 481 | 481 | const keyword = matches && matches[1]; | |
| 482 | 482 | const rest = matches && matches[2]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -177,7 +177,7 @@ function Zlib(opts, mode) { | |||
| 177 | 177 | ||
| 178 | 178 | if (opts) { | |
| 179 | 179 | chunkSize = opts.chunkSize; | |
| 180 | - if (chunkSize !== undefined && chunkSize === chunkSize) { | ||
| 180 | + if (chunkSize !== undefined && !Number.isNaN(chunkSize)) { | ||
| 181 | 181 | if (chunkSize < Z_MIN_CHUNK || !Number.isFinite(chunkSize)) | |
| 182 | 182 | throw new errors.RangeError('ERR_INVALID_OPT_VALUE', | |
| 183 | 183 | 'chunkSize', | |
@@ -187,15 +187,15 @@ function Zlib(opts, mode) { | |||
| 187 | 187 | } | |
| 188 | 188 | ||
| 189 | 189 | flush = opts.flush; | |
| 190 | - if (flush !== undefined && flush === flush) { | ||
| 190 | + if (flush !== undefined && !Number.isNaN(flush)) { | ||
| 191 | 191 | if (flush < Z_NO_FLUSH || flush > Z_BLOCK || !Number.isFinite(flush)) | |
| 192 | 192 | throw new errors.RangeError('ERR_INVALID_OPT_VALUE', 'flush', flush); | |
| 193 | 193 | } else { | |
| 194 | 194 | flush = Z_NO_FLUSH; | |
| 195 | 195 | } | |
| 196 | 196 | ||
| 197 | 197 | finishFlush = opts.finishFlush; | |
| 198 | - if (finishFlush !== undefined && finishFlush === finishFlush) { | ||
| 198 | + if (finishFlush !== undefined && !Number.isNaN(finishFlush)) { | ||
| 199 | 199 | if (finishFlush < Z_NO_FLUSH || finishFlush > Z_BLOCK || | |
| 200 | 200 | !Number.isFinite(finishFlush)) { | |
| 201 | 201 | throw new errors.RangeError('ERR_INVALID_OPT_VALUE', | |
@@ -207,7 +207,7 @@ function Zlib(opts, mode) { | |||
| 207 | 207 | } | |
| 208 | 208 | ||
| 209 | 209 | windowBits = opts.windowBits; | |
| 210 | - if (windowBits !== undefined && windowBits === windowBits) { | ||
| 210 | + if (windowBits !== undefined && !Number.isNaN(windowBits)) { | ||
| 211 | 211 | if (windowBits < Z_MIN_WINDOWBITS || windowBits > Z_MAX_WINDOWBITS || | |
| 212 | 212 | !Number.isFinite(windowBits)) { | |
| 213 | 213 | throw new errors.RangeError('ERR_INVALID_OPT_VALUE', | |
@@ -219,7 +219,7 @@ function Zlib(opts, mode) { | |||
| 219 | 219 | } | |
| 220 | 220 | ||
| 221 | 221 | level = opts.level; | |
| 222 | - if (level !== undefined && level === level) { | ||
| 222 | + if (level !== undefined && !Number.isNaN(level)) { | ||
| 223 | 223 | if (level < Z_MIN_LEVEL || level > Z_MAX_LEVEL || | |
| 224 | 224 | !Number.isFinite(level)) { | |
| 225 | 225 | throw new errors.RangeError('ERR_INVALID_OPT_VALUE', | |
@@ -230,7 +230,7 @@ function Zlib(opts, mode) { | |||
| 230 | 230 | } | |
| 231 | 231 | ||
| 232 | 232 | memLevel = opts.memLevel; | |
| 233 | - if (memLevel !== undefined && memLevel === memLevel) { | ||
| 233 | + if (memLevel !== undefined && !Number.isNaN(memLevel)) { | ||
| 234 | 234 | if (memLevel < Z_MIN_MEMLEVEL || memLevel > Z_MAX_MEMLEVEL || | |
| 235 | 235 | !Number.isFinite(memLevel)) { | |
| 236 | 236 | throw new errors.RangeError('ERR_INVALID_OPT_VALUE', | |
@@ -241,7 +241,7 @@ function Zlib(opts, mode) { | |||
| 241 | 241 | } | |
| 242 | 242 | ||
| 243 | 243 | strategy = opts.strategy; | |
| 244 | - if (strategy !== undefined && strategy === strategy) { | ||
| 244 | + if (strategy !== undefined && !Number.isNaN(strategy)) { | ||
| 245 | 245 | if (strategy < Z_DEFAULT_STRATEGY || strategy > Z_FIXED || | |
| 246 | 246 | !Number.isFinite(strategy)) { | |
| 247 | 247 | throw new errors.TypeError('ERR_INVALID_OPT_VALUE', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments