diff --git a/lib/buffer.js b/lib/buffer.js index 2d0057544395bc..482c2b6cab17a6 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -1113,7 +1113,7 @@ function adjustOffset(offset, length) { return NumberIsNaN(offset) ? 0 : length; } -Buffer.prototype.slice = function slice(start, end) { +Buffer.prototype.subarray = function subarray(start, end) { const srcLength = this.length; start = adjustOffset(start, srcLength); end = end !== undefined ? adjustOffset(end, srcLength) : srcLength; @@ -1121,6 +1121,10 @@ Buffer.prototype.slice = function slice(start, end) { return new FastBuffer(this.buffer, this.byteOffset + start, newLength); }; +Buffer.prototype.slice = function slice(start, end) { + return this.subarray(start, end); +}; + function swap(b, n, m) { const i = b[n]; b[n] = b[m];