github.com/nektos/act@v0.2.63/pkg/runner/testdata/actions/node16/node_modules/@octokit/plugin-paginate-rest/dist-src/paginate.js (about) 1 import { iterator } from "./iterator"; 2 export function paginate(octokit, route, parameters, mapFn) { 3 if (typeof parameters === "function") { 4 mapFn = parameters; 5 parameters = undefined; 6 } 7 return gather(octokit, [], iterator(octokit, route, parameters)[Symbol.asyncIterator](), mapFn); 8 } 9 function gather(octokit, results, iterator, mapFn) { 10 return iterator.next().then((result) => { 11 if (result.done) { 12 return results; 13 } 14 let earlyExit = false; 15 function done() { 16 earlyExit = true; 17 } 18 results = results.concat(mapFn ? mapFn(result.value, done) : result.value.data); 19 if (earlyExit) { 20 return results; 21 } 22 return gather(octokit, results, iterator, mapFn); 23 }); 24 }