From 811322069080cd560449b418b98dc5a323a9f543 Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Tue, 31 Jan 2023 02:32:35 +0900 Subject: [PATCH] doc: pass string to `textEncoder.encode` as input Input of `textEncoder.encode` should be string, not array. Refs: https://nodejs.org/dist/latest-v19.x/docs/api/util.html#textencoderencodeinput PR-URL: https://github.com/nodejs/node/pull/46421 Reviewed-By: Colin Ihrig Reviewed-By: Antoine du Hamel Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen --- doc/api/webstreams.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/webstreams.md b/doc/api/webstreams.md index 37ac739f4345fb..8ffe4702f6bb9e 100644 --- a/doc/api/webstreams.md +++ b/doc/api/webstreams.md @@ -1480,7 +1480,7 @@ const { Readable } = require('node:stream'); const { TextEncoder } = require('node:util'); const encoder = new TextEncoder(); -const dataArray = encoder.encode(['hello world from consumers!']); +const dataArray = encoder.encode('hello world from consumers!'); const readable = Readable.from(dataArray); arrayBuffer(readable).then((data) => { console.log(`from readable: ${data.byteLength}`);