1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00
denoland-deno/std/async/pool_test.ts

21 lines
559 B
TypeScript
Raw Normal View History

2021-01-10 21:59:07 -05:00
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
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 {};