summaryrefslogtreecommitdiff
path: root/doc/api
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2023-04-14 14:53:50 +0200
committerGitHub <noreply@github.com>2023-04-14 12:53:50 +0000
commitcad0ae702baedb24344be61be9e87c618a080471 (patch)
tree2aa1ad4cb3971dceb69e7aa6628ccce903334f08 /doc/api
parent503d838b1e1f6f5c03fc234d9352c31ee3717da4 (diff)
downloadnode-new-cad0ae702baedb24344be61be9e87c618a080471.tar.gz
doc: add missing setEncoding call in ESM example
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 <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Harshitha K P <harshitha014@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Diffstat (limited to 'doc/api')
-rw-r--r--doc/api/esm.md1
1 files changed, 1 insertions, 0 deletions
diff --git a/doc/api/esm.md b/doc/api/esm.md
index 70821859f9..545c65b0a3 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