From 7473a3926d9c2b69d7348235359c9dcb28c0e542 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Thu, 25 Jan 2024 22:12:49 -0600 Subject: [PATCH] refactor: Use callback for octokit conversion --- src/octokit-wrapper.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/octokit-wrapper.ts b/src/octokit-wrapper.ts index f1c4fb1..4fd58e5 100644 --- a/src/octokit-wrapper.ts +++ b/src/octokit-wrapper.ts @@ -52,24 +52,19 @@ export async function setup_octokit( } export async function pull_releases( - octokit: InstanceType -): Promise { - const all_release_data: object[] = await all_nf_release_data(octokit) - const all_releases: NextflowRelease[] = [] - for (const data of all_release_data) { - all_releases.push(nextflow_release(data)) - } - - return all_releases -} - -export async function all_nf_release_data( ok: InstanceType -): Promise { +): Promise { return await ok.paginate( ok.rest.repos.listReleases, NEXTFLOW_REPO, - response => response.data + response => { + const all_releases: NextflowRelease[] = [] + const releases_data = response.data + for (const release_data of releases_data) { + all_releases.push(nextflow_release(release_data)) + } + return all_releases + } ) }