README: Rewrite example using Prettier.

This commit is contained in:
David Braun 2017-10-18 13:23:14 -04:00
parent a2746f6e68
commit b94df07a09

View file

@ -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.