Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dex4er/js-stream.finished

Polyfill for stream.finished in node versions < v10
https://github.com/dex4er/js-stream.finished

Last synced: 10 days ago
JSON representation

Polyfill for stream.finished in node versions < v10

Awesome Lists containing this project

README

        

# stream.finished

[![Build Status](https://secure.travis-ci.org/dex4er/js-stream.finished.svg)](http://travis-ci.org/dex4er/js-stream.finished) [![npm](https://img.shields.io/npm/v/stream.finished.svg)](https://www.npmjs.com/package/stream.finished)

Polyfill for stream.finished in node versions < v10

node v10.0.0 added support for a built-in `stream.finished`:

This package provides the built-in
[`stream.finished`](https://nodejs.org/api/stream.html#stream_stream_finished_stream_callback)
in node v10.0.0 and later, and a replacement in other environments.

This package implements the [es-shim API](https://github.com/es-shims/api)
interface. It works in an ES3-supported environment and complies with the
[spec](http://www.ecma-international.org/ecma-262/6.0/).

## Installation

```shell
npm install stream.finished
```

_Additionally for Typescript:_

```shell
npm install -D @types/node
```

## Usage

### Direct

```js
const finished = require('stream.finished');
// Use `finished` just like the built-in method on `stream`
```

_Typescript:_

```ts
import finished from 'stream.finished';
// Use `finished` just like the built-in method on `stream`
```

### Shim

```js
require('stream.finished/shim')();
// `stream.finished` is now defined
const stream = require('stream');
// Use `stream.finished`
```

or:

```js
require('stream.finished/auto');
// `stream.finished` is now defined
const stream = require('stream');
// Use `stream.finished`
```

_Typescript:_

```js
import finishedShim from 'stream.finished/shim';
finishedShim();
// `stream.finished` is now defined
import stream from 'stream';
// Use `stream.finished`
```

or:

```js
import 'stream.finished/auto';
// `stream.finished` is now defined
import stream from 'stream';
// Use `stream.finished`
```

## License

Copyright (c) 2018-2019 Piotr Roszatycki

Copyright Node.js contributors. All rights reserved.

Copyright (c) 2014 Mathias Buus

[MIT](https://opensource.org/licenses/MIT)