Tiny ESM helpers for reading files line by line.
- Lightweight: tiny wrapper around Node.js core modules with no dependencies.
- Functional API: simple
read(handler)(path)style for quick scripting. - JSONL-friendly:
readJsonparses one JSON object per line. - Node 22+ ready: modern ESM and
node:imports.
npm i readline-esimport { read, readJson } from 'readline-es';
read((line) => {
console.log('text line:', line);
})('./example.txt');
readJson((obj) => {
console.log('json line:', obj);
})('./example.json');- Creates and returns a Node.js
readline.Interface - Calls
onLine(line)for each line whenonLineis provided
- Same as
read, but each line is parsed withJSON.parse - Calls
onLine(parsedObject)for each JSON line