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