From 7ca416af1571a4473bbaa7ed22a128605d33c788 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 14 Apr 2023 14:53:50 +0200 Subject: [PATCH] doc: add missing setEncoding call in ESM example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding `setEncoding()` ensures that the example handles characters split across chunk boundaries well. PR-URL: https://github.com/nodejs/node/pull/47558 Reviewed-By: Michaël Zasso Reviewed-By: Antoine du Hamel Reviewed-By: Moshe Atlow Reviewed-By: Tobias Nießen Reviewed-By: Harshitha K P Reviewed-By: Rafael Gonzaga --- doc/api/esm.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/api/esm.md b/doc/api/esm.md index 1169ec0854da1f..02fed0990542b2 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -1058,6 +1058,7 @@ export function load(url, context, nextLoad) { return new Promise((resolve, reject) => { get(url, (res) => { let data = ''; + res.setEncoding('utf8'); res.on('data', (chunk) => data += chunk); res.on('end', () => resolve({ // This example assumes all network-provided JavaScript is ES module