Permalink
Browse files

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>
  • Loading branch information...
Trott committed Nov 26, 2016
1 parent 951ba0d commit 6b2aa1a2b9ba2cc51eafd31099a5658c52902e3d
@@ -238,7 +238,7 @@ function fromArrayLike(obj) {
}
function fromArrayBuffer(obj, byteOffset, length) {
byteOffset = internalUtil.toInteger(byteOffset);
byteOffset >>>= 0;
const maxLength = obj.byteLength - byteOffset;
@@ -248,7 +248,7 @@ function fromArrayBuffer(obj, byteOffset, length) {
if (length === undefined) {
length = maxLength;
} else {
length = internalUtil.toLength(length);
length >>>= 0;
if (length > maxLength)
throw new RangeError("'length' is out of bounds");
}
@@ -161,21 +161,3 @@ exports.cachedResult = function cachedResult(fn) {
return result;
};
};
/*
* Implementation of ToInteger as per ECMAScript Specification
* Refer: http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger
*/
const toInteger = exports.toInteger = function toInteger(argument) {
const number = +argument;
return Number.isNaN(number) ? 0 : Math.trunc(number);
};
/*
* Implementation of ToLength as per ECMAScript Specification
* Refer: http://www.ecma-international.org/ecma-262/6.0/#sec-tolength
*/
exports.toLength = function toLength(argument) {
const len = toInteger(argument);
return len <= 0 ? 0 : Math.min(len, Number.MAX_SAFE_INTEGER);
};

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

0 comments on commit 6b2aa1a

Please sign in to comment.