blob: 1be4556be7f7d3d80b3aeab25113925f1a33854a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 {};
|