xml-js icon indicating copy to clipboard operation
xml-js copied to clipboard

how to use createReadStream instead of readFileSync

Open at4446 opened this issue 3 years ago • 0 comments

I was wondering how it is possible to use createReadStream instead of readFileSync? I am trying to read an xml which is 500MB so node is running out of heap memory so I need to read the file in chunk instead. let json = convert.xml2js( fs.readFileSync(entities.xml), { instructionHasAttributes: true, compact: true, spaces: 4, reversible: true, } );

when I change fs readFileSync to fs.createReadStream I get the following error:

UnhandledPromiseRejectionWarning: Error: Text data outside of root node.

at4446 avatar May 13 '21 03:05 at4446