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

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

Awesome Lists containing this project

README

          

[![npm](https://img.shields.io/npm/v/reader-line-iterator.svg)](https://www.npmjs.com/package/reader-line-iterator)
[![License](https://img.shields.io/badge/License-0BSD-blue.svg)](https://spdx.org/licenses/0BSD.html)
[![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\&label\&labelColor=blue\&color=555555)](https://typescriptlang.org)
[![bundlejs](https://deno.bundlejs.com/?q=reader-line-iterator\&badge=detailed)](https://bundlejs.com/?q=reader-line-iterator)
[![downloads](http://img.shields.io/npm/dm/reader-line-iterator.svg?style=flat-square)](https://npmjs.org/package/reader-line-iterator)
[![GitHub Issues](https://img.shields.io/github/issues/arlac77/reader-line-iterator.svg?style=flat-square)](https://github.com/arlac77/reader-line-iterator/issues)
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Freader-line-iterator%2Fbadge\&style=flat)](https://actions-badge.atrox.dev/arlac77/reader-line-iterator/goto)
[![Styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![Known Vulnerabilities](https://snyk.io/test/github/arlac77/reader-line-iterator/badge.svg)](https://snyk.io/test/github/arlac77/reader-line-iterator)
[![Coverage Status](https://coveralls.io/repos/arlac77/reader-line-iterator/badge.svg)](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