jsonarrayfs 
jsonarrayfs is a Node.js library designed to facilitate efficient handling of JSON array data stored in files. It offers functionality for streaming JSON array elements in batches, allowing for reduced memory consumption when working with large datasets. Additionally, jsonarrayfs provides a method for appending new data to existing JSON array files without loading the entire dataset into memory.
Installation
To install jsonarrayfs, use:
npm install jsonarrayfs
Features
- Stream JSON array elements:
import { createReadStream } from "jsonarrayfs";
const streamer = await createReadStream("./data.json", { encoding: 'utf-8' });
for await (const chunk of streamer.stream(100)) {
}
- Append data to existing JSON array:
import { appendFile } from "jsonarrayfs";
const newData = [
{ id: 1, name: "JavaScript" },
{ id: 2, name: "Go" }
];
await appendFile("./data.json", 'utf-8', ...newData);
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
MIT License