mirror of
https://github.com/MillironX/setup-nextflow.git
synced 2024-11-22 01:46:04 +00:00
feat: Add lazy release iterator
This commit is contained in:
parent
c71f252745
commit
4af33538f0
1 changed files with 34 additions and 0 deletions
|
@ -51,6 +51,40 @@ export async function setup_octokit(
|
|||
return octokit
|
||||
}
|
||||
|
||||
export async function* release_iter(
|
||||
octokit: InstanceType<typeof GitHub>
|
||||
): AsyncGenerator<NextflowRelease> {
|
||||
const iterator = octokit.paginate.iterator(
|
||||
octokit.rest.repos.listReleases,
|
||||
NEXTFLOW_REPO
|
||||
)
|
||||
let item_index = 0
|
||||
let release_items = []
|
||||
|
||||
/* eslint-disable-next-line @typescript-eslint/unbound-method */
|
||||
const { next } = iterator[Symbol.asyncIterator]()
|
||||
|
||||
let request = await next()
|
||||
|
||||
return {
|
||||
async next() {
|
||||
if (item_index >= release_items.length) {
|
||||
if (request.done) {
|
||||
return { done: true }
|
||||
}
|
||||
|
||||
request = await next()
|
||||
release_items = request.value.data
|
||||
item_index = 0
|
||||
}
|
||||
return {
|
||||
value: nextflow_release(release_items[item_index++]),
|
||||
done: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function pull_releases(
|
||||
ok: InstanceType<typeof GitHub>
|
||||
): Promise<NextflowRelease[]> {
|
||||
|
|
Loading…
Reference in a new issue