summaryrefslogtreecommitdiff
path: root/lib/buffer.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/buffer.js')
-rw-r--r--lib/buffer.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/buffer.js b/lib/buffer.js
index ac8c134739..8cbc0af538 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) {