mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user