From 92e7287f4a744cad1fbe46ba1ce84c2b479ce6ac Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Tue, 13 Jun 2023 21:26:28 +0200 Subject: fix(node/buffer): make slice be the same as subarray (#19481) --- ext/node/polyfills/internal/buffer.mjs | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'ext/node/polyfills/internal/buffer.mjs') diff --git a/ext/node/polyfills/internal/buffer.mjs b/ext/node/polyfills/internal/buffer.mjs index 73116e552..32396beaa 100644 --- a/ext/node/polyfills/internal/buffer.mjs +++ b/ext/node/polyfills/internal/buffer.mjs @@ -860,31 +860,7 @@ function _hexSlice(buf, start, end) { } Buffer.prototype.slice = function slice(start, end) { - const len = this.length; - start = ~~start; - end = end === void 0 ? len : ~~end; - if (start < 0) { - start += len; - if (start < 0) { - start = 0; - } - } else if (start > len) { - start = len; - } - if (end < 0) { - end += len; - if (end < 0) { - end = 0; - } - } else if (end > len) { - end = len; - } - if (end < start) { - end = start; - } - const newBuf = this.subarray(start, end); - Object.setPrototypeOf(newBuf, Buffer.prototype); - return newBuf; + return this.subarray(start, end); }; Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE( -- cgit v1.2.3