diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2020-07-29 02:44:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-29 02:44:34 +0200 |
commit | 1b60840f286bc0203a3bd2900f67557a8ff2c3f6 (patch) | |
tree | dc11c98ca3eae7ee35697dc556f50acab7802b2d /std/async/pool_test.ts | |
parent | c6917133942c791480cd2aec7297b2a2ee623059 (diff) |
feat(std/async): add pooledMap utility (#6898)
Diffstat (limited to 'std/async/pool_test.ts')
-rw-r--r-- | std/async/pool_test.ts | 19 |
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 {}; |