pchan

0.1.0 • Public • Published

pchan

JS channels implementation... for async fun.

CircleCI

About

This is mt first attempt at pure JS implementation of golang style channels. The premise of channels for JS is that (in concert with ES2017 async / await and promises they can be used to write heavily asyncronous and parallel-ish in a very readable and pleasant way. Specially, they allow for functions resembling threads (or goroutines) to be chained and syncronised with minimal effort.

pchan is feature complete and pretty performant, it allows for channel creation, buffering and closing, channel sends / recieves and ranging over open channels. The API is not particularly javascripty (as much a is practical, it resembles the golang API). The next attempt will just be an effort to make a channels look like more idiomatic JS.

Usage

Coming Soon / WIP.

API

make([capacity])

  • capacity (number) - the size of the channels buffer.

channel([value])

  • value (mixed) - the value to send into the channel.

channel.close()

A convinience function used to close the channel, equivalent to channel(null).

range(channel, fn)

  • channel (function) - the channel to range over.
  • fn (function) - the callback function (called for each received value).

License

MIT © axdg (axdg@dfant.asia), 2107 •

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.00latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.00

Package Sidebar

Install

npm i pchan

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • axdg