From 225c8ab0c7a0eb00482523cdcf1d7559592b4c7c Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 14 Apr 2023 10:25:52 +0200 Subject: [PATCH] doc: add missing setEncoding call in ESM example Adding `setEncoding()` ensures that the example handles characters split across chunk boundaries well. --- doc/api/esm.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/api/esm.md b/doc/api/esm.md index 70821859f903a2..545c65b0a33cf6 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