https://github.com/vweevers/on-stream-close
Callback when a stream has closed.
https://github.com/vweevers/on-stream-close
close nodejs npm-package readable-stream stream streamx
Last synced: about 2 months ago
JSON representation
Callback when a stream has closed.
- Host: GitHub
- URL: https://github.com/vweevers/on-stream-close
- Owner: vweevers
- License: mit
- Created: 2020-07-24T09:23:29.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-24T09:25:57.000Z (almost 5 years ago)
- Last Synced: 2025-03-28T21:39:07.234Z (about 2 months ago)
- Topics: close, nodejs, npm-package, readable-stream, stream, streamx
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# on-stream-close
**Callback when a stream has closed.** Alternative to [`stream.finished`](https://nodejs.org/api/stream.html#stream_stream_finished_stream_options_callback) and its predecessor [`end-of-stream`](https://github.com/mafintosh/end-of-stream) that utilize other events (like `end` and `finish`) which makes them compatible with older streams but they can't guarantee the stream has fully cleaned up its resources.
[](https://www.npmjs.org/package/on-stream-close)
[](https://www.npmjs.org/package/on-stream-close)
[](http://travis-ci.com/vweevers/on-stream-close)
[](https://standardjs.com)## Usage
```js
const osc = require('on-stream-close')osc(stream, function (err) {
// Stream has closed
})
```With promises:
```js
const osc = require('on-stream-close').promisesawait osc(stream)
```## Compatible stream flavors
- [`stream`](https://nodejs.org/api/stream.html): node >= 14.0.0 or >= 10.16.0 if `autoDestroy` is set to `true` by implementation
- [`readable-stream`](https://github.com/nodejs/readable-stream): >= 3.5.0 if `autoDestroy` is set to `true` by implementation
- [`streamx`](https://github.com/mafintosh/streamx): always
- [`minipass`](https://github.com/isaacs/minipass): not out of the box, an implementation can choose to emit close.## Install
With [npm](https://npmjs.org) do:
```
npm install on-stream-close
```## License
[MIT](LICENSE.md) © 2020-present Vincent Weevers