npm.io
1.2.3 • Published 10 months ago

reader-line-iterator

Licence
0BSD
Version
1.2.3
Deps
0
Size
7 kB
Vulns
0
Weekly
0

npm License Typed with TypeScript bundlejs downloads GitHub Issues Build Status Styled with prettier Commitizen friendly Known Vulnerabilities Coverage Status

reader-line-iterator

Convert a reader into a async iterator emitting text lines

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

Extracts lines from a reader and delivers them as an async iterator.

Parameters
  • reader (ReadableStreamDefaultReader | ReadableStreamBYOBReader)
  • decoder TextDecoder (optional, default new TextDecoder())

Returns AsyncIterable<string> extracted lines

install

With npm do:

npm install reader-line-iterator

license

BSD-2-Clause