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

https://github.com/parro-it/ai-from-stream

create an async iterable from a stream
https://github.com/parro-it/ai-from-stream

Last synced: 10 months ago
JSON representation

create an async iterable from a stream

Awesome Lists containing this project

README

          

# ai-from-stream

[![Travis Build Status](https://img.shields.io/travis/parro-it/ai-from-stream/master.svg)](http://travis-ci.org/parro-it/ai-from-stream)
[![NPM downloads](https://img.shields.io/npm/dt/ai-from-stream.svg)](https://npmjs.org/package/ai-from-stream)

> create an async iterable from a stream

This module convert an instance of readable node Stream into an async iterable.

## Usage

Write content of a file in a for loop:

```js
import fromStream from ".";
import { createReadStream } from "fs";

const stream = createReadStream(`file.txt`, "utf8");
for await (const chunk of fromStream(stream)) {
console.log(chunk);
}
```

This will output the content of `file.txt` file

## API

### aiFromStream

Create an async iterable from a stream

**Parameters**

* `stream` **ReadableStream** the stream to transform

Returns **AsyncIterable** converted iterator

## Install

With [npm](https://npmjs.org/) installed, run

```bash
npm install --save ai-from-stream
```

## See Also

* [`noffle/common-readme`](https://github.com/noffle/common-readme)

## License

MIT