Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 89c3273

Browse filesBrowse files
benjamingrBethGriggs
authored andcommitted
buffer: alias subarray and slice
PR-URL: #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>
1 parent 6fefd51 commit 89c3273
Copy full SHA for 89c3273

File tree

Expand file treeCollapse file tree

1 file changed

+5
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-1
lines changed
Open diff view settings
Collapse file

‎lib/buffer.js‎

Copy file name to clipboardExpand all lines: lib/buffer.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,14 +1112,18 @@ function adjustOffset(offset, length) {
11121112
return NumberIsNaN(offset) ? 0 : length;
11131113
}
11141114

1115-
Buffer.prototype.slice = function slice(start, end) {
1115+
Buffer.prototype.subarray = function subarray(start, end) {
11161116
const srcLength = this.length;
11171117
start = adjustOffset(start, srcLength);
11181118
end = end !== undefined ? adjustOffset(end, srcLength) : srcLength;
11191119
const newLength = end > start ? end - start : 0;
11201120
return new FastBuffer(this.buffer, this.byteOffset + start, newLength);
11211121
};
11221122

1123+
Buffer.prototype.slice = function slice(start, end) {
1124+
return this.subarray(start, end);
1125+
};
1126+
11231127
function swap(b, n, m) {
11241128
const i = b[n];
11251129
b[n] = b[m];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.