npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

destroy-on-hwm

1.0.0 • Public • Published

destroy-on-hwm

NPM version Build status Test coverage Dependency Status License Downloads Gittip

Destroys a writable stream if a write ever hits the high water mark. This is useful when piping a single stream to multiple clients - you don't want one client slowing down the rest of the clients. With how streams currently work, streams flow at the speed of the slowest destination stream.

Usage

var Stream = require('stream');
var destroyOnHWM = require('destroy-on-hwm');
 
var stream = new Stream.PassThrough();
 
/**
 * With no callback, attempts to execute `stream.destroy()` on high water mark.
 * This stream does not have `.destroy()` though, so it's really a noop.
 */
 
destroyOnHWM(stream);
 
/**
 * Instead, we'll just use a custom callback.
 */
 
destroyOnHWM(stream, function (stream) {
  assert(stream === this); // the stream is passed as both `this` and the first argument
  console.log('High water mark reached!');
});

install

npm i destroy-on-hwm

Downloadsweekly downloads

3

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability