jprichardson / node-jsonfile

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

Add appendFile and appendFileSync #23

Closed kjsmita6 closed 9 years ago

kjsmita6 commented 9 years ago

I believe this time the changes I made are a lot better. I added the asynchronous version, kept the current style, and added tests. I think that the addition of appendFile will be greatly helpful for any users who really want to use it.

jprichardson commented 9 years ago

Ok, I like these new changes. Let's explore this a bit... I do often write JSON records to a file, but I use a streams. What's your use case?

kjsmita6 commented 9 years ago

If by "use case" you mean how I use it, one example is if someone tries to steal items from my Steam Bot (seishun/node-steam). I can append to a json file the user's name, their id, the time, etc. I would mainly use appendFile sort of like a custom JSON log. Yes, I could use Winston logger for this, but jsonfile allows me to customize what I log.

kjsmita6 commented 9 years ago

Bumping as it's been almost a week without a reply.

jprichardson commented 9 years ago

Bumping as it's been almost a week without a reply.

Sorry about that. I'm not trying to ignore you as I have been contemplating this. This is a really good PR with really good functionality. I have some problems with this at the moment:

  1. I'd like to get the four methods in this library working perfectly and reliably without adding any additional unnecessary code that doesn't satisfy this. (See regressions in changelog).
  2. I'm wondering if it'd be confusing that readFile, writeFile are used in the context of one JSON object (one JSON record), whereas appendFile would imply appending another JSON object, i.e. this JSON file would have multiple JSON objects (multiple JSON records). Would this be confusing? Is there a standard / mime-type of newline delimited JSON?

As much as I'd like to accept this, I'm going to reject this unless some thoughts/points are raised that perhaps I didn't consider.

Please share any thoughts that you have on this (obviously to the degree as to which you feel it's worth your time). Thanks for your interest in this module.