| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,7 @@ | |||
| 24 | 24 | const { | |
| 25 | 25 | ArrayIsArray, | |
| 26 | 26 | Boolean, | |
| 27 | + NumberIsFinite, | ||
| 27 | 28 | ObjectAssign, | |
| 28 | 29 | ObjectKeys, | |
| 29 | 30 | ObjectSetPrototypeOf, | |
@@ -219,7 +220,7 @@ function ClientRequest(input, options, cb) { | |||
| 219 | 220 | // but only if the Agent will actually reuse the connection! | |
| 220 | 221 | // If it's not a keepAlive agent, and the maxSockets==Infinity, then | |
| 221 | 222 | // there's never a case where this socket will actually be reused | |
| 222 | - if (!this.agent.keepAlive && !Number.isFinite(this.agent.maxSockets)) { | ||
| 223 | + if (!this.agent.keepAlive && !NumberIsFinite(this.agent.maxSockets)) { | ||
| 223 | 224 | this._last = true; | |
| 224 | 225 | this.shouldKeepAlive = false; | |
| 225 | 226 | } else { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,8 @@ | |||
| 23 | 23 | ||
| 24 | 24 | const { | |
| 25 | 25 | ArrayIsArray, | |
| 26 | + NumberIsInteger, | ||
| 27 | + NumberIsNaN, | ||
| 26 | 28 | ObjectDefineProperty, | |
| 27 | 29 | ObjectSetPrototypeOf, | |
| 28 | 30 | } = primordials; | |
@@ -389,7 +391,7 @@ function howMuchToRead(n, state) { | |||
| 389 | 391 | return 0; | |
| 390 | 392 | if (state.objectMode) | |
| 391 | 393 | return 1; | |
| 392 | - if (Number.isNaN(n)) { | ||
| 394 | + if (NumberIsNaN(n)) { | ||
| 393 | 395 | // Only flow one buffer at a time | |
| 394 | 396 | if (state.flowing && state.length) | |
| 395 | 397 | return state.buffer.first().length; | |
@@ -408,7 +410,7 @@ Readable.prototype.read = function(n) { | |||
| 408 | 410 | // in this scenario, so we are doing it manually. | |
| 409 | 411 | if (n === undefined) { | |
| 410 | 412 | n = NaN; | |
| 411 | - } else if (!Number.isInteger(n)) { | ||
| 413 | + } else if (!NumberIsInteger(n)) { | ||
| 412 | 414 | n = parseInt(n, 10); | |
| 413 | 415 | } | |
| 414 | 416 | const state = this._readableState; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | + NumberIsSafeInteger, | ||
| 4 | 5 | ReflectApply, | |
| 5 | 6 | } = primordials; | |
| 6 | 7 | ||
@@ -147,7 +148,7 @@ class AsyncResource { | |||
| 147 | 148 | ||
| 148 | 149 | // Unlike emitInitScript, AsyncResource doesn't supports null as the | |
| 149 | 150 | // triggerAsyncId. | |
| 150 | - if (!Number.isSafeInteger(triggerAsyncId) || triggerAsyncId < -1) { | ||
| 151 | + if (!NumberIsSafeInteger(triggerAsyncId) || triggerAsyncId < -1) { | ||
| 151 | 152 | throw new ERR_INVALID_ASYNC_ID('triggerAsyncId', triggerAsyncId); | |
| 152 | 153 | } | |
| 153 | 154 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,9 @@ const { | |||
| 27 | 27 | MathFloor, | |
| 28 | 28 | MathMin, | |
| 29 | 29 | MathTrunc, | |
| 30 | + NumberIsNaN, | ||
| 31 | + NumberMAX_SAFE_INTEGER, | ||
| 32 | + NumberMIN_SAFE_INTEGER, | ||
| 30 | 33 | ObjectCreate, | |
| 31 | 34 | ObjectDefineProperties, | |
| 32 | 35 | ObjectDefineProperty, | |
@@ -175,9 +178,9 @@ function showFlaggedDeprecation() { | |||
| 175 | 178 | ||
| 176 | 179 | function toInteger(n, defaultVal) { | |
| 177 | 180 | n = +n; | |
| 178 | - if (!Number.isNaN(n) && | ||
| 179 | - n >= Number.MIN_SAFE_INTEGER && | ||
| 180 | - n <= Number.MAX_SAFE_INTEGER) { | ||
| 181 | + if (!NumberIsNaN(n) && | ||
| 182 | + n >= NumberMIN_SAFE_INTEGER && | ||
| 183 | + n <= NumberMAX_SAFE_INTEGER) { | ||
| 181 | 184 | return ((n % 1) === 0 ? n : MathFloor(n)); | |
| 182 | 185 | } | |
| 183 | 186 | return defaultVal; | |
@@ -442,7 +445,7 @@ function fromArrayBuffer(obj, byteOffset, length) { | |||
| 442 | 445 | byteOffset = 0; | |
| 443 | 446 | } else { | |
| 444 | 447 | byteOffset = +byteOffset; | |
| 445 | - if (Number.isNaN(byteOffset)) | ||
| 448 | + if (NumberIsNaN(byteOffset)) | ||
| 446 | 449 | byteOffset = 0; | |
| 447 | 450 | } | |
| 448 | 451 | ||
@@ -890,7 +893,7 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { | |||
| 890 | 893 | // Coerce to Number. Values like null and [] become 0. | |
| 891 | 894 | byteOffset = +byteOffset; | |
| 892 | 895 | // If the offset is undefined, "foo", {}, coerces to NaN, search whole buffer. | |
| 893 | - if (Number.isNaN(byteOffset)) { | ||
| 896 | + if (NumberIsNaN(byteOffset)) { | ||
| 894 | 897 | byteOffset = dir ? 0 : buffer.length; | |
| 895 | 898 | } | |
| 896 | 899 | dir = !!dir; // Cast to bool. | |
@@ -1063,7 +1066,7 @@ function adjustOffset(offset, length) { | |||
| 1063 | 1066 | if (offset < length) { | |
| 1064 | 1067 | return offset; | |
| 1065 | 1068 | } | |
| 1066 | - return Number.isNaN(offset) ? 0 : length; | ||
| 1069 | + return NumberIsNaN(offset) ? 0 : length; | ||
| 1067 | 1070 | } | |
| 1068 | 1071 | ||
| 1069 | 1072 | Buffer.prototype.slice = function slice(start, end) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | 24 | const { | |
| 25 | 25 | ArrayIsArray, | |
| 26 | + NumberIsInteger, | ||
| 26 | 27 | ObjectAssign, | |
| 27 | 28 | ObjectDefineProperty, | |
| 28 | 29 | ObjectPrototypeHasOwnProperty, | |
@@ -670,7 +671,7 @@ function execSync(command, options) { | |||
| 670 | 671 | ||
| 671 | 672 | ||
| 672 | 673 | function validateTimeout(timeout) { | |
| 673 | - if (timeout != null && !(Number.isInteger(timeout) && timeout >= 0)) { | ||
| 674 | + if (timeout != null && !(NumberIsInteger(timeout) && timeout >= 0)) { | ||
| 674 | 675 | throw new ERR_OUT_OF_RANGE('timeout', 'an unsigned integer', timeout); | |
| 675 | 676 | } | |
| 676 | 677 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,7 @@ | |||
| 24 | 24 | const { | |
| 25 | 25 | Array, | |
| 26 | 26 | MathMin, | |
| 27 | + NumberIsNaN, | ||
| 27 | 28 | ObjectCreate, | |
| 28 | 29 | ObjectDefineProperty, | |
| 29 | 30 | ObjectGetPrototypeOf, | |
@@ -79,7 +80,7 @@ ObjectDefineProperty(EventEmitter, 'defaultMaxListeners', { | |||
| 79 | 80 | return defaultMaxListeners; | |
| 80 | 81 | }, | |
| 81 | 82 | set: function(arg) { | |
| 82 | - if (typeof arg !== 'number' || arg < 0 || Number.isNaN(arg)) { | ||
| 83 | + if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { | ||
| 83 | 84 | throw new ERR_OUT_OF_RANGE('defaultMaxListeners', | |
| 84 | 85 | 'a non-negative number', | |
| 85 | 86 | arg); | |
@@ -102,7 +103,7 @@ EventEmitter.init = function() { | |||
| 102 | 103 | // Obviously not all Emitters should be limited to 10. This function allows | |
| 103 | 104 | // that to be increased. Set to zero for unlimited. | |
| 104 | 105 | EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { | |
| 105 | - if (typeof n !== 'number' || n < 0 || Number.isNaN(n)) { | ||
| 106 | + if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { | ||
| 106 | 107 | throw new ERR_OUT_OF_RANGE('n', 'a non-negative number', n); | |
| 107 | 108 | } | |
| 108 | 109 | this._maxListeners = n; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | 27 | const { | |
| 28 | 28 | MathMax, | |
| 29 | + NumberIsSafeInteger, | ||
| 29 | 30 | ObjectCreate, | |
| 30 | 31 | ObjectDefineProperties, | |
| 31 | 32 | ObjectDefineProperty, | |
@@ -476,7 +477,7 @@ function read(fd, buffer, offset, length, position, callback) { | |||
| 476 | 477 | ||
| 477 | 478 | validateOffsetLengthRead(offset, length, buffer.byteLength); | |
| 478 | 479 | ||
| 479 | - if (!Number.isSafeInteger(position)) | ||
| 480 | + if (!NumberIsSafeInteger(position)) | ||
| 480 | 481 | position = -1; | |
| 481 | 482 | ||
| 482 | 483 | function wrapper(err, bytesRead) { | |
@@ -511,7 +512,7 @@ function readSync(fd, buffer, offset, length, position) { | |||
| 511 | 512 | ||
| 512 | 513 | validateOffsetLengthRead(offset, length, buffer.byteLength); | |
| 513 | 514 | ||
| 514 | - if (!Number.isSafeInteger(position)) | ||
| 515 | + if (!NumberIsSafeInteger(position)) | ||
| 515 | 516 | position = -1; | |
| 516 | 517 | ||
| 517 | 518 | const ctx = {}; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | 4 | FunctionPrototypeBind, | |
| 5 | + NumberIsSafeInteger, | ||
| 5 | 6 | ObjectDefineProperty, | |
| 6 | 7 | } = primordials; | |
| 7 | 8 | ||
@@ -118,7 +119,7 @@ function validateAsyncId(asyncId, type) { | |||
| 118 | 119 | // Skip validation when async_hooks is disabled | |
| 119 | 120 | if (async_hook_fields[kCheck] <= 0) return; | |
| 120 | 121 | ||
| 121 | - if (!Number.isSafeInteger(asyncId) || asyncId < -1) { | ||
| 122 | + if (!NumberIsSafeInteger(asyncId) || asyncId < -1) { | ||
| 122 | 123 | fatalError(new ERR_INVALID_ASYNC_ID(type, asyncId)); | |
| 123 | 124 | } | |
| 124 | 125 | } | |
@@ -299,7 +300,7 @@ function clearDefaultTriggerAsyncId() { | |||
| 299 | 300 | function defaultTriggerAsyncIdScope(triggerAsyncId, block, ...args) { | |
| 300 | 301 | if (triggerAsyncId === undefined) | |
| 301 | 302 | return block(...args); | |
| 302 | - // CHECK(Number.isSafeInteger(triggerAsyncId)) | ||
| 303 | + // CHECK(NumberIsSafeInteger(triggerAsyncId)) | ||
| 303 | 304 | // CHECK(triggerAsyncId > 0) | |
| 304 | 305 | const oldDefaultTriggerAsyncId = async_id_fields[kDefaultTriggerAsyncId]; | |
| 305 | 306 | async_id_fields[kDefaultTriggerAsyncId] = triggerAsyncId; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | 4 | MathMin, | |
| 5 | + NumberIsNaN, | ||
| 5 | 6 | } = primordials; | |
| 6 | 7 | ||
| 7 | 8 | const { AsyncWrap, Providers } = internalBinding('async_wrap'); | |
@@ -23,7 +24,7 @@ function assertOffset(offset, elementSize, length) { | |||
| 23 | 24 | offset *= elementSize; | |
| 24 | 25 | ||
| 25 | 26 | const maxLength = MathMin(length, kMaxPossibleLength); | |
| 26 | - if (Number.isNaN(offset) || offset > maxLength || offset < 0) { | ||
| 27 | + if (NumberIsNaN(offset) || offset > maxLength || offset < 0) { | ||
| 27 | 28 | throw new ERR_OUT_OF_RANGE('offset', `>= 0 && <= ${maxLength}`, offset); | |
| 28 | 29 | } | |
| 29 | 30 | ||
@@ -34,7 +35,7 @@ function assertSize(size, elementSize, offset, length) { | |||
| 34 | 35 | validateNumber(size, 'size'); | |
| 35 | 36 | size *= elementSize; | |
| 36 | 37 | ||
| 37 | - if (Number.isNaN(size) || size > kMaxPossibleLength || size < 0) { | ||
| 38 | + if (NumberIsNaN(size) || size > kMaxPossibleLength || size < 0) { | ||
| 38 | 39 | throw new ERR_OUT_OF_RANGE('size', | |
| 39 | 40 | `>= 0 && <= ${kMaxPossibleLength}`, size); | |
| 40 | 41 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,7 @@ | |||
| 13 | 13 | const { | |
| 14 | 14 | ArrayIsArray, | |
| 15 | 15 | MathAbs, | |
| 16 | + NumberIsInteger, | ||
| 16 | 17 | ObjectDefineProperty, | |
| 17 | 18 | ObjectKeys, | |
| 18 | 19 | } = primordials; | |
@@ -1113,7 +1114,7 @@ E('ERR_OUT_OF_RANGE', | |||
| 1113 | 1114 | let msg = replaceDefaultBoolean ? str : | |
| 1114 | 1115 | `The value of "${str}" is out of range.`; | |
| 1115 | 1116 | let received; | |
| 1116 | - if (Number.isInteger(input) && MathAbs(input) > 2 ** 32) { | ||
| 1117 | + if (NumberIsInteger(input) && MathAbs(input) > 2 ** 32) { | ||
| 1117 | 1118 | received = addNumericalSeparator(String(input)); | |
| 1118 | 1119 | } else if (typeof input === 'bigint') { | |
| 1119 | 1120 | received = String(input); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments