doc: fix globalPreload example

Fixes: https://github.com/nodejs/node/issues/50279
PR-URL: https://github.com/nodejs/node/pull/50300
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
This commit is contained in:
bmacnaughton authored and Michaël Zasso committed 2023-10-28 11:31:07 +02:00
1 parent 76e4d4117c
commit 2b30c8b8a3
1 file changed
+6 -6
+6 -6
View File
@@ -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);
});
`;
}
```