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

Browse filesBrowse files
Trottdanielleadams
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 2c813d8 commit 9f8e442
Copy full SHA for 9f8e442

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
@@ -1185,13 +1185,9 @@ added: v8.3.0
11851185
An implementation of the [WHATWG Encoding Standard][] `TextDecoder` API.
11861186

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

11971193
### WHATWG supported encodings

0 commit comments

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