overtake 1.0.5 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -29
- package/build/cli.cjs +43 -33
- package/build/cli.cjs.map +1 -1
- package/build/cli.js +42 -32
- package/build/cli.js.map +1 -1
- package/build/executor.cjs +6 -3
- package/build/executor.cjs.map +1 -1
- package/build/executor.d.ts +3 -2
- package/build/executor.js +6 -3
- package/build/executor.js.map +1 -1
- package/build/gc-watcher.cjs +31 -0
- package/build/gc-watcher.cjs.map +1 -0
- package/build/gc-watcher.d.ts +9 -0
- package/build/gc-watcher.js +21 -0
- package/build/gc-watcher.js.map +1 -0
- package/build/index.cjs +9 -1
- package/build/index.cjs.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +9 -1
- package/build/index.js.map +1 -1
- package/build/runner.cjs +229 -24
- package/build/runner.cjs.map +1 -1
- package/build/runner.d.ts +1 -1
- package/build/runner.js +229 -24
- package/build/runner.js.map +1 -1
- package/build/types.cjs.map +1 -1
- package/build/types.d.ts +4 -0
- package/build/types.js.map +1 -1
- package/build/utils.cjs +21 -0
- package/build/utils.cjs.map +1 -1
- package/build/utils.d.ts +1 -0
- package/build/utils.js +18 -0
- package/build/utils.js.map +1 -1
- package/build/worker.cjs +104 -14
- package/build/worker.cjs.map +1 -1
- package/build/worker.d.ts +1 -1
- package/build/worker.js +63 -8
- package/build/worker.js.map +1 -1
- package/examples/accuracy.ts +54 -0
- package/examples/custom-reports.ts +0 -1
- package/examples/imports.ts +3 -7
- package/examples/quick-start.ts +2 -0
- package/package.json +11 -10
- package/src/cli.ts +44 -31
- package/src/executor.ts +8 -2
- package/src/gc-watcher.ts +23 -0
- package/src/index.ts +11 -0
- package/src/runner.ts +269 -23
- package/src/types.ts +4 -0
- package/src/utils.ts +20 -0
- package/src/worker.ts +72 -9
- package/build/queue.cjs +0 -48
- package/build/queue.cjs.map +0 -1
- package/build/queue.d.ts +0 -3
- package/build/queue.js +0 -38
- package/build/queue.js.map +0 -1
- package/src/queue.ts +0 -42
package/src/queue.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export const createQueue = <T>(worker: (task: T) => Promise<void>, concurency: number = 1) => {
|
|
2
|
-
const queue = new Set<T>();
|
|
3
|
-
const processing = new Map<number, Promise<void>>();
|
|
4
|
-
const iterator = queue[Symbol.iterator]();
|
|
5
|
-
|
|
6
|
-
let next: () => void;
|
|
7
|
-
let counter = 0;
|
|
8
|
-
|
|
9
|
-
queueMicrotask(async () => {
|
|
10
|
-
while (true) {
|
|
11
|
-
if (concurency > 0 && processing.size === concurency) {
|
|
12
|
-
await Promise.race(processing.values());
|
|
13
|
-
}
|
|
14
|
-
if (queue.size === 0) {
|
|
15
|
-
const { promise, resolve } = Promise.withResolvers<void>();
|
|
16
|
-
next = resolve;
|
|
17
|
-
await promise;
|
|
18
|
-
}
|
|
19
|
-
const result = iterator.next();
|
|
20
|
-
if (result.done) {
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
const id = counter++;
|
|
24
|
-
const task = Promise.resolve(worker(result.value))
|
|
25
|
-
.catch(() => {})
|
|
26
|
-
.finally(() => {
|
|
27
|
-
processing.delete(id);
|
|
28
|
-
});
|
|
29
|
-
processing.set(id, task);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
push: async (input: T) => {
|
|
35
|
-
queue.add(input);
|
|
36
|
-
|
|
37
|
-
if (queue.size === 0) {
|
|
38
|
-
next?.();
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
};
|