This commit is contained in:
eric sciple 2020-01-24 12:20:19 -05:00
parent beb1329f9f
commit 2b95e76931
7736 changed files with 1874747 additions and 51184 deletions
node_modules/@octokit/rest/plugins/pagination

View file

@ -1,34 +1,40 @@
module.exports = paginate
module.exports = paginate;
const iterator = require('./iterator')
const iterator = require("./iterator");
function paginate (octokit, route, options, mapFn) {
if (typeof options === 'function') {
mapFn = options
options = undefined
function paginate(octokit, route, options, mapFn) {
if (typeof options === "function") {
mapFn = options;
options = undefined;
}
options = octokit.request.endpoint.merge(route, options)
return gather(octokit, [], iterator(octokit, options)[Symbol.asyncIterator](), mapFn)
options = octokit.request.endpoint.merge(route, options);
return gather(
octokit,
[],
iterator(octokit, options)[Symbol.asyncIterator](),
mapFn
);
}
function gather (octokit, results, iterator, mapFn) {
return iterator.next()
.then(result => {
if (result.done) {
return results
}
function gather(octokit, results, iterator, mapFn) {
return iterator.next().then(result => {
if (result.done) {
return results;
}
let earlyExit = false
function done () {
earlyExit = true
}
let earlyExit = false;
function done() {
earlyExit = true;
}
results = results.concat(mapFn ? mapFn(result.value, done) : result.value.data)
results = results.concat(
mapFn ? mapFn(result.value, done) : result.value.data
);
if (earlyExit) {
return results
}
if (earlyExit) {
return results;
}
return gather(octokit, results, iterator, mapFn)
})
return gather(octokit, results, iterator, mapFn);
});
}