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
{{ message }}
Repository navigation
Undocumented and possibly wrong behavior of historySize in readline #6336
This is all the docs say about historySize in readline:
historySize - maximum number of history lines retained. Defaults to 30.
If I want to use readline for reading a big file line by line (see example in docs), I don't need the history tracking. However I cannot set historySize to 0:
I don't know if failure to distinguish 0 and undefined here is a bug or a feature.
Maybe these fixes could be done:
Tactically:
Clarify in the docs that 0 is not a legal value for historySize.
May be add a throw in the readline.js (currently the function throws only if historySize < 0). Now the user value is silently secretly discarded.
Strategically:
Add the possibility to turn off history tracking by setting historySize to 0. I test some code with historySize: 30 and historySize: 1 — the second case uses slightly less memory, but slightly more time. The history size has less impact on the performance than history tracking itself because of all the operations in the _addHistory function. If I want to read the file with 100000 lines, the 100000 bunches of array operations in this function is a considerable write-off overhead.
Activity
Fixed nodejs#6336:
Document update for nodejs#6336
readline: allow history to be disabled
readline: allow history to be disabled
readline: allow history to be disabled