Sha256: 6f6dee0eda429dbe35ede37e975742d64ac5a64585bce7af9a91a5fbff823601

Contents?: true

Size: 1.53 KB

Versions: 13

Compression:

Stored size: 1.53 KB

Contents

# end-of-stream

A node module that calls a callback when a readable/writable/duplex stream has completed or failed.

	npm install end-of-stream

## Usage

Simply pass a stream and a callback to the `eos`.
Both legacy streams, streams2 and stream3 are supported.

``` js
var eos = require('end-of-stream');

eos(readableStream, function(err) {
  // this will be set to the stream instance
	if (err) return console.log('stream had an error or closed early');
	console.log('stream has ended', this === readableStream);
});

eos(writableStream, function(err) {
	if (err) return console.log('stream had an error or closed early');
	console.log('stream has finished', this === writableStream);
});

eos(duplexStream, function(err) {
	if (err) return console.log('stream had an error or closed early');
	console.log('stream has ended and finished', this === duplexStream);
});

eos(duplexStream, {readable:false}, function(err) {
	if (err) return console.log('stream had an error or closed early');
	console.log('stream has finished but might still be readable');
});

eos(duplexStream, {writable:false}, function(err) {
	if (err) return console.log('stream had an error or closed early');
	console.log('stream has ended but might still be writable');
});

eos(readableStream, {error:false}, function(err) {
	// do not treat emit('error', err) as a end-of-stream
});
```

## License

MIT

## Related

`end-of-stream` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one.

Version data entries

13 entries across 13 versions & 6 rubygems

Version Path
jester-data-8.0.0 node_modules/end-of-stream/README.md
ezii-os-5.2.1 node_modules/end-of-stream/README.md
ezii-os-2.0.1 node_modules/end-of-stream/README.md
ezii-os-1.1.0 node_modules/end-of-stream/README.md
ezii-os-1.0.0 node_modules/end-of-stream/README.md
ezii-os-0.0.0.1.0 node_modules/end-of-stream/README.md
ezii-os-0.0.0.0.1 node_modules/end-of-stream/README.md
optimacms-0.4.3 spec/dummy/node_modules/end-of-stream/README.md
optimacms-0.4.2 spec/dummy/node_modules/end-of-stream/README.md
locomotivecms-4.0.0.alpha1 app/javascript/node_modules/end-of-stream/README.md
locomotivecms-3.4.0 app/javascript/node_modules/end-of-stream/README.md
cortex-0.1.3 spec/dummy/node_modules/end-of-stream/README.md
dragonfly_puppeteer-0.1.0 node_modules/end-of-stream/README.md