Socket
Book a DemoInstallSign in
Socket

pchan

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pchan

JS channels implementation... for async fun

latest
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

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 •

FAQs

Package last updated on 27 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts