diff options
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 {}; |