import fs from 'fs' import { Transform } from 'stream' import JSONStream from 'JSONStream' // Custom transform stream const transformer = new Transform({ objectMode: true, transform(jsonItem, encoding, callback) { // your logic goes here... // const updatedItem = {} callback(null, updatedItem) } }) const input = fs.createReadStream('./raw-input.json', 'utf8') const output = fs.createWriteStream('processed-output.json', 'utf8') input .pipe(JSONStream.parse('*')) // JSON structure parser pattern .pipe(transformer) // Process data .pipe(JSONStream.stringify()) // Convert it back to JSON .pipe(output) // save the result