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
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.
The text was updated successfully, but these errors were encountered:
fixnodejs#6336
1. The `historySize` to default to `30` only if `undefined`.
2. If `historySize` is set to 0, then disable caching the line.
3. Added unit tests.
4. Updated documentation.
1. The `historySize` to default to `30` only if `undefined`.
2. If `historySize` is set to 0, then disable caching the line.
3. Added unit tests.
4. Updated documentation.
Fixes: #6336
PR-URL: #6352
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
This is all the docs say about
historySize
inreadline
: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:
gives
30
;If I get it right, it is due to this fragment in the
readline.js
:I don't know if failure to distinguish
0
andundefined
here is a bug or a feature.Maybe these fixes could be done:
Tactically:
0
is not a legal value forhistorySize
.readline.js
(currently the function throws only ifhistorySize < 0
). Now the user value is silently secretly discarded.Strategically:
historySize
to0
. I test some code withhistorySize: 30
andhistorySize: 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.The text was updated successfully, but these errors were encountered: