Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

co-write

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

co-write

Write to streams, respecting backpressure

Source
npmnpm
Version
0.0.0
Version published
Maintainers
1
Created
Source

co-write

Write to streams, respecting backpressure.

yield write(stream, chunk)

Write chunk to stream and block until stream is writable again.

Returns false when stream ended and you should stop writing to it.

Installation

$ npm install co-write

Example

Write random numbers to an http response until it ends:

var write = require('co-write');
var co = require('co');
var http = require('http');

http.createServer(function(req, res){
  co(function*(){
    while (true) {
      var open = yield write(res, ''+Math.random());
      if (!open) return;
    }
  })();
}).listen(8000);

License

MIT

FAQs

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