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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]>
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)