Commit ee83c95
buffer: make byteLength work with ArrayBuffer & DataView
Convert anything to string, but Buffer, TypedArray and ArrayBuffer
```
var uint8 = new Uint8Array([0xf0, 0x9f, 0x90]);
Buffer.byteLength(uint8); // should be 3, but returns 11
Buffer.byteLength(uint8.buffer); // should be 3, but return 20
```
PR-URL: #5255
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>1 parent 1f8e4b5 commit ee83c95Copy full SHA for ee83c95
File tree
Expand file treeCollapse file tree
3 files changed
+47
-5
lines changedOpen diff view settings
Filter options
- doc/api
- lib
- test/parallel
Expand file treeCollapse file tree
3 files changed
+47
-5
lines changedOpen diff view settings
Collapse file
+9-2Lines changed: 9 additions & 2 deletions
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
451 | 451 | |
452 | 452 | |
453 | 453 | |
454 | | - |
| 454 | + |
455 | 455 | |
456 | 456 | |
457 | 457 | |
| ||
470 | 470 | |
471 | 471 | |
472 | 472 | |
| 473 | + |
| 474 | + |
| 475 | + |
| 476 | + |
| 477 | + |
473 | 478 | |
474 | 479 | |
475 | 480 | |
| ||
1744 | 1749 | |
1745 | 1750 | |
1746 | 1751 | |
1747 | | - |
| 1752 | + |
| 1753 | + |
| 1754 | + |
Collapse file
+4-3Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
340 | 340 | |
341 | 341 | |
342 | 342 | |
343 | | - |
344 | | - |
| 343 | + |
| 344 | + |
| 345 | + |
345 | 346 | |
346 | | - |
347 | 347 | |
| 348 | + |
348 | 349 | |
349 | 350 | |
350 | 351 | |
|
Collapse file
test/parallel/test-buffer-bytelength.js
Copy file name to clipboardExpand all lines: test/parallel/test-buffer-bytelength.js+34Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
3 | 3 | |
4 | 4 | |
5 | 5 | |
| 6 | + |
6 | 7 | |
7 | 8 | |
8 | 9 | |
9 | 10 | |
10 | 11 | |
11 | 12 | |
12 | 13 | |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
13 | 19 | |
14 | 20 | |
15 | 21 | |
16 | 22 | |
17 | 23 | |
18 | 24 | |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
19 | 53 | |
20 | 54 | |
21 | 55 | |
|
0 commit comments