Skip to content

Commit d40bcdd

Browse files
addaleaxMoLow
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 fa447b5 commit d40bcdd

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
@@ -1036,6 +1036,7 @@ export function load(url, context, nextLoad) {
10361036
return new Promise((resolve, reject) => {
10371037
get(url, (res) => {
10381038
let data = '';
1039+
res.setEncoding('utf8');
10391040
res.on('data', (chunk) => data += chunk);
10401041
res.on('end', () => resolve({
10411042
// This example assumes all network-provided JavaScript is ES module

0 commit comments

Comments
 (0)