Skip to content

Commit

Permalink
Fix a typo in the README (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Nov 4, 2024
1 parent 00db35d commit 0729947
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.3

* No user-visible changes.

## 1.1.2

* No user-visible changes.
Expand Down
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,32 @@ action.

[the `sync-child-process` package]: https://github.com/sass/sync-child-process

[**API Docs**]

[**API Docs**]: https://sass.github.io/sync-message-port/classes/SyncMessagePort.html

## Usage

1. Use `SyncMessagePort.createChanenl()` to create a message channel that's set
up to be compatible with `SyncMessagePort`s. A normal `MessageChannel` won't
work!
1. Use [`SyncMessagePort.createChannel()`] to create a message channel that's
set up to be compatible with `SyncMessagePort`s. A normal `MessageChannel`
won't work!

2. You can send this `MessageChannel`'s ports across worker boundaries just like
any other `MessagePort`. Send one to the worker you want to communicate with
synchronously.

3. Once you're ready to start sending and receiving messages, wrap *both* ports
in `new SyncMessagePort()`, even if one is only ever going to be sending
in [`new SyncMessagePort()`], even if one is only ever going to be sending
messages and not receiving them.

4. Use `SyncMessagePort.postMessage()` to send messages and
4. Use [`SyncMessagePort.postMessage()`] to send messages and
`SyncMessagePort.receiveMessage()` to receive them synchronously.

[`SyncMessagePort.createChannel()`]: https://sass.github.io/sync-message-port/classes/SyncMessagePort.html#createChannel
[`new SyncMessagePort()`]: https://sass.github.io/sync-message-port/classes/SyncMessagePort.html#constructor
[`SyncMessagePort.postMessage()`]: https://sass.github.io/sync-message-port/classes/SyncMessagePort.html#postMessage
[`SyncMessagePort.receiveMessage()`]: https://sass.github.io/sync-message-port/classes/SyncMessagePort.html#receiveMessage

```js
import {Worker} from 'node:worker_threads';
import {SyncMessagePort} from 'sync-message-port;
Expand Down Expand Up @@ -111,7 +120,7 @@ across threads when messages are available, and

[`Atomics`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics
[`SharedArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
[`Worker.receiveMessageOnPort()`]: https://nodejs.org/api/worker_threads.html#workerreceivemessageonportport
[`worker_threads.receiveMessageOnPort()`]: https://nodejs.org/api/worker_threads.html#workerreceivemessageonportport

### Can I use this in a browser?

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sync-message-port",
"version": "1.1.2",
"version": "1.1.3",
"description": "A Node.js communication port that can pass messages synchronously between workers",
"repository": "sass/sync-message-port",
"author": "Google Inc.",
Expand Down

0 comments on commit 0729947

Please sign in to comment.