From 2b30c8b8a330d4ee21a0a0dbf22c5ba565afc8a4 Mon Sep 17 00:00:00 2001 From: bmacnaughton Date: Thu, 19 Oct 2023 09:55:59 -0700 Subject: [PATCH] doc: fix `globalPreload` example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/nodejs/node/issues/50279 PR-URL: https://github.com/nodejs/node/pull/50300 Reviewed-By: Antoine du Hamel Reviewed-By: Vinícius Lourenço Claro Cardoso Reviewed-By: Marco Ippolito --- doc/api/esm.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/api/esm.md b/doc/api/esm.md index 8f147b9c2445b2..caf21f6607faff 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -976,14 +976,14 @@ close normally. * and sends the message back to the application context */ export function globalPreload({ port }) { - port.onmessage = (evt) => { - port.postMessage(evt.data); - }; + port.on('message', (msg) => { + port.postMessage(msg); + }); return `\ port.postMessage('console.log("I went to the Loader and back");'); - port.onmessage = (evt) => { - eval(evt.data); - }; + port.on('message', (data) => { + eval(data); + }); `; } ```