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 🙏

© 2026 – Pkg Stats / Ryan Hefner

tower-channel

v0.0.1

Published

A queue/channel implementation geared for use with generators.

Downloads

7

Readme

Tower Channel

Tower Channel provides you with a pretty simple, yet extremely powerful Channel system.

The channels are inspired by Clojure's core.async library and a bunch of talks that Rich Hickey gave.

Indirection Of Data Flow

These are the premise that Channels provide. In the era of JavaScript, evented data flow are plentiful. This inheritely creates a set of tightly coupled components: The event and it's callbacks.

The callbacks are then at the mercy of the callee -- the emitter, where as with Channels, you have much more control over this behaviour.

Data Flow

Leveraging Channels As A Form Of Control Flow

Instead of using callback driven programming, we can leverage generator-based programming with the use of Channels. This will decoupled components that are event-driven, allowing the component itself when, where, and how data is being fetched.

Here's an example of pushing events into a channel (we're also using the go primitive):

/**
 * Module dependencies.
 */

var chan = require('tower-channel');
var put  = chan.put;
var take = chan.take;

/**
 * Create a new channel;
 */

var c = chan();

window.onscroll = function(event) {
  go(function *() {
    yield c.put(event); // or `put(c, event)`
  });
};

Now we have decoupled our logic from the events themselves. We can use select blocks or simply takes to operate on channels.

go(function* () {
  var event = yield c.take();
  // Do something with the event.
});

Channels also give you a way to limit the amount of events that come through at a time, thus, giving the system time to operate on the current events before taking any new ones.

When you have a bounded/buffered channel and you select or take, it will block if it's empty until a value is present. Note that by "block", it doesn't truly block the system, otherwise that would stall everything. When a buffered channel is full and you try and write to it, it will again block until it can write.

var c = chan(10); // Buffered channel with a size of 10

Channels can also be closed. When a channel is closed, writes will not be accepted and won't block. Any reads will still be served until the Channel is empty.

var c = chan(10);

setTimeout(function() {
  c.close();
}, 1200);

go(function* () {
  yield c.put(10); // won't block and won't write.
});

Closed channels do not throw an exception when you try to write to it.

This also gives you the ability to have Timeout Channels.

var t = chan.timeout(200); // Close the channel within 200 ms.

go(function*() {
  yield t.put(10); // Works!
});

setTimeout(function() {
  go(function* () {
    yield t.take(); // 10 ... Works
    yield t.put(40); // Nope.
  });
}, 400);

You can also check when a channel is closed:

// c being a channel.
if (c.closed) {
  // Something here...
}

License

MIT