jprichardson / node-jsonfile

Easily read/write JSON files.
MIT License
1.2k stars 321 forks source link

Better have sync stringify to improve performance. #99

Closed kanaksinghal closed 6 years ago

kanaksinghal commented 6 years ago

https://github.com/jprichardson/node-jsonfile/blob/0cb15103d61cbb69cc77e7fc6d43bf9d6067006e/index.js#L101

For my use case, I have large files to dump and using synchronous JSON.stringify limits me as it may cause the program to freeze while the value is being computed. So while I'm not specifically calling the writeSync method, I'd prefer to have stringify async as well. Using following module for async JSON stringify: https://www.npmjs.com/package/async-json

RyanZim commented 6 years ago

That module hasn't been updated since 2015; I don't want to include an outdated dependency like that in such a highly-used lib. Furthermore, handling such large JSON files is an edge case IMO; if you're dealing with such big files, you're gonna have to build some of your own tooling. It'd be pretty trivial to build a stripped-down version of this lib that uses async-json for your uses (it's under 150 lines already, would be under 100 lines if we didn't include sync methods). Closing as wontfix.