From f7148ecf3301b10c0f601208c508c289363d4fd8 Mon Sep 17 00:00:00 2001 From: Sergey Chernyshev Date: Thu, 25 Apr 2024 00:14:13 +0200 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 --- graal-nodejs/doc/api/esm.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/graal-nodejs/doc/api/esm.md b/graal-nodejs/doc/api/esm.md index 8f147b9c244..caf21f6607f 100644 --- a/graal-nodejs/doc/api/esm.md +++ b/graal-nodejs/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); + }); `; } ```