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
- Host: GitHub
- URL: https://github.com/parro-it/ai-from-stream
- Owner: parro-it
- License: mit
- Created: 2017-11-17T16:49:21.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-28T18:21:55.000Z (about 8 years ago)
- Last Synced: 2024-10-13T08:57:34.199Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 283 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# ai-from-stream
[](http://travis-ci.org/parro-it/ai-from-stream)
[](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