From 99f8d71498316b6ef76a4f6d252a1b6bb309a661 Mon Sep 17 00:00:00 2001 From: Okiki Date: Sun, 1 Sep 2024 08:47:06 +0000 Subject: [PATCH] chore: ... Signed-off-by: Okiki --- _repl.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/_repl.ts b/_repl.ts index 03c26cf..6baf5fe 100644 --- a/_repl.ts +++ b/_repl.ts @@ -49,6 +49,21 @@ await Promise.all([ console.log("Future", { e }); } })(), + (async () => { + try { + const iterator = Future.withConcurrencyLimit([ + Future.from(gen), + Future.inBackground(Future.from(gen)), + ], 2); + // setTimeout(() => iterator.cancel(), 1000); + + for await (const value of iterator) { + console.log("Concurrent Value:", value); + } + } catch (e) { + console.log("Future", { e }); + } + })(), ]); console.log("Done!!!"); -- 2.51.2