From 431d03624b814078a44b9d4b127656d12cdc8526 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Thu, 18 Jul 2024 23:45:03 +0800 Subject: [PATCH] functional: init --- src/functional.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/functional.ts diff --git a/src/functional.ts b/src/functional.ts new file mode 100644 index 0000000..05c4e57 --- /dev/null +++ b/src/functional.ts @@ -0,0 +1,8 @@ +export const sequence = (fn: ($: T) => Promise) => async (L: T[]) => { + for (const o of L) + await fn(o); +}; + +export const parallel = (fn: ($: T) => Promise) => async (L: T[]) => { + await Promise.all(L.map(fn)); +};