diff --git a/doc/api/util.md b/doc/api/util.md index 0e90b2892ffc5a..04a7acfaf5de6b 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -1185,13 +1185,9 @@ added: v8.3.0 An implementation of the [WHATWG Encoding Standard][] `TextDecoder` API. ```js -const decoder = new TextDecoder('shift_jis'); -let string = ''; -let buffer; -while (buffer = getNextChunkSomehow()) { - string += decoder.decode(buffer, { stream: true }); -} -string += decoder.decode(); // end-of-stream +const decoder = new TextDecoder(); +const u8arr = new Uint8Array([72, 101, 108, 108, 111]); +console.log(decoder.decode(u8arr)); // Hello ``` ### WHATWG supported encodings