You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of needing to call readFile, modify the Json, and later call writeFile, add an updateFile method that accept a literal object and use it's attributes and hierarchy to update the content of the Json file. To remove entries, they can be set to undefined, so JSON.stringify() will ignore them later.
The text was updated successfully, but these errors were encountered:
Ultimately, in a updateFile() method, you'd still need to call fs.writeFile(). There are so many json/object diff libraries out there, that you could easily create your own updateFile() and updateFileSync() methods in conjunction with this library.
I'm not sure if it doesn't falls in the scope of the library (I think it does). In any case, I've crafted my own updateFile function by using the merge:
Instead of needing to call readFile, modify the Json, and later call writeFile, add an updateFile method that accept a literal object and use it's attributes and hierarchy to update the content of the Json file. To remove entries, they can be set to
undefined
, so JSON.stringify() will ignore them later.The text was updated successfully, but these errors were encountered: