{"_id":"chan","_rev":"1213345","name":"chan","description":"A go style channel implementation that works nicely with co","dist-tags":{"latest":"0.6.1"},"maintainers":[{"name":"brentburgoyne","email":"brent47@gmail.com"}],"time":{"modified":"2021-10-13T05:46:44.000Z","created":"2013-11-11T20:37:45.036Z","0.6.1":"2014-08-05T12:35:04.465Z","0.6.0":"2014-08-05T12:25:02.331Z","0.3.0":"2014-01-07T21:35:57.115Z","0.2.0":"2013-12-07T20:38:50.279Z","0.1.0":"2013-12-02T01:23:18.844Z","0.0.0":"2013-11-11T20:37:45.036Z"},"users":{"lightspeedc":true,"aaron":true,"vorg":true,"brainpoint":true},"author":{"name":"Brent Burgoyne"},"repository":{"type":"git","url":"http://github.com/brentburgoyne/chan"},"versions":{"0.6.1":{"name":"chan","version":"0.6.1","description":"A go style channel implementation that works nicely with co","main":"index.js","scripts":{"test":"./node_modules/mocha/bin/mocha"},"repository":{"type":"git","url":"http://github.com/brentburgoyne/chan"},"keywords":["async","go","channel","co","generator"],"author":{"name":"Brent Burgoyne"},"contributors":[{"name":"Brent Burgoyne"},{"name":"TJ Holowaychuk","email":"tj@vision-media.ca"},{"name":"Eugene Ware","email":"eugene@noblesamurai.com"}],"license":"MIT","bugs":{"url":"https://github.com/brentburgoyne/chan/issues"},"homepage":"https://github.com/brentburgoyne/chan","devDependencies":{"co":"^3.0.6","co-wait":"0.0.0","expect.js":"^0.3.1","mocha":"^1.20.1","should":"^4.0.4","sinon":"^1.10.3","split":"^0.3.0","superagent":"^0.18.0"},"_id":"chan@0.6.1","_shasum":"ec0ad132e5bc62c27ef10ccbfc4d8dcd8ca00640","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"brentburgoyne","email":"brent47@gmail.com"},"maintainers":[{"name":"brentburgoyne","email":"brent47@gmail.com"}],"dist":{"shasum":"ec0ad132e5bc62c27ef10ccbfc4d8dcd8ca00640","size":7586,"noattachment":false,"key":"/chan/-/chan-0.6.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/chan/download/chan-0.6.1.tgz"},"directories":{},"publish_time":1407242104465,"_cnpm_publish_time":1407242104465,"_hasShrinkwrap":false},"0.6.0":{"name":"chan","version":"0.6.0","description":"A go style channel implementation that works nicely with co","main":"index.js","scripts":{"test":"./node_modules/mocha/bin/mocha"},"repository":{"type":"git","url":"http://github.com/brentburgoyne/chan"},"keywords":["async","go","channel","co","generator"],"author":{"name":"Brent Burgoyne"},"contributors":[{"name":"Brent Burgoyne"},{"name":"TJ Holowaychuk","email":"tj@vision-media.ca"},{"name":"Eugene Ware","email":"eugene@noblesamurai.com"}],"license":"MIT","bugs":{"url":"https://github.com/brentburgoyne/chan/issues"},"homepage":"https://github.com/brentburgoyne/chan","devDependencies":{"co":"^3.0.6","co-wait":"0.0.0","expect.js":"^0.3.1","mocha":"^1.20.1","should":"^4.0.4","sinon":"^1.10.3","split":"^0.3.0","superagent":"^0.18.0"},"_id":"chan@0.6.0","_shasum":"317197625bd9f0d0fd38d25f58f1393e8ba88f59","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"brentburgoyne","email":"brent47@gmail.com"},"maintainers":[{"name":"brentburgoyne","email":"brent47@gmail.com"}],"dist":{"shasum":"317197625bd9f0d0fd38d25f58f1393e8ba88f59","size":8350,"noattachment":false,"key":"/chan/-/chan-0.6.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/chan/download/chan-0.6.0.tgz"},"directories":{},"publish_time":1407241502331,"_cnpm_publish_time":1407241502331,"_hasShrinkwrap":false},"0.3.0":{"name":"chan","version":"0.3.0","description":"A go style channel implementation that works nicely with co","main":"chan.js","scripts":{"test":"./node_modules/mocha/bin/mocha"},"repository":{"type":"git","url":"http://github.com/brentburgoyne/chan"},"keywords":["async","go","channel","co","generator"],"author":{"name":"Brent Burgoyne"},"contributors":[{"name":"Brent Burgoyne"},{"name":"TJ Holowaychuk","email":"tj@vision-media.ca"},{"name":"Eugene Ware","email":"eugene@noblesamurai.com"}],"license":"MIT","bugs":{"url":"https://github.com/brentburgoyne/chan/issues"},"homepage":"https://github.com/brentburgoyne/chan","devDependencies":{"mocha":"~1.14.0","expect.js":"~0.2.0","co":"~2.3.0","superagent":"~0.15.7","co-wait":"0.0.0","split":"~0.2.10"},"readmeFilename":"README.markdown","_id":"chan@0.3.0","dist":{"shasum":"ade6bd660e2930862c86b8a61e2acf2786c04567","size":9125,"noattachment":false,"key":"/chan/-/chan-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/chan/download/chan-0.3.0.tgz"},"_from":".","_npmVersion":"1.3.22","_npmUser":{"name":"brentburgoyne","email":"brent47@gmail.com"},"maintainers":[{"name":"brentburgoyne","email":"brent47@gmail.com"}],"directories":{},"publish_time":1389130557115,"_cnpm_publish_time":1389130557115,"_hasShrinkwrap":false},"0.2.0":{"name":"chan","version":"0.2.0","description":"A go style channel implementation that works nicely with co","main":"chan.js","scripts":{"test":"./node_modules/mocha/bin/mocha"},"repository":{"type":"git","url":"http://github.com/brentburgoyne/chan"},"keywords":["async","go","channel","co","generator"],"author":{"name":"Brent Burgoyne"},"contributors":[{"name":"Brent Burgoyne"},{"name":"TJ Holowaychuk","email":"tj@vision-media.ca"}],"license":"MIT","bugs":{"url":"https://github.com/brentburgoyne/chan/issues"},"homepage":"https://github.com/brentburgoyne/chan","devDependencies":{"mocha":"~1.14.0","expect.js":"~0.2.0","co":"~2.3.0","superagent":"~0.15.7","co-wait":"0.0.0","split":"~0.2.10"},"readmeFilename":"README.markdown","_id":"chan@0.2.0","dist":{"shasum":"cf51cc6a5bd1a11a2dd2ebb2925dff752c7c8e1e","size":5895,"noattachment":false,"key":"/chan/-/chan-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/chan/download/chan-0.2.0.tgz"},"_from":".","_npmVersion":"1.3.15","_npmUser":{"name":"brentburgoyne","email":"brent47@gmail.com"},"maintainers":[{"name":"brentburgoyne","email":"brent47@gmail.com"}],"directories":{},"publish_time":1386448730279,"_cnpm_publish_time":1386448730279,"_hasShrinkwrap":false},"0.1.0":{"name":"chan","version":"0.1.0","description":"A go style channel implementation that works nicely with co","main":"chan.js","scripts":{"test":"./node_modules/mocha/bin/mocha"},"repository":{"type":"git","url":"http://github.com/brentburgoyne/chan"},"keywords":["async","go","channel","co","generator"],"author":{"name":"Brent Burgoyne"},"contributors":[{"name":"Brent Burgoyne"},{"name":"TJ Holowaychuk","email":"tj@vision-media.ca"}],"license":"MIT","bugs":{"url":"https://github.com/brentburgoyne/chan/issues"},"homepage":"https://github.com/brentburgoyne/chan","devDependencies":{"mocha":"~1.14.0","expect.js":"~0.2.0","co":"~2.3.0","superagent":"~0.15.7","co-wait":"0.0.0"},"readmeFilename":"README.markdown","_id":"chan@0.1.0","dist":{"shasum":"f0b681ec1a4cf5f77d32cbbfd7df069b9a18ce3c","size":4764,"noattachment":false,"key":"/chan/-/chan-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/chan/download/chan-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.15","_npmUser":{"name":"brentburgoyne","email":"brent47@gmail.com"},"maintainers":[{"name":"brentburgoyne","email":"brent47@gmail.com"}],"directories":{},"publish_time":1385947398844,"_cnpm_publish_time":1385947398844,"_hasShrinkwrap":false},"0.0.0":{"name":"chan","version":"0.0.0","description":"A go style channel implementation that works nicely with co","main":"chan.js","scripts":{"test":"./node_modules/mocha/bin/mocha"},"repository":{"type":"git","url":"http://github.com/brentburgoyne/chan"},"keywords":["async","go","channel","co","generator"],"author":{"name":"Brent Burgoyne"},"license":"MIT","bugs":{"url":"https://github.com/brentburgoyne/chan/issues"},"homepage":"https://github.com/brentburgoyne/chan","devDependencies":{"mocha":"~1.14.0","expect.js":"~0.2.0"},"readmeFilename":"README.markdown","_id":"chan@0.0.0","dist":{"shasum":"9003906ef14b4dd77d118c8564bcc79d058351ed","size":4884,"noattachment":false,"key":"/chan/-/chan-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/chan/download/chan-0.0.0.tgz"},"_from":".","_npmVersion":"1.3.13","_npmUser":{"name":"brentburgoyne","email":"brent47@gmail.com"},"maintainers":[{"name":"brentburgoyne","email":"brent47@gmail.com"}],"directories":{},"publish_time":1384202265036,"_cnpm_publish_time":1384202265036,"_hasShrinkwrap":false}},"readme":"# Chan\n\nA [golang](http://golang.org) like channel implementation for JavaScript that\nworks well with [co](https://github.com/visionmedia/co).\n\n[![Build Status](https://travis-ci.org/brentburgoyne/chan.png)](https://travis-ci.org/brentburgoyne/chan)\n[![Code Climate](https://codeclimate.com/github/brentburgoyne/chan.png)](https://codeclimate.com/github/brentburgoyne/chan)\n[![Dependency Status](https://gemnasium.com/brentburgoyne/chan.png)](https://gemnasium.com/brentburgoyne/chan)\n\n## Features\n\n- CSP Style channels in JavaScript\n- Buffered or Unbuffered channels\n- Channels can be closed\n- API designed to work well with generators and co\n- Can be used without generators\n- Channels can be selected similar to Go's select statement\n\n## Installation\n\n```bash\n$ npm install chan --save\n```\n\n## The Basics\n\nChan is inspired by golang's channels. It is implemented as a function that\nrepresents an asynchronous first in first out queue.\n\n```js\nvar makeChan = require('chan')\n// make a new unbuffered channel\nvar ch = makeChan()\ntypeof ch // -> 'function'\n```\n\n### Sending values to the channel\n\nValues are added to the\nchannel by calling the function with either `(value)` or `(error, value)`. The\nreturn value is a thunk (a function that take a node-style callback as its only\nargument). The callback given to the thunk is called once the value is added.\n\n```js\nch('foo')(function (err) {\n  if (err) {\n    // There was an error putting the value on the channel\n  } else {\n    // The value was successfully put on the channel\n  }\n})\n```\n\n### Receiving values from the channel\n\nValues are removed from the channel by calling it with a node-style callback as\nthis first argument. When a value is available on the channel the callback is\ncalled with the value or error. In this case the channel itself can also be a\nthunk.\n\n```js\nch(function (err, val) {\n  // called when there is a value or error on the channel\n})\n```\n\n### Generators\n\nBecause thunks are yield-able in a co generator, chan works very well when\ncombined with co. Using them together makes chan feel very similar to go\nchannels.\n\n```js\nvar co = require('co')\n\nco(function *() {\n  var val = yield ch\n})\n\nco(function *() {\n  yield ch('foo')\n})\n```\n\n## Buffer\n\nDocs coming soon...\n\n## Close\n\nDocs coming soon...\n\n## Select\n\nDocs coming soon...\n","_attachments":{},"homepage":"https://github.com/brentburgoyne/chan","bugs":{"url":"https://github.com/brentburgoyne/chan/issues"},"license":"MIT"}