summaryrefslogtreecommitdiff
path: root/std/async/pool_test.ts
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2020-07-29 02:44:34 +0200
committerGitHub <noreply@github.com>2020-07-29 02:44:34 +0200
commit1b60840f286bc0203a3bd2900f67557a8ff2c3f6 (patch)
treedc11c98ca3eae7ee35697dc556f50acab7802b2d /std/async/pool_test.ts
parentc6917133942c791480cd2aec7297b2a2ee623059 (diff)
feat(std/async): add pooledMap utility (#6898)
Diffstat (limited to 'std/async/pool_test.ts')
-rw-r--r--std/async/pool_test.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/std/async/pool_test.ts b/std/async/pool_test.ts
new file mode 100644
index 000000000..1be4556be
--- /dev/null
+++ b/std/async/pool_test.ts
@@ -0,0 +1,19 @@
+import { pooledMap } from "./pool.ts";
+import { assert } from "../testing/asserts.ts";
+
+Deno.test("[async] pooledMap", async function (): Promise<void> {
+ const start = new Date();
+ const results = pooledMap(
+ 2,
+ [1, 2, 3],
+ (i) => new Promise((r) => setTimeout(() => r(i), 1000)),
+ );
+ for await (const value of results) {
+ console.log(value);
+ }
+ const diff = new Date().getTime() - start.getTime();
+ assert(diff >= 2000);
+ assert(diff < 3000);
+});
+
+export {};