Skip to content

Commit d128637

Browse files
committed
Feat: Add .done getter on paginators
1 parent 26a010a commit d128637

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

doc/paginators.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ for (const fetchedTweet of homeTimeline) {
2121
}
2222
```
2323

24+
## Check if a next page is available
25+
26+
You can know if a paginator is over by looking up the `.done` property.
27+
28+
```ts
29+
while (!homeTimeline.done) {
30+
await homeTimeline.fetchNext();
31+
}
32+
```
33+
2434
## Download next page
2535

2636
You can fetch the next page of the collection with the method `.fetchNext()`.

src/paginators/TwitterPaginator.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ export abstract class TwitterPaginator<TApiResult, TApiParams extends object, TI
145145
return this._realData;
146146
}
147147

148+
get done() {
149+
return !this.canFetchNextPage(this._realData);
150+
}
151+
148152
/**
149153
* Iterate over currently fetched items.
150154
*/

0 commit comments

Comments
 (0)