Skip to content

Commit

Permalink
feat: Remove next() argument
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Paginator#next no longer accepts an argument. Please recreate Paginator if you want to reset the internal state
  • Loading branch information
neet committed Dec 23, 2022
1 parent 58ba2c7 commit 5370e0c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ export class Paginator<Entity, Params = never>
.replace(/^https?:\/\/[^/]+/, '');
};

async next(params?: Params): Promise<IteratorResult<Entity>> {
async next(): Promise<IteratorResult<Entity>> {
if (this.nextPath == undefined) {
return { done: true, value: undefined };
}

const reset = params != undefined;
const response = await this.http.request({
path: reset ? this.initialPath : this.nextPath,
searchParams: (params ?? this.nextParams) as Record<string, unknown>,
requestInit: { method: 'GET' },
path: this.nextPath,
searchParams: this.nextParams as Record<string, unknown>,
});

this.nextPath =
Expand Down

0 comments on commit 5370e0c

Please sign in to comment.