Skip to content

Commit 6b2aa1a

Browse files
committed
Revert "buffer: convert offset & length to int properly"
This reverts commit ca37fa5. A test provided by the commit fails on most (but not all) platforms on CI. PR-URL: #9814 Ref: #9492 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: MichaΓ«l Zasso <targos@protonmail.com> Reviewed-By: Π‘ΠΊΠΎΠ²ΠΎΡ€ΠΎΠ΄Π° Никита АндрССвич <chalkerx@gmail.com>
1 parent 951ba0d commit 6b2aa1a

File tree

5 files changed

+2
-108
lines changed

5 files changed

+2
-108
lines changed

β€Žlib/buffer.jsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function fromArrayLike(obj) {
238238
}
239239

240240
function fromArrayBuffer(obj, byteOffset, length) {
241-
byteOffset = internalUtil.toInteger(byteOffset);
241+
byteOffset >>>= 0;
242242

243243
const maxLength = obj.byteLength - byteOffset;
244244

@@ -248,7 +248,7 @@ function fromArrayBuffer(obj, byteOffset, length) {
248248
if (length === undefined) {
249249
length = maxLength;
250250
} else {
251-
length = internalUtil.toLength(length);
251+
length >>>= 0;
252252
if (length > maxLength)
253253
throw new RangeError("'length' is out of bounds");
254254
}

β€Žlib/internal/util.jsβ€Ž

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,3 @@ exports.cachedResult = function cachedResult(fn) {
161161
return result;
162162
};
163163
};
164-
165-
/*
166-
* Implementation of ToInteger as per ECMAScript Specification
167-
* Refer: http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger
168-
*/
169-
const toInteger = exports.toInteger = function toInteger(argument) {
170-
const number = +argument;
171-
return Number.isNaN(number) ? 0 : Math.trunc(number);
172-
};
173-
174-
/*
175-
* Implementation of ToLength as per ECMAScript Specification
176-
* Refer: http://www.ecma-international.org/ecma-262/6.0/#sec-tolength
177-
*/
178-
exports.toLength = function toLength(argument) {
179-
const len = toInteger(argument);
180-
return len <= 0 ? 0 : Math.min(len, Number.MAX_SAFE_INTEGER);
181-
};

β€Žtest/parallel/test-buffer-creation-regression.jsβ€Ž

Lines changed: 0 additions & 21 deletions
This file was deleted.

β€Žtest/parallel/test-internal-util-toInteger.jsβ€Ž

Lines changed: 0 additions & 32 deletions
This file was deleted.

β€Žtest/parallel/test-internal-util-toLength.jsβ€Ž

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
Β (0)