Skip to content

Instantly share code, notes, and snippets.

@myndzi
Created December 23, 2016 03:00
Show Gist options
  • Select an option

  • Save myndzi/0667436bfb4efb631d68683034a8c681 to your computer and use it in GitHub Desktop.

Select an option

Save myndzi/0667436bfb4efb631d68683034a8c681 to your computer and use it in GitHub Desktop.
function getFoos(nextOffset, results) {
nextOffset = nextOffset || 0;
results = results || [ ];
return Promise.try(() => {
return getSomeFoos(nextOffset);
}).then(res => {
let newResults = results.concat(res.foos);
return res.hasMore ?
getFoos(res.nextOffset, newResults) :
newResults
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment