Thanks for the detailed explanation ❤️
My goal is to be pure JS implementation with no binary dependencies.
I think streams are optimized to minimize CPU and memory overheads
There's always a lot to learn, I still learn every day.
No bins is good for supporting front and back as well as being hardware agnostic.
You should take a look at fs.open, and see if there's a flock, etc.
You might decide you don't need to implement flock but if you make that decision it's crucial to understand concurrency issues.
To test this might be easier than you think. See if there's a sleepSync. Then after writing each line sleep.
Then run a basic program filling the in memory store then saving it twice at the same time.
You'll see lines from both. Ok it doesn't matter you mgiht think they're the same and it's just the same op twice but initialise each database so that they have the same keys but different values.
If you really push it, just run the program thousands of times at the same time with no delays, then you can get something like the file will have one line that suddenly stops and then the line from another program continues meaning the lines wont even be parsable in JSON.
When people are starting out the first thought is "how can I make this work". The next step, the revolution, is thinking "how can I break this" :D.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.