-
-
Notifications
You must be signed in to change notification settings - Fork 942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to the .pagination
API
#1215
Comments
You can use a rule that only forces you to have Regarding the |
FWIW, when there is more than one value to be passed in to a function I prefer to pass in an object so it can be destructured. This permits the access of any/all of the properties in the object and also allows further properties to be easily added at a later date. So the full signature for paginate({ response, allItems, currentItem }) If you only wanted paginate({ currentItem }) |
I too usually prefer object parameters when possible/sensible. I don't think it is common with callback signatures, though... |
@fiznool Good idea. We already did this with |
This brought me into checking this. |
I agree. We should make it an object instead in Got v12 (not soon, unfortunately). |
As for:
I haven't yet made up my mind. If you use the pagination API, please chime in on this. |
If anyone wants to see this happen in Got 12, now would be a time to submit a pull request, otherwise, we'll defer it to Got 13. |
@szmarczak sorry for the late PRs. Looks like they won't be needed after all. |
What problem are you trying to solve?
Improve
.pagination
API (and possibly performance and stability)Describe the feature
I would humbly suggest the following 2 breaking changes:
allItems
andcurrentItems
parameters ofpagination.paginate
,pagination.filter
andpagination.shouldContinue
My reasoning about parameters order is that probably most use cases don't need the
allItems
parameters, withcurrentItems
typically being more used. To be confirmed by other users, but if indeedcurrentItems
is used more thanallItems
then it should reflect in the order of parameters.It doesn't change how the Got code works but could save custom
pagination.paginate
,pagination.filter
andpagination.shouldContinue
from having an unused and unaesthetic_
as the second parameter... ;)stackAllItem
tofalse
As per the default of
allItems
, it implies a waste of CPU and RAM resources when unused. This is especially noticeable when iterating large datasets (and can results in a node.js crash in worst case scenarios)Checklist
The text was updated successfully, but these errors were encountered: