Socket
Book a DemoInstallSign in
Socket

co-process

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

co-process

Concurrent producer/consumer processing for co

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

co-process

Concurrent producer/consumer processing for co with optional concurrency control.

Also see co-thread for a more lightweight but buffering implementation.

Example

var co = require('co');
var process = require('co-process');

co(function*(){
  yield process(getData(), function*(data){
    data = yield transform(data);
    yield db.put(data);
  });
})();

API

process(producer, consumer)

Let consumer concurrently process work from producer.

Whenever producer yields data - and maximum concurrency isn't reached - it will be read immediately. Stop processing by yielding a falsy value.

Options:

- max: limit maximum concurrency
- timeout: kill workers after x milliseconds (default: 100)

Debugging

Set or add co-process to the DEBUG env variable to see how workers spawn, die and consume work.

Installation

$ npm install co-process

License

MIT

FAQs

Package last updated on 03 Feb 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