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 9c73bd5

Browse filesBrowse files
TrottBethGriggs
authored andcommitted
doc: simplify util.TextDecoder example
This simplifies the example and makes it runnable. (The current example has a magic function.) (This also removes an assignment in a condition which will be flagged if we enable ESLint's no-cond-assign rule.) PR-URL: #41574 Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent f947f72 commit 9c73bd5
Copy full SHA for 9c73bd5

File tree

Expand file treeCollapse file tree

1 file changed

+3
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-7
lines changed
Open diff view settings
Collapse file

‎doc/api/util.md‎

Copy file name to clipboardExpand all lines: doc/api/util.md
+3-7Lines changed: 3 additions & 7 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1187,13 +1187,9 @@ added: v8.3.0
11871187
An implementation of the [WHATWG Encoding Standard][] `TextDecoder` API.
11881188

11891189
```js
1190-
const decoder = new TextDecoder('shift_jis');
1191-
let string = '';
1192-
let buffer;
1193-
while (buffer = getNextChunkSomehow()) {
1194-
string += decoder.decode(buffer, { stream: true });
1195-
}
1196-
string += decoder.decode(); // end-of-stream
1190+
const decoder = new TextDecoder();
1191+
const u8arr = new Uint8Array([72, 101, 108, 108, 111]);
1192+
console.log(decoder.decode(u8arr)); // Hello
11971193
```
11981194

11991195
### WHATWG supported encodings

0 commit comments

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