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

cooperator

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

cooperator

Like co but lets you also output data

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Cooperator

Usage

var cooperator = require('cooperator')
var sleep = require('co-sleep')
var co = cooperator(function*() {
	yield 'foo'
	yield sleep(2000)
	yield 'bar'
	yield sleep(2000)
	yield 'baz'
}).on('data', function(data) {
	console.log('data', data)
}).on('error', function(err) {
	console.error('error', err.stack)
}).on('done', function(res) {
	console.log('done', res)
}).start()
// yields
// data foo
// data bar
// data baz
// done undefined

API

  • co = cooperator(gen) - Creates a cooperator from gen (can be a generator or a generator function)
  • co.start() - Start it
  • co.on('data', cb(data)) - An event emitted when the generator yields a value that can't be thunkifyered
  • co.on('done', cb(res)) - An event emitted when the generator returns
  • co.on('error', cb(err)) - An event emitted when the generator throws an error
  • co.pullStream - A pull-stream for the data

FAQs

Package last updated on 18 Jun 2014

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