1.1.0 • Published 8 years ago

@f/channel v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

channel

Build status Git tag NPM version Code style

Simple CSP channel implemented with promises.

Installation

$ npm install @f/channel

Usage

import channel from '@f/channel'

let {take, put} = channel()

take().then(val => val) // => 42
put(42).then(val => val) // => true

API

channel()

Returns: bound channel methods

take()

Returns: promise that resolves to a value that is put on channel

put(value)

  • value - value to put

Returns: promise that resolves to true or false indicating whetehr value is taken

close()

Close the channel. All pending takes resolve to CLOSED. All pending puts resolve to false.

open()

Open the channel. Open a closed channel.

CLOSED

Closed value.

License

MIT