Replace r-json with fs and JSON.parse
michaellee opened this issue · comments
Hey hey Ionica,
I was looking into an issue where the emojis weren't rendering in my terminal where tmux was running. Looking over the library I was wondering if it was an outdated dependency or something. I don't believe it is and I think it has to do with tmux.
Nonetheless, while looking over your code, I was wondering if it would be better to just replace r-json with Node's fs.readFileSync
and then passing the results to JSON.parse
. Looking over the source for the JSON there didn't seem to be any specific rJSON benefits. And both the size output for rJSON and JSON.parse seems to be the same.
First and last lines of the image shows you the size is the same.
Let me know if my assumptions would benefit your project and I can create a PR. I figured having one less node dependency is a positive thing.
Again, thanks for this package 😄
Hey @michaellee!
Hmm, like you saw r-json
is really just readFileSync()
and then JSON.parse
. But I created r-json
and w-json
to prevent writing JSON.parse(readFileSync())
every time.
In the future, when hitting some issue (e.g. very large files), I may add some feature in w-json
and r-json
to be more than readFile
and writeFile
(maybe streams/promises whatever), and that feature will be propagated to all the dependents.
Regarding the initial problem: what operating system and terminal emulator are you using? It seems to work for me.
Hey Ionica, thanks for the reply! I actually looked over rjson and not r-json
the module you made. Sorry for the confusion, my mistake. I will look into using r-json
as I actually do read and write json files in a couple of the tools I've written :) Thanks again for creating such useful tools.
I'm on macOS 10.13.4. Using terminal.app. I'm also using oh-my-zsh and tmux 2.7
Cool!
I reproduced the problem with emojis, but it seems to be tmux
related. I'm not sure why it happens that way.
Maybe you can open an issue in tmux/tmux
or I can do it.