Sha256: 177b2368d761e70733e06bbc2ff58f59360e49643aa86b99bc3114ba7ee2fe0c

Contents?: true

Size: 1.66 KB

Versions: 28

Compression:

Stored size: 1.66 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

[![Build status](https://travis-ci.org/mafintosh/end-of-stream.svg?branch=master)](https://travis-ci.org/mafintosh/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

28 entries across 27 versions & 8 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/end-of-stream/README.md
disco_app-0.18.0 test/dummy/node_modules/end-of-stream/README.md
disco_app-0.18.2 test/dummy/node_modules/end-of-stream/README.md
disco_app-0.16.1 test/dummy/node_modules/end-of-stream/README.md
isomorfeus-puppetmaster-0.5.5 node_modules/end-of-stream/README.md
isomorfeus-puppetmaster-0.5.4 node_modules/end-of-stream/README.md
disco_app-0.15.2 test/dummy/node_modules/end-of-stream/README.md
isomorfeus-puppetmaster-0.5.3 node_modules/end-of-stream/README.md
disco_app-0.18.4 test/dummy/node_modules/end-of-stream/README.md
disco_app-0.18.1 test/dummy/node_modules/end-of-stream/README.md
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/end-of-stream/README.md
disco_app-0.14.0 test/dummy/node_modules/end-of-stream/README.md
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/end-of-stream/README.md
isomorfeus-puppetmaster-0.5.2 node_modules/end-of-stream/README.md
isomorfeus-puppetmaster-0.5.1 node_modules/end-of-stream/README.md
isomorfeus-puppetmaster-0.5.0 node_modules/end-of-stream/README.md
tang-0.2.1 spec/tang_app/node_modules/end-of-stream/README.md
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/end-of-stream/README.md
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/end-of-stream/README.md
ruby2js-4.0.4 lib/tasks/testrails/node_modules/end-of-stream/README.md