From 0cf7f268a7df7711ac6ab8c2c67b4d7abf454fcd Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Thu, 25 Jul 2024 23:06:19 +0200 Subject: fix(node/worker_threads): support `port.once()` (#24725) Support `MessagePort.once` in Node mode and enable relevant `worker_threads` test. Noticed that another Node test was passing as well, so I enabled that too. --- ext/node/polyfills/worker_threads.ts | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ext/node') diff --git a/ext/node/polyfills/worker_threads.ts b/ext/node/polyfills/worker_threads.ts index b51049af5..3519ae217 100644 --- a/ext/node/polyfills/worker_threads.ts +++ b/ext/node/polyfills/worker_threads.ts @@ -536,6 +536,13 @@ function webMessagePortToNodeMessagePort(port: MessagePort) { port.ref = () => { port[refMessagePort](true); }; + port.once = (name: string | symbol, listener) => { + const fn = (event) => { + port.off(name, fn); + return listener(event); + }; + port.on(name, fn); + }; return port; } -- cgit v1.2.3