diff --git a/lib/buffer.js b/lib/buffer.js index 1f4f0a2e89deb8..a2ded906f8ebc4 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -1112,7 +1112,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; @@ -1120,6 +1120,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];