npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chan

v0.6.1

Published

A go style channel implementation that works nicely with co

Downloads

113,403

Readme

Chan

A golang like channel implementation for JavaScript that works well with co.

Build Status Code Climate Dependency Status

Features

  • CSP Style channels in JavaScript
  • Buffered or Unbuffered channels
  • Channels can be closed
  • API designed to work well with generators and co
  • Can be used without generators
  • Channels can be selected similar to Go's select statement

Installation

$ npm install chan --save

The Basics

Chan is inspired by golang's channels. It is implemented as a function that represents an asynchronous first in first out queue.

var makeChan = require('chan')
// make a new unbuffered channel
var ch = makeChan()
typeof ch // -> 'function'

Sending values to the channel

Values are added to the channel by calling the function with either (value) or (error, value). The return value is a thunk (a function that take a node-style callback as its only argument). The callback given to the thunk is called once the value is added.

ch('foo')(function (err) {
  if (err) {
    // There was an error putting the value on the channel
  } else {
    // The value was successfully put on the channel
  }
})

Receiving values from the channel

Values are removed from the channel by calling it with a node-style callback as this first argument. When a value is available on the channel the callback is called with the value or error. In this case the channel itself can also be a thunk.

ch(function (err, val) {
  // called when there is a value or error on the channel
})

Generators

Because thunks are yield-able in a co generator, chan works very well when combined with co. Using them together makes chan feel very similar to go channels.

var co = require('co')

co(function *() {
  var val = yield ch
})

co(function *() {
  yield ch('foo')
})

Buffer

Docs coming soon...

Close

Docs coming soon...

Select

Docs coming soon...