generated at
async-lib

内容物
promisify()
promisifyするやつ
ある値を取り出してから次に取り出す間に生成された値の取り扱い方をoptionから変えられる
maxQueued: 0 getPromiseSettledAnytimesと同じ挙動になる
maxQueued の値によらず、 resolve() 及び reject() の第二引数に { forceQueued: true } を渡すと間引かれない
pool()
promise-parallel-throttleみたいなやつ
sort() / sortBySettled()
Promise<T>[] Async Generatorへの変換する
当初は Iterable<Promise<T>> を変換するつもりだったが、無限リストを入れられるとprogramが停止してしまうので、有限な配列に制限した
Iterable<T>にできないか検討してみたけど、やはりだめそうtakker
event listenerやmessage channelみたいなので上手いことやり取りすればいけるか?
いや、iteratorの消費を中断できないだろ
全部消費されるまで別の処理を行えない

実装したいこと

2022-04-18
18:20:35 pool がちゃんと動いているのか疑問になったので、確かめてみる
テストは通っているから気にしなくても良さそうではあるが
18:27:17 特に問題はなさそうだった
ts
import { pool } from "./mod.ts"; import { getPage } from "../scrapbox-userscript-std/rest.ts"; import type { Scrapbox } from "../scrapbox-jp%2Ftypes/userscript.ts"; declare const scrapbox: Scrapbox; let counter = 0; const project = scrapbox.Project.name; await Promise.all([...pool( 6, scrapbox.Project.pages.filter((page) => page.exists), async (page) => { const index = counter++; const result = await getPage(project, page.title); console.log(`[${index} Download /${project}/${page.title}`); }, )]);

mod.ts
export * from "https://raw.githubusercontent.com/takker99/async-lib/0.2.0/mod.ts"; export { delay as sleep } from "https://raw.githubusercontent.com/takker99/async-lib/0.2.0/delay.ts";

#2022-05-31 15:20:27
#2022-05-13 13:08:22
#2022-03-28 09:37:20
#2022-03-27 20:21:34
#2022-03-22 09:20:39
#2022-03-14 07:36:12
#2022-03-10 14:58:35
#2022-03-08 11:36:04