Skip to content

Commit

Permalink
Merge pull request #421 from Esri/at/search-all-items-func
Browse files Browse the repository at this point in the history
Adding batch size param
  • Loading branch information
drewdaemon authored Nov 9, 2020
2 parents 3a8e3a9 + 8846023 commit e19797a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/common/src/items/fetch-all-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ const MAX_NUM = 100;
* @param {SearchFunction} searchFunc
* @param {ISearchOptions} opts
* @param {number} limit
* @param {batchSize} number of concurrent requests at a time
* @returns {Promise<SearchableType[]>}
*/
export function fetchAllPages(
searchFunc: SearchFunction,
opts: ISearchOptions,
limit = -1
limit = -1,
batchSize?: number
): Promise<SearchableType[]> {
const pageSize = opts.num || MAX_NUM;
const firstStart = opts.start || 1;
Expand Down Expand Up @@ -48,7 +50,7 @@ export function fetchAllPages(
}
const batchSearchFunc = (start: number) =>
searchFunc({ ...opts, start, num: pageSize });
return batch(starts, batchSearchFunc).then(responses => [
return batch(starts, batchSearchFunc, batchSize).then(responses => [
firstResponse,
...responses
]);
Expand Down

0 comments on commit e19797a

Please sign in to comment.