aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/builtins/js
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/builtins/js')
-rw-r--r--src/bun.js/builtins/js/JSBufferPrototype.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bun.js/builtins/js/JSBufferPrototype.js b/src/bun.js/builtins/js/JSBufferPrototype.js
index 310870540..a81634f69 100644
--- a/src/bun.js/builtins/js/JSBufferPrototype.js
+++ b/src/bun.js/builtins/js/JSBufferPrototype.js
@@ -292,7 +292,12 @@ function slice(start, end) {
Buffer[Symbol.species] ||= Buffer;
- return new Buffer(this.buffer, this.byteOffset + (start || 0), (end || this.byteLength) - (start || 0));
+ start = start || 0;
+ if (end !== 0) {
+ end = end || this.byteLength;
+ }
+
+ return new Buffer(this.buffer, this.byteOffset + start, end - start);
}