Skip to content

Instantly share code, notes, and snippets.

@SohumB
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SohumB/09c4a31ceed10f1bf55d to your computer and use it in GitHub Desktop.
Save SohumB/09c4a31ceed10f1bf55d to your computer and use it in GitHub Desktop.
pageRecurse(fn, opts, page) {
var withPage = _.clone(opts);
  withPage.page = page;
  return fn(withPage).then(results => {
    return _.isEmpty(results)
             ? results
             : this.pageRecurse(fn, opts, page + 1).then(following => results.concat(following));
  });
}
getReleasesFromPage(...args) {
return this.pageRecurse(opts => this.github.releases.listReleasesAsync(opts), ...args);
}
getPullRequestsFromPage(...args) {
return this.pageRecurse(opts => this.github.pullRequests.getAllAsync(opts), ...args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment