diff options
author | Marvin Hagemeister <marvin@deno.com> | 2024-07-25 23:06:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-25 23:06:19 +0200 |
commit | 0cf7f268a7df7711ac6ab8c2c67b4d7abf454fcd (patch) | |
tree | 7520b6dd22c3088a8431d9feda65b981e872b6ef /ext/node/polyfills/worker_threads.ts | |
parent | 763f05e74dfd0032b238603f625893a52e363591 (diff) |
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.
Diffstat (limited to 'ext/node/polyfills/worker_threads.ts')
-rw-r--r-- | ext/node/polyfills/worker_threads.ts | 7 |
1 files changed, 7 insertions, 0 deletions
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; } |