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.
```JavaScript
const assert = require(`assert`)
const Channel = require(`@nodeguy/channel`)
const assert = require(`assert`);
const Channel = require(`@nodeguy/channel`);
const channel = Channel()
const channel = Channel();
const send = async () => {
await channel.push(42)
await channel.close()
}
await channel.push(42);
await channel.close();
};
const receive = async () => {
assert.equal(await channel.shift(), 42)
assert.equal(await channel.shift(), undefined)
}
assert.equal(await channel.shift(), 42);
assert.equal(await channel.shift(), undefined);
};
send()
receive()
send();
receive();
```
The `push` and `shift` methods are usually called in different async functions.