summaryrefslogtreecommitdiff
path: root/ext/node/polyfills
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2023-06-13 21:26:28 +0200
committerGitHub <noreply@github.com>2023-06-13 21:26:28 +0200
commit92e7287f4a744cad1fbe46ba1ce84c2b479ce6ac (patch)
treed8ef78aed744bce754c671af331b3d01c5f32f93 /ext/node/polyfills
parent7e81d3c876bccd208a2e7b9c33f6fad4e3cf1b0f (diff)
fix(node/buffer): make slice be the same as subarray (#19481)
Diffstat (limited to 'ext/node/polyfills')
-rw-r--r--ext/node/polyfills/internal/buffer.mjs26
1 files changed, 1 insertions, 25 deletions
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(