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
Pass allItems
and currentItems
to _pagination.paginate()
#1100
Changes from 16 commits
59a2ea1
791f297
1186829
d1d521b
4232b81
a4b1a2b
7b01010
bccd95e
de3c26e
3f29cc8
a7c5c69
68cc75a
7ebf342
e1fa9bd
f60aaab
872e27b
b21be19
3d7959e
c31f2f9
86d57b9
b10be23
09c41c0
8054ab1
e49dec2
4f2e21a
9850542
badc8be
68f0c42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -680,25 +680,27 @@ A function that transform [`Response`](#response) into an array of items. This i | |
###### \_pagination.paginate | ||
|
||
Type: `Function`\ | ||
Default: [`Link` header logic](source/index.ts) | ||
Default: `(response, allItems, currentItems) => getLinkFromHeaders(response)` (find details [here](source/index.ts)) | ||
|
||
A function that returns an object representing Got options pointing to the next page. If there are no more pages, `false` should be returned. | ||
|
||
For example, if you want to stop when the response contains less items that expected, you should use `(response, allItems, currentItems) => currentItems.length < LIMIT ? false : { url: getNextLink(response, allItems, currentItems) }`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, it's updated. |
||
|
||
###### \_pagination.filter | ||
|
||
Type: `Function`\ | ||
Default: `(item, allItems) => true` | ||
Default: `(item, allItems, currentItems) => true` | ||
|
||
Checks whether the item should be emitted or not. | ||
Checks whether the item should be emitted or not. `allItems` is an array of the all emitted items, while `currentItems` is an array of the current response items. | ||
|
||
###### \_pagination.shouldContinue | ||
|
||
Type: `Function`\ | ||
Default: `(item, allItems) => true` | ||
Default: `(item, allItems, currentItems) => true` | ||
|
||
Checks whether the pagination should continue. | ||
Checks whether the pagination should continue. `allItems` is an array of the all emitted items, while `currentItems` is an array of the current response items. | ||
|
||
For example, if you need to stop **before** emitting an entry with some flag, you should use `(item, allItems) => !item.flag`. If you want to stop **after** emitting the entry, you should use `(item, allItems) => allItems.some(entry => entry.flag)` instead. | ||
For example, if you need to stop **before** emitting an entry with some flag, you should use `(item, allItems, currentItems) => !item.flag`. If you want to stop **after** emitting the entry, you should use `(item, allItems, currentItems) => allItems.some(entry => entry.flag)` instead. | ||
|
||
###### \_pagination.countLimit | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I restored it but changed the sentence afterwards to make clear how the signature of the function should be. This should make it easier for users without diving into the code first.