NodeJS Iterate over JSONL
npm install node-jsonlnode-jsonl> NodeJS Iterate over JSONL Line Delimited JSON
Using Yarn:
``bash`
yarn add node-jsonl
or using NPM:
`bash`
npm install --save node-jsonl
CommonJS
`js`
const jsonl = require("node-jsonl");
Typescript (ES6)
`js`
import * as jsonl from "node-jsonl";
example.jsonl
`json`
{"name":"joe"}
{"name":"bob"}
{"name":"frank"}
{"name":"marie"}
`ts
const rl = jsonl.readlines
while (true) {
const {value, done} = await rl.next()
if (done) break;
console.log(value); // value => T
}
`
`ts
const rl = jsonl.readlinesChunk
while (true) {
const {value, done} = await rl.next()
if (done) break;
console.log(value); // value => Array
}
``