Skip to content

Commit 7ca416a

Browse files
addaleaxtargos
authored andcommitted
doc: add missing setEncoding call in ESM example
Adding `setEncoding()` ensures that the example handles characters split across chunk boundaries well. PR-URL: #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>
1 parent f9abd59 commit 7ca416a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

doc/api/esm.md

+1
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,7 @@ export function load(url, context, nextLoad) {
10581058
return new Promise((resolve, reject) => {
10591059
get(url, (res) => {
10601060
let data = '';
1061+
res.setEncoding('utf8');
10611062
res.on('data', (chunk) => data += chunk);
10621063
res.on('end', () => resolve({
10631064
// This example assumes all network-provided JavaScript is ES module

0 commit comments

Comments
 (0)