diff options
Diffstat (limited to 'lib/internal/worker/io.js')
-rw-r--r-- | lib/internal/worker/io.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/internal/worker/io.js b/lib/internal/worker/io.js index 8b7aedd39d0..63c8a8d9763 100644 --- a/lib/internal/worker/io.js +++ b/lib/internal/worker/io.js @@ -4,13 +4,15 @@ const { Object } = primordials; const { handle_onclose: handleOnCloseSymbol, - oninit: onInitSymbol + oninit: onInitSymbol, + no_message_symbol: noMessageSymbol } = internalBinding('symbols'); const { MessagePort, MessageChannel, drainMessagePort, moveMessagePortToContext, + receiveMessageOnPort: receiveMessageOnPort_, stopMessagePort } = internalBinding('messaging'); const { @@ -235,6 +237,12 @@ function createWorkerStdio() { }; } +function receiveMessageOnPort(port) { + const message = receiveMessageOnPort_(port); + if (message === noMessageSymbol) return undefined; + return { message }; +} + module.exports = { drainMessagePort, messageTypes, @@ -245,6 +253,7 @@ module.exports = { moveMessagePortToContext, MessagePort, MessageChannel, + receiveMessageOnPort, setupPortReferencing, ReadableWorkerStdio, WritableWorkerStdio, |