mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
buffer: alias subarray
and slice
PR-URL: https://github.com/nodejs/node/pull/41596 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
parent
6bf769e4e6
commit
3d23d62373
1 changed files with 5 additions and 1 deletions
|
@ -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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue