@f/channels

Minimal CSP channels.

Usage no npm install needed!

<script type="module">
  import fChannels from 'https://cdn.skypack.dev/@f/channels';
</script>

README

channels

Build status Git tag NPM version Code style

Minimal CSP channels.

Installation

$ npm install @f/channels

Usage

var createChannels = require('@f/channels')
var channels = createChannels()

var CH = 'CHANNEL'

channels.take(CH).then(function (val) {
  val // 42
})
channels.put(CH, 42).then(function (val) {
  val // true
})

API

channels()

Returns: instanced channels api

.take(channel)

  • channel - channel to take value from

Returns: promise that resolves to value that is put

.put(channel, value)

  • channel - channel to put value on
  • value - value to put

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

.close(channel)

  • channel - channel to close

License

MIT