Skip to content

Commit

Permalink
Merge pull request #1 from corinv/master
Browse files Browse the repository at this point in the history
 Fix page count sometimes missing last partial page
  • Loading branch information
johndagostino authored Mar 7, 2019
2 parents 90a7e7d + 692ae03 commit b549d2f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ async function* batch(query = { batchSize: 1000 }) {
if (count === 0) {
return false;
}

const pages = Math.max(Math.round(count / query.batchSize), 1);
const pagesRemainder = (count % query.batchSize) ? 1 : 0;
const pages = Math.floor(count / query.batchSize) + pagesRemainder;
let page = 1;

const params = Object.assign({}, query);
Expand Down

0 comments on commit b549d2f

Please sign in to comment.