node-jsonl
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

node-jsonl

NodeJS Iterate over JSONL Line Delimited JSON

Install

Using Yarn:

yarn add node-jsonl

or using NPM:

npm install --save node-jsonl

Import Module

CommonJS

const jsonl = require("node-jsonl");

Typescript (ES6)

import * as jsonl from "node-jsonl";

Quickstart

example.jsonl

{"name":"joe"}
{"name":"bob"}
{"name":"frank"}
{"name":"marie"}

Read JSONL one line at a time

const rl = jsonl.readlines<T>(filepath)
 
while (true) {
    const {value, done} = await rl.next()
    if (done) break;
    console.log(value); // value => T
}

Read JSONL multiple lines at a time

const rl = jsonl.readlinesChunk<T>(filepath, maxlines)
 
while (true) {
    const {value, done} = await rl.next()
    if (done) break;
    console.log(value); // value => Array<T>
}

Readme

Keywords

none

Package Sidebar

Install

npm i node-jsonl

Weekly Downloads

595

Version

0.1.0

License

MIT

Unpacked Size

7.91 kB

Total Files

5

Last publish

Collaborators

  • deniscarriere