@@ -12,23 +12,32 @@ action.
12
12
13
13
[ the `sync-child-process` package ] : https://github.com/sass/sync-child-process
14
14
15
+ [ ** API Docs** ]
16
+
17
+ [ **API Docs** ] : https://sass.github.io/sync-message-port/classes/SyncMessagePort.html
18
+
15
19
## Usage
16
20
17
- 1 . Use ` SyncMessagePort.createChanenl () ` to create a message channel that's set
18
- up to be compatible with ` SyncMessagePort ` s. A normal ` MessageChannel ` won't
19
- work!
21
+ 1 . Use [ ` SyncMessagePort.createChannel () ` ] to create a message channel that's
22
+ set up to be compatible with ` SyncMessagePort ` s. A normal ` MessageChannel `
23
+ won't work!
20
24
21
25
2 . You can send this ` MessageChannel ` 's ports across worker boundaries just like
22
26
any other ` MessagePort ` . Send one to the worker you want to communicate with
23
27
synchronously.
24
28
25
29
3 . Once you're ready to start sending and receiving messages, wrap * both* ports
26
- in ` new SyncMessagePort() ` , even if one is only ever going to be sending
30
+ in [ ` new SyncMessagePort() ` ] , even if one is only ever going to be sending
27
31
messages and not receiving them.
28
32
29
- 4 . Use ` SyncMessagePort.postMessage() ` to send messages and
33
+ 4 . Use [ ` SyncMessagePort.postMessage() ` ] to send messages and
30
34
` SyncMessagePort.receiveMessage() ` to receive them synchronously.
31
35
36
+ [ `SyncMessagePort.createChannel()` ] : https://sass.github.io/sync-message-port/classes/SyncMessagePort.html#createChannel
37
+ [ `new SyncMessagePort()` ] : https://sass.github.io/sync-message-port/classes/SyncMessagePort.html#constructor
38
+ [ `SyncMessagePort.postMessage()` ] : https://sass.github.io/sync-message-port/classes/SyncMessagePort.html#postMessage
39
+ [ `SyncMessagePort.receiveMessage()` ] : https://sass.github.io/sync-message-port/classes/SyncMessagePort.html#receiveMessage
40
+
32
41
``` js
33
42
import {Worker } from ' node:worker_threads' ;
34
43
import {SyncMessagePort } from ' sync-message-port;
@@ -111,7 +120,7 @@ across threads when messages are available, and
111
120
112
121
[ `Atomics` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics
113
122
[ `SharedArrayBuffer` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
114
- [ `Worker .receiveMessageOnPort()` ] : https://nodejs.org/api/worker_threads.html#workerreceivemessageonportport
123
+ [ `worker_threads .receiveMessageOnPort()` ] : https://nodejs.org/api/worker_threads.html#workerreceivemessageonportport
115
124
116
125
### Can I use this in a browser?
117
126
0 commit comments