| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Is there a benefit to loading the current history into memory rather than just appending to the as-is history file? From what I'm seeing, it would allow a programmer to access previous history - at the expense of a breaking change to what they might have previously relied on (i.e., first command ran = first index). |
Sorry, something went wrong.
|
Sorry, I didn't get your point. |
Sorry, something went wrong.
|
@a8m its alright. I intended to ask: why load on startup and overwrite the entire file every time a new line is entered, rather than appending each time a new line is entered? For a big file (lets say 10Mb), and someone enters twenty lines, that'd be ~210Mb of input / output rather than just a few bytes (~8Kb) by appending to the file using fs.appendFileSync(). This would also avoid using lots of RAM by loading the file into memory. Edit: this would also allow for two readline's to be run at once with the same history file. |
Sorry, something went wrong.
|
I agree with you @brendanashworth, it really more sense. var rl = readline.createInterface({
//...
history: 'path/to/history'
});
rl.setHistorySize(100);what are your thoughts? |
Sorry, something went wrong.
|
@a8m I like that idea, 👍 from me on that topic. On a side note, could you clean up your commit title and description to fit the guidelines? |
Sorry, something went wrong.
|
Update: Also, I've updated the docs and the tests too. |
Sorry, something went wrong.
There was a problem hiding this comment.
This change should not be made to the REPL module, it should be specific to iojs command line repl.
Sorry, something went wrong.
|
I don't think readline should do any io. The user can just pass history array and retrieve it later |
Sorry, something went wrong.
|
@vkurchatkin writing to the terminal is also io, but I get your point. readline.createInterface({
//...
history: loadSync('history')
})
.on('line', // append to a file)
.on('close', // or save on closing)If this is acceptable to you guys, I'll make this changes. |
Sorry, something went wrong.
|
@a8m it is, but readline doesn't write directly, you provide a stream. This way you can use it with any kind of stream. The same principle applies to history, so that user can store history in memory or database. |
Sorry, something went wrong.
|
@piscisaureus this PR was updated after @vkurchatkin comments. |
Sorry, something went wrong.
There was a problem hiding this comment.
it's not clear from the example what is the result of loadHistorySync(). It's better to use array literal
Sorry, something went wrong.
There was a problem hiding this comment.
history should be passed here as well
Sorry, something went wrong.
There was a problem hiding this comment.
Right! (I'm usually using it with option object)
changed!
Sorry, something went wrong.
There was a problem hiding this comment.
style: missing semicolon here
Sorry, something went wrong.
|
Is there an update on this? It hasn't been touched in a while. |
Sorry, something went wrong.
|
It's up to you guys. |
Sorry, something went wrong.
|
With 0450ce7 landed, I think this may be obsolete now. |
Sorry, something went wrong.
|
Yep, seems like it. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
As I commented in #343
I think the persistent history support should be part of the readline module.
After this changes, any cli that using readline would be able to support too.
e.g:
The "main" changes is in the readline module and it's tested too.
I also changed a bit the repl module, and add the history support by default.
Maybe it should become with flags(NODE_DISABLE_HISTORY, NODE_HISTORY_PATH) like @evanlucas suggested, but this is out of the scope of this PR.
Thanks.