Dump large Javascript arrays to JSON file without using too much memory.
If you're looking for a way to read from JSON file into memory, check out jsonstrom.
npm i dumpjson
const dumpjson = require('dumpjson')
// Filename to dump to
const writer = dumpjson('file.json')
// Very large array
const largeArray = [...]
for (const item of largeArray) {
writer.write(item)
}
// Indicate end of stream
writer.end()
// Await if you need to wait for all writes to finish
await writer.end()
MIT Licensed. Enjoy!