diff --git a/lib/_http_client.js b/lib/_http_client.js index 249a6d6028f7af..6d8cb8fc8eadd7 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -24,6 +24,7 @@ const { ArrayIsArray, Boolean, + NumberIsFinite, ObjectAssign, ObjectKeys, ObjectSetPrototypeOf, @@ -210,7 +211,7 @@ function ClientRequest(input, options, cb) { // but only if the Agent will actually reuse the connection! // If it's not a keepAlive agent, and the maxSockets==Infinity, then // there's never a case where this socket will actually be reused - if (!this.agent.keepAlive && !Number.isFinite(this.agent.maxSockets)) { + if (!this.agent.keepAlive && !NumberIsFinite(this.agent.maxSockets)) { this._last = true; this.shouldKeepAlive = false; } else { diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 7c9a14f4392c1e..0d83ada205b835 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -23,6 +23,8 @@ const { ArrayIsArray, + NumberIsInteger, + NumberIsNaN, ObjectDefineProperty, ObjectSetPrototypeOf, } = primordials; @@ -406,7 +408,7 @@ function howMuchToRead(n, state) { return 0; if (state.objectMode) return 1; - if (Number.isNaN(n)) { + if (NumberIsNaN(n)) { // Only flow one buffer at a time if (state.flowing && state.length) return state.buffer.first().length; @@ -425,7 +427,7 @@ Readable.prototype.read = function(n) { // in this scenario, so we are doing it manually. if (n === undefined) { n = NaN; - } else if (!Number.isInteger(n)) { + } else if (!NumberIsInteger(n)) { n = parseInt(n, 10); } const state = this._readableState; diff --git a/lib/async_hooks.js b/lib/async_hooks.js index a567e1599f7eea..a7ca5af7ef8105 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -1,6 +1,7 @@ 'use strict'; const { + NumberIsSafeInteger, ReflectApply, } = primordials; @@ -147,7 +148,7 @@ class AsyncResource { // Unlike emitInitScript, AsyncResource doesn't supports null as the // triggerAsyncId. - if (!Number.isSafeInteger(triggerAsyncId) || triggerAsyncId < -1) { + if (!NumberIsSafeInteger(triggerAsyncId) || triggerAsyncId < -1) { throw new ERR_INVALID_ASYNC_ID('triggerAsyncId', triggerAsyncId); } diff --git a/lib/buffer.js b/lib/buffer.js index ac8c134739f985..8cbc0af538dbba 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -27,6 +27,9 @@ const { MathFloor, MathMin, MathTrunc, + NumberIsNaN, + NumberMAX_SAFE_INTEGER, + NumberMIN_SAFE_INTEGER, ObjectCreate, ObjectDefineProperties, ObjectDefineProperty, @@ -175,9 +178,9 @@ function showFlaggedDeprecation() { function toInteger(n, defaultVal) { n = +n; - if (!Number.isNaN(n) && - n >= Number.MIN_SAFE_INTEGER && - n <= Number.MAX_SAFE_INTEGER) { + if (!NumberIsNaN(n) && + n >= NumberMIN_SAFE_INTEGER && + n <= NumberMAX_SAFE_INTEGER) { return ((n % 1) === 0 ? n : MathFloor(n)); } return defaultVal; @@ -442,7 +445,7 @@ function fromArrayBuffer(obj, byteOffset, length) { byteOffset = 0; } else { byteOffset = +byteOffset; - if (Number.isNaN(byteOffset)) + if (NumberIsNaN(byteOffset)) byteOffset = 0; } @@ -890,7 +893,7 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { // Coerce to Number. Values like null and [] become 0. byteOffset = +byteOffset; // If the offset is undefined, "foo", {}, coerces to NaN, search whole buffer. - if (Number.isNaN(byteOffset)) { + if (NumberIsNaN(byteOffset)) { byteOffset = dir ? 0 : buffer.length; } dir = !!dir; // Cast to bool. @@ -1063,7 +1066,7 @@ function adjustOffset(offset, length) { if (offset < length) { return offset; } - return Number.isNaN(offset) ? 0 : length; + return NumberIsNaN(offset) ? 0 : length; } Buffer.prototype.slice = function slice(start, end) { diff --git a/lib/child_process.js b/lib/child_process.js index 866eb5fae12429..2a0d471c02a74d 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -23,6 +23,7 @@ const { ArrayIsArray, + NumberIsInteger, ObjectAssign, ObjectDefineProperty, ObjectPrototypeHasOwnProperty, @@ -651,7 +652,7 @@ function execSync(command, options) { function validateTimeout(timeout) { - if (timeout != null && !(Number.isInteger(timeout) && timeout >= 0)) { + if (timeout != null && !(NumberIsInteger(timeout) && timeout >= 0)) { throw new ERR_OUT_OF_RANGE('timeout', 'an unsigned integer', timeout); } } diff --git a/lib/events.js b/lib/events.js index f8c268ee1cd843..a09333af443534 100644 --- a/lib/events.js +++ b/lib/events.js @@ -24,6 +24,7 @@ const { Array, MathMin, + NumberIsNaN, ObjectCreate, ObjectDefineProperty, ObjectGetPrototypeOf, @@ -79,7 +80,7 @@ ObjectDefineProperty(EventEmitter, 'defaultMaxListeners', { return defaultMaxListeners; }, set: function(arg) { - if (typeof arg !== 'number' || arg < 0 || Number.isNaN(arg)) { + if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { throw new ERR_OUT_OF_RANGE('defaultMaxListeners', 'a non-negative number', arg); @@ -102,7 +103,7 @@ EventEmitter.init = function() { // Obviously not all Emitters should be limited to 10. This function allows // that to be increased. Set to zero for unlimited. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { - if (typeof n !== 'number' || n < 0 || Number.isNaN(n)) { + if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { throw new ERR_OUT_OF_RANGE('n', 'a non-negative number', n); } this._maxListeners = n; diff --git a/lib/fs.js b/lib/fs.js index 8d44ee21be42fd..b7ada86c28a2d2 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -26,6 +26,7 @@ const { MathMax, + NumberIsSafeInteger, ObjectCreate, ObjectDefineProperties, ObjectDefineProperty, @@ -472,7 +473,7 @@ function read(fd, buffer, offset, length, position, callback) { validateOffsetLengthRead(offset, length, buffer.byteLength); - if (!Number.isSafeInteger(position)) + if (!NumberIsSafeInteger(position)) position = -1; function wrapper(err, bytesRead) { @@ -512,7 +513,7 @@ function readSync(fd, buffer, offset, length, position) { validateOffsetLengthRead(offset, length, buffer.byteLength); - if (!Number.isSafeInteger(position)) + if (!NumberIsSafeInteger(position)) position = -1; const ctx = {}; diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 441b0bfb034ec8..b17406c78241cd 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -2,6 +2,7 @@ const { FunctionPrototypeBind, + NumberIsSafeInteger, ObjectDefineProperty, } = primordials; @@ -118,7 +119,7 @@ function validateAsyncId(asyncId, type) { // Skip validation when async_hooks is disabled if (async_hook_fields[kCheck] <= 0) return; - if (!Number.isSafeInteger(asyncId) || asyncId < -1) { + if (!NumberIsSafeInteger(asyncId) || asyncId < -1) { fatalError(new ERR_INVALID_ASYNC_ID(type, asyncId)); } } @@ -299,7 +300,7 @@ function clearDefaultTriggerAsyncId() { function defaultTriggerAsyncIdScope(triggerAsyncId, block, ...args) { if (triggerAsyncId === undefined) return block(...args); - // CHECK(Number.isSafeInteger(triggerAsyncId)) + // CHECK(NumberIsSafeInteger(triggerAsyncId)) // CHECK(triggerAsyncId > 0) const oldDefaultTriggerAsyncId = async_id_fields[kDefaultTriggerAsyncId]; async_id_fields[kDefaultTriggerAsyncId] = triggerAsyncId; diff --git a/lib/internal/crypto/random.js b/lib/internal/crypto/random.js index 425b65e2684d4e..85855a709e89fd 100644 --- a/lib/internal/crypto/random.js +++ b/lib/internal/crypto/random.js @@ -2,6 +2,7 @@ const { MathMin, + NumberIsNaN, } = primordials; const { AsyncWrap, Providers } = internalBinding('async_wrap'); @@ -23,7 +24,7 @@ function assertOffset(offset, elementSize, length) { offset *= elementSize; const maxLength = MathMin(length, kMaxPossibleLength); - if (Number.isNaN(offset) || offset > maxLength || offset < 0) { + if (NumberIsNaN(offset) || offset > maxLength || offset < 0) { throw new ERR_OUT_OF_RANGE('offset', `>= 0 && <= ${maxLength}`, offset); } @@ -34,7 +35,7 @@ function assertSize(size, elementSize, offset, length) { validateNumber(size, 'size'); size *= elementSize; - if (Number.isNaN(size) || size > kMaxPossibleLength || size < 0) { + if (NumberIsNaN(size) || size > kMaxPossibleLength || size < 0) { throw new ERR_OUT_OF_RANGE('size', `>= 0 && <= ${kMaxPossibleLength}`, size); } diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 7dd976e299c079..ee467f31f3e1f3 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -13,6 +13,7 @@ const { ArrayIsArray, MathAbs, + NumberIsInteger, ObjectDefineProperty, ObjectKeys, } = primordials; @@ -1108,7 +1109,7 @@ E('ERR_OUT_OF_RANGE', let msg = replaceDefaultBoolean ? str : `The value of "${str}" is out of range.`; let received; - if (Number.isInteger(input) && MathAbs(input) > 2 ** 32) { + if (NumberIsInteger(input) && MathAbs(input) > 2 ** 32) { received = addNumericalSeparator(String(input)); } else if (typeof input === 'bigint') { received = String(input); diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index a4ac18ba45c200..daf18e19d1c784 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -3,6 +3,7 @@ const { MathMax, MathMin, + NumberIsSafeInteger, } = primordials; const { @@ -235,7 +236,7 @@ async function read(handle, buffer, offset, length, position) { validateOffsetLengthRead(offset, length, buffer.length); - if (!Number.isSafeInteger(position)) + if (!NumberIsSafeInteger(position)) position = -1; const bytesRead = (await binding.read(handle.fd, buffer, offset, length, diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index 6f274d841967ee..7b17eae338aa46 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -3,6 +3,8 @@ const { Array, MathMin, + NumberIsInteger, + NumberIsSafeInteger, ObjectDefineProperty, ObjectSetPrototypeOf, } = primordials; @@ -41,9 +43,9 @@ function allocNewPool(poolSize) { // Check the `this.start` and `this.end` of stream. function checkPosition(pos, name) { - if (!Number.isSafeInteger(pos)) { + if (!NumberIsSafeInteger(pos)) { validateNumber(pos, name); - if (!Number.isInteger(pos)) + if (!NumberIsInteger(pos)) throw new ERR_OUT_OF_RANGE(name, 'an integer', pos); throw new ERR_OUT_OF_RANGE(name, '>= 0 and <= 2 ** 53 - 1', pos); } diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index f7857192651349..c1dd1878ee2488 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -3,6 +3,7 @@ const { ArrayIsArray, DateNow, + NumberIsFinite, ObjectSetPrototypeOf, ReflectOwnKeys, } = primordials; @@ -486,7 +487,7 @@ function toUnixTimestamp(time, name = 'time') { if (typeof time === 'string' && +time == time) { return +time; } - if (Number.isFinite(time)) { + if (NumberIsFinite(time)) { if (time < 0) { return DateNow() / 1000; } diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 7b1cd9eabeb498..2ead72781d53f0 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -6,6 +6,7 @@ const { ArrayIsArray, + NumberMAX_SAFE_INTEGER, ObjectDefineProperties, ObjectDefineProperty, ObjectFreeze, @@ -102,7 +103,7 @@ function wrapProcessMethods(binding) { // implementation always returns numbers <= Number.MAX_SAFE_INTEGER. function previousValueIsValid(num) { return typeof num === 'number' && - num <= Number.MAX_SAFE_INTEGER && + num <= NumberMAX_SAFE_INTEGER && num >= 0; } diff --git a/lib/internal/readline/utils.js b/lib/internal/readline/utils.js index 27110f82797c41..510acf221831a0 100644 --- a/lib/internal/readline/utils.js +++ b/lib/internal/readline/utils.js @@ -2,6 +2,7 @@ const { Boolean, + NumberIsInteger, } = primordials; // Regex used for ansi escape code splitting @@ -38,7 +39,7 @@ if (internalBinding('config').hasIntl) { const icu = internalBinding('icu'); getStringWidth = function getStringWidth(str, options) { options = options || {}; - if (Number.isInteger(str)) { + if (NumberIsInteger(str)) { // Provide information about the character with code point 'str'. return icu.getStringWidth( str, @@ -76,7 +77,7 @@ if (internalBinding('config').hasIntl) { * Returns the number of columns required to display the given string. */ getStringWidth = function getStringWidth(str) { - if (Number.isInteger(str)) + if (NumberIsInteger(str)) return isFullWidthCodePoint(str) ? 2 : 1; let width = 0; @@ -107,7 +108,7 @@ if (internalBinding('config').hasIntl) { isFullWidthCodePoint = function isFullWidthCodePoint(code) { // Code points are derived from: // http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt - return Number.isInteger(code) && code >= 0x1100 && ( + return NumberIsInteger(code) && code >= 0x1100 && ( code <= 0x115f || // Hangul Jamo code === 0x2329 || // LEFT-POINTING ANGLE BRACKET code === 0x232a || // RIGHT-POINTING ANGLE BRACKET diff --git a/lib/internal/repl.js b/lib/internal/repl.js index a5f5cd25f25561..75a68c8ea859ef 100644 --- a/lib/internal/repl.js +++ b/lib/internal/repl.js @@ -1,6 +1,7 @@ 'use strict'; const { + NumberIsNaN, ObjectCreate, } = primordials; @@ -39,7 +40,7 @@ function createRepl(env, opts, cb) { } const historySize = Number(env.NODE_REPL_HISTORY_SIZE); - if (!Number.isNaN(historySize) && historySize > 0) { + if (!NumberIsNaN(historySize) && historySize > 0) { opts.historySize = historySize; } else { opts.historySize = 1000; diff --git a/lib/internal/streams/state.js b/lib/internal/streams/state.js index aa16a0a6b8afb7..fa902ef429b553 100644 --- a/lib/internal/streams/state.js +++ b/lib/internal/streams/state.js @@ -2,6 +2,7 @@ const { MathFloor, + NumberIsInteger, } = primordials; const { ERR_INVALID_OPT_VALUE } = require('internal/errors').codes; @@ -18,7 +19,7 @@ function getDefaultHighWaterMark(objectMode) { function getHighWaterMark(state, options, duplexKey, isDuplex) { const hwm = highWaterMarkFrom(options, isDuplex, duplexKey); if (hwm != null) { - if (!Number.isInteger(hwm) || hwm < 0) { + if (!NumberIsInteger(hwm) || hwm < 0) { const name = isDuplex ? duplexKey : 'highWaterMark'; throw new ERR_INVALID_OPT_VALUE(name, hwm); } diff --git a/lib/internal/timers.js b/lib/internal/timers.js index e55e17b53702a1..84b3c34d87cfaf 100644 --- a/lib/internal/timers.js +++ b/lib/internal/timers.js @@ -75,6 +75,7 @@ const { MathMax, MathTrunc, + NumberMIN_SAFE_INTEGER, ObjectCreate, } = primordials; @@ -121,7 +122,7 @@ const kHasOutstanding = 2; // Timeout values > TIMEOUT_MAX are set to 1. const TIMEOUT_MAX = 2 ** 31 - 1; -let timerListId = Number.MIN_SAFE_INTEGER; +let timerListId = NumberMIN_SAFE_INTEGER; const kRefed = Symbol('refed'); diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index d62727fa577139..0491d1e1e8d335 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -16,6 +16,7 @@ const { MathMin, MathRound, MathSqrt, + NumberIsNaN, NumberPrototypeValueOf, ObjectAssign, ObjectCreate, @@ -720,7 +721,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) { return ctx.stylize(base, 'regexp'); } else if (isDate(value)) { // Make dates with properties first say the date - base = Number.isNaN(DatePrototypeGetTime(value)) ? + base = NumberIsNaN(DatePrototypeGetTime(value)) ? DatePrototypeToString(value) : DatePrototypeToISOString(value); const prefix = getPrefix(constructor, tag, 'Date'); diff --git a/lib/internal/validators.js b/lib/internal/validators.js index 7fd4d5180e9231..079ab3d2f53c20 100644 --- a/lib/internal/validators.js +++ b/lib/internal/validators.js @@ -1,5 +1,11 @@ 'use strict'; +const { + NumberIsInteger, + NumberMAX_SAFE_INTEGER, + NumberMIN_SAFE_INTEGER, +} = primordials; + const { hideStackFrames, codes: { @@ -14,7 +20,6 @@ const { isArrayBufferView } = require('internal/util/types'); const { signals } = internalBinding('constants').os; -const { MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } = Number; function isInt32(value) { return value === (value | 0); @@ -63,10 +68,10 @@ function parseMode(value, name, def) { } const validateInteger = hideStackFrames( - (value, name, min = MIN_SAFE_INTEGER, max = MAX_SAFE_INTEGER) => { + (value, name, min = NumberMIN_SAFE_INTEGER, max = NumberMAX_SAFE_INTEGER) => { if (typeof value !== 'number') throw new ERR_INVALID_ARG_TYPE(name, 'number', value); - if (!Number.isInteger(value)) + if (!NumberIsInteger(value)) throw new ERR_OUT_OF_RANGE(name, 'an integer', value); if (value < min || value > max) throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value); @@ -80,7 +85,7 @@ const validateInt32 = hideStackFrames( if (typeof value !== 'number') { throw new ERR_INVALID_ARG_TYPE(name, 'number', value); } - if (!Number.isInteger(value)) { + if (!NumberIsInteger(value)) { throw new ERR_OUT_OF_RANGE(name, 'an integer', value); } throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value); @@ -96,7 +101,7 @@ const validateUint32 = hideStackFrames((value, name, positive) => { if (typeof value !== 'number') { throw new ERR_INVALID_ARG_TYPE(name, 'number', value); } - if (!Number.isInteger(value)) { + if (!NumberIsInteger(value)) { throw new ERR_OUT_OF_RANGE(name, 'an integer', value); } const min = positive ? 1 : 0; diff --git a/lib/net.js b/lib/net.js index 3370ecf117046f..db63a0cc9da516 100644 --- a/lib/net.js +++ b/lib/net.js @@ -24,6 +24,7 @@ const { ArrayIsArray, Boolean, + NumberIsNaN, ObjectDefineProperty, ObjectSetPrototypeOf, } = primordials; @@ -1222,7 +1223,7 @@ function createServerHandle(address, port, addressType, fd, flags) { handle = new Pipe(PipeConstants.SERVER); if (process.platform === 'win32') { const instances = parseInt(process.env.NODE_PENDING_PIPE_INSTANCES); - if (!Number.isNaN(instances)) { + if (!NumberIsNaN(instances)) { handle.setPendingInstances(instances); } } diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 7121fb389984b0..0b8bab03e48296 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -3,6 +3,7 @@ const { ArrayIsArray, Boolean, + NumberIsSafeInteger, ObjectDefineProperties, ObjectDefineProperty, ObjectKeys, @@ -604,7 +605,7 @@ function monitorEventLoopDelay(options = {}) { throw new ERR_INVALID_ARG_TYPE('options.resolution', 'number', resolution); } - if (resolution <= 0 || !Number.isSafeInteger(resolution)) { + if (resolution <= 0 || !NumberIsSafeInteger(resolution)) { throw new ERR_INVALID_OPT_VALUE.RangeError('resolution', resolution); } return new ELDHistogram(new _ELDHistogram(resolution)); diff --git a/lib/readline.js b/lib/readline.js index 57c2d6aff3c2dd..b25cf9ee64b8a7 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -32,6 +32,8 @@ const { MathCeil, MathFloor, MathMax, + NumberIsFinite, + NumberIsNaN, ObjectDefineProperty, ObjectSetPrototypeOf, } = primordials; @@ -117,7 +119,7 @@ function Interface(input, output, completer, terminal) { prompt = input.prompt; } if (input.escapeCodeTimeout !== undefined) { - if (Number.isFinite(input.escapeCodeTimeout)) { + if (NumberIsFinite(input.escapeCodeTimeout)) { this.escapeCodeTimeout = input.escapeCodeTimeout; } else { throw new ERR_INVALID_OPT_VALUE( @@ -139,7 +141,7 @@ function Interface(input, output, completer, terminal) { } if (typeof historySize !== 'number' || - Number.isNaN(historySize) || + NumberIsNaN(historySize) || historySize < 0) { throw new ERR_INVALID_OPT_VALUE.RangeError('historySize', historySize); } diff --git a/lib/repl.js b/lib/repl.js index 6f84cf7e69f1c3..bac427bd5ad96f 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -45,6 +45,7 @@ const { ArrayIsArray, MathMax, + NumberIsNaN, ObjectAssign, ObjectCreate, ObjectDefineProperty, @@ -701,7 +702,7 @@ function REPLServer(prompt, // display next prompt and return. if (trimmedCmd) { if (trimmedCmd.charAt(0) === '.' && trimmedCmd.charAt(1) !== '.' && - Number.isNaN(parseFloat(trimmedCmd))) { + NumberIsNaN(parseFloat(trimmedCmd))) { const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/); const keyword = matches && matches[1]; const rest = matches && matches[2]; diff --git a/lib/tty.js b/lib/tty.js index 95f2624708bc17..583cc1329830c9 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -23,6 +23,7 @@ const { Array, + NumberIsInteger, ObjectSetPrototypeOf, } = primordials; @@ -39,7 +40,7 @@ const { let readline; function isatty(fd) { - return Number.isInteger(fd) && fd >= 0 && isTTY(fd); + return NumberIsInteger(fd) && fd >= 0 && isTTY(fd); } function ReadStream(fd, options) { diff --git a/lib/util.js b/lib/util.js index 7329b8d715674c..e2b738052daa4d 100644 --- a/lib/util.js +++ b/lib/util.js @@ -23,6 +23,7 @@ const { ArrayIsArray, + NumberIsSafeInteger, ObjectDefineProperties, ObjectDefineProperty, ObjectGetOwnPropertyDescriptors, @@ -225,7 +226,7 @@ function callbackify(original) { function getSystemErrorName(err) { validateNumber(err, 'err'); - if (err >= 0 || !Number.isSafeInteger(err)) { + if (err >= 0 || !NumberIsSafeInteger(err)) { throw new ERR_OUT_OF_RANGE('err', 'a negative integer', err); } return internalErrorName(err); diff --git a/lib/zlib.js b/lib/zlib.js index 4b3426731836c7..375af0fea5a429 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -23,6 +23,8 @@ const { MathMax, + NumberIsFinite, + NumberIsNaN, ObjectDefineProperties, ObjectDefineProperty, ObjectFreeze, @@ -191,11 +193,11 @@ const checkFiniteNumber = hideStackFrames((number, name) => { return false; } - if (Number.isFinite(number)) { + if (NumberIsFinite(number)) { return true; // Is a valid number } - if (Number.isNaN(number)) { + if (NumberIsNaN(number)) { return false; } @@ -791,7 +793,7 @@ function Brotli(opts, mode) { if (opts && opts.params) { for (const origKey of ObjectKeys(opts.params)) { const key = +origKey; - if (Number.isNaN(key) || key < 0 || key > kMaxBrotliParam || + if (NumberIsNaN(key) || key < 0 || key > kMaxBrotliParam || (brotliInitParamsArray[key] | 0) !== -1) { throw new ERR_BROTLI_INVALID_PARAM(origKey); }