Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chan

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chan

A go style channel implementation that works nicely with co

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24K
increased by15.68%
Maintainers
1
Weekly downloads
 
Created
Source

Chan

A go style channel implementation that works well with co.

Installation

$ npm install chan

Usage

Chan does not directly use any ES6 Harmony features, but it is designed to work well with co, a control flow library based on ES6 generators. The following example uses co and requires node 0.11.x (unstable) and must be run with the --harmony-generators flag. Future stable versions of node.js will include support for generators.

// require the dependencies
var chan = require('chan')
  , co   = require('co')
  , fs   = require('fs');

// make a new channel
var ch = chan();

// execute a co generator
co(function *() {
  
  // pass the channel as the callback to filesystem read file function
  // this will push the file contents in to the channel
  fs.readFile(__dirname + '/README.markdown', ch);

  // yield the channel to pull the value off the channel
  var contents = yield ch;

  // use the value
  console.log(String(contents));

})();

Keywords

FAQs

Package last updated on 07 Dec 2013

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc