We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
subarray
slice
1 parent 6fefd51 commit 89c3273Copy full SHA for 89c3273
lib/buffer.js
@@ -1112,14 +1112,18 @@ function adjustOffset(offset, length) {
1112
return NumberIsNaN(offset) ? 0 : length;
1113
}
1114
1115
-Buffer.prototype.slice = function slice(start, end) {
+Buffer.prototype.subarray = function subarray(start, end) {
1116
const srcLength = this.length;
1117
start = adjustOffset(start, srcLength);
1118
end = end !== undefined ? adjustOffset(end, srcLength) : srcLength;
1119
const newLength = end > start ? end - start : 0;
1120
return new FastBuffer(this.buffer, this.byteOffset + start, newLength);
1121
};
1122
1123
+Buffer.prototype.slice = function slice(start, end) {
1124
+ return this.subarray(start, end);
1125
+};
1126
+
1127
function swap(b, n, m) {
1128
const i = b[n];
1129
b[n] = b[m];
0 commit comments