README: Rewrite example using Prettier.
This commit is contained in:
parent
a2746f6e68
commit
b94df07a09
1 changed files with 11 additions and 11 deletions
22
README.md
22
README.md
|
@ -35,23 +35,23 @@ To send a value to a channel use `push`. To receive a value from a channel use
|
||||||
there are no more values to push.
|
there are no more values to push.
|
||||||
|
|
||||||
```JavaScript
|
```JavaScript
|
||||||
const assert = require(`assert`)
|
const assert = require(`assert`);
|
||||||
const Channel = require(`@nodeguy/channel`)
|
const Channel = require(`@nodeguy/channel`);
|
||||||
|
|
||||||
const channel = Channel()
|
const channel = Channel();
|
||||||
|
|
||||||
const send = async () => {
|
const send = async () => {
|
||||||
await channel.push(42)
|
await channel.push(42);
|
||||||
await channel.close()
|
await channel.close();
|
||||||
}
|
};
|
||||||
|
|
||||||
const receive = async () => {
|
const receive = async () => {
|
||||||
assert.equal(await channel.shift(), 42)
|
assert.equal(await channel.shift(), 42);
|
||||||
assert.equal(await channel.shift(), undefined)
|
assert.equal(await channel.shift(), undefined);
|
||||||
}
|
};
|
||||||
|
|
||||||
send()
|
send();
|
||||||
receive()
|
receive();
|
||||||
```
|
```
|
||||||
|
|
||||||
The `push` and `shift` methods are usually called in different async functions.
|
The `push` and `shift` methods are usually called in different async functions.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue