https://github.com/arlac77/reader-line-iterator
Convert a reader into a async iterator emitting text lines
https://github.com/arlac77/reader-line-iterator
Last synced: 8 months ago
JSON representation
Convert a reader into a async iterator emitting text lines
- Host: GitHub
- URL: https://github.com/arlac77/reader-line-iterator
- Owner: arlac77
- License: 0bsd
- Created: 2020-08-13T08:18:55.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-10-07T18:01:23.000Z (8 months ago)
- Last Synced: 2025-10-07T20:14:32.927Z (8 months ago)
- Language: JavaScript
- Size: 1.99 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/reader-line-iterator)
[](https://spdx.org/licenses/0BSD.html)
[](https://typescriptlang.org)
[](https://bundlejs.com/?q=reader-line-iterator)
[](https://npmjs.org/package/reader-line-iterator)
[](https://github.com/arlac77/reader-line-iterator/issues)
[](https://actions-badge.atrox.dev/arlac77/reader-line-iterator/goto)
[](https://github.com/prettier/prettier)
[](http://commitizen.github.io/cz-cli/)
[](https://snyk.io/test/github/arlac77/reader-line-iterator)
[](https://coveralls.io/github/arlac77/reader-line-iterator)
# reader-line-iterator
Convert a reader into a async iterator emitting text lines
```js
import { lineIterator } from "reader-line-iterator";
const result = await fetch("http://somewhere/mytext.txt");
for await (const line of lineIterator(result.body.getReader())) {
console.log(line);
}
```
# API
### Table of Contents
* [lineIterator](#lineiterator)
* [Parameters](#parameters)
## lineIterator
Extracts lines from a reader and delivers them as an async iterator.
### Parameters
* `reader` **(ReadableStreamDefaultReader | ReadableStreamBYOBReader)**
* `decoder` **[TextDecoder](https://developer.mozilla.org/docs/Web/API/TextDecoder)** (optional, default `new TextDecoder()`)
Returns **AsyncIterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** extracted lines
# install
With [npm](http://npmjs.org) do:
```shell
npm install reader-line-iterator
```
# license
BSD-2-Clause