@altano/tiny-async-pool 3.0.2 → 4.0.0

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/dist/doWork.d.ts CHANGED
@@ -1,21 +1,14 @@
1
- import { type IterableItem } from "./doWorkAndYield.js";
2
- /**
3
- * Process items from `iterable` in batches.
4
- */
5
- export declare function doWork<TIn, TIterable extends Iterable<TIn>>(
6
- /**
7
- * The size of the batch of work, or, how many times `iteratorFn` will be
8
- * called in parallel.
9
- */
10
- concurrentCount: number,
11
- /**
12
- * An iterable that contains the items that should be passed to `iteratorFn`.
13
- */
14
- iterable: TIterable,
15
- /**
16
- * The async callback function that does the work. Will be passed items from
17
- * `iterable`. Promise returned must not resolve to a value, as it will be
18
- * ignored.
19
- */
20
- iteratorFn: (item: IterableItem<TIterable>, Iterable: TIterable) => Promise<void>): Promise<void>;
1
+ import { IterableItem } from "./doWorkAndYield.js";
2
+
3
+ //#region src/doWork.d.ts
4
+ /**
5
+ * Process items from `iterable` in batches.
6
+ */
7
+ /**
8
+ * Process items from `iterable` in batches.
9
+ */
10
+ declare function doWork<TIn, TIterable extends Iterable<TIn>>(concurrentCount: number, iterable: TIterable, iteratorFn: (item: IterableItem<TIterable>, Iterable: TIterable) => Promise<void>): Promise<void>;
11
+
12
+ //#endregion
13
+ export { doWork };
21
14
  //# sourceMappingURL=doWork.d.ts.map
package/dist/doWork.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import { doWorkAndYield } from "./doWorkAndYield.js";
2
+
3
+ //#region src/doWork.ts
4
+ /**
5
+ * Process items from `iterable` in batches.
6
+ */
2
7
  async function doWork(concurrentCount, iterable, iteratorFn) {
3
- for await (const _result of doWorkAndYield(
4
- concurrentCount,
5
- iterable,
6
- iteratorFn
7
- )) {
8
- }
8
+ for await (const _result of doWorkAndYield(concurrentCount, iterable, iteratorFn));
9
9
  }
10
- export {
11
- doWork
12
- };
10
+
11
+ //#endregion
12
+ export { doWork };
13
+ //# sourceMappingURL=doWork.js.map
@@ -1,21 +1,11 @@
1
- export type IterableItem<T> = T extends Iterable<infer R> ? R : never;
2
- /**
3
- * Process items from `iterable` in batches and yield the result of each call to
4
- * `iteratorFn`
5
- */
6
- export declare function doWorkAndYield<TIn, TOut, TIterable extends Iterable<TIn>>(
7
- /**
8
- * The size of the batch of work, or, how many times `iteratorFn` will be
9
- * called in parallel.
10
- */
11
- concurrentCount: number,
12
- /**
13
- * An iterable that contains the items that should be passed to `iteratorFn`.
14
- */
15
- iterable: TIterable,
16
- /**
17
- * The async callback function that does the work. Will be passed items from
18
- * `iterable`.
19
- */
20
- iteratorFn: (item: IterableItem<TIterable>, Iterable: TIterable) => Promise<TOut>): AsyncGenerator<Awaited<TOut>, void, unknown>;
1
+ //#region src/doWorkAndYield.d.ts
2
+ type IterableItem<T> = T extends Iterable<infer R> ? R : never;
3
+ /**
4
+ * Process items from `iterable` in batches and yield the result of each call to
5
+ * `iteratorFn`
6
+ */
7
+ declare function doWorkAndYield<TIn, TOut, TIterable extends Iterable<TIn>>(concurrentCount: number, iterable: TIterable, iteratorFn: (item: IterableItem<TIterable>, Iterable: TIterable) => Promise<TOut>): AsyncGenerator<Awaited<TOut>, void, unknown>;
8
+
9
+ //#endregion
10
+ export { IterableItem, doWorkAndYield };
21
11
  //# sourceMappingURL=doWorkAndYield.d.ts.map
@@ -1,25 +1,24 @@
1
+ //#region src/doWorkAndYield.ts
2
+ /**
3
+ * Process items from `iterable` in batches and yield the result of each call to
4
+ * `iteratorFn`
5
+ */
1
6
  async function* doWorkAndYield(concurrentCount, iterable, iteratorFn) {
2
- const executing = /* @__PURE__ */ new Set();
3
- async function consume() {
4
- const [promise, value] = await Promise.race(executing);
5
- executing.delete(promise);
6
- return value;
7
- }
8
- for (const item of iterable) {
9
- const result = iteratorFn(item, iterable);
10
- const promise = result.then((value) => [
11
- promise,
12
- value
13
- ]);
14
- executing.add(promise);
15
- if (executing.size >= concurrentCount) {
16
- yield await consume();
17
- }
18
- }
19
- while (executing.size) {
20
- yield await consume();
21
- }
7
+ const executing = new Set();
8
+ async function consume() {
9
+ const [promise, value] = await Promise.race(executing);
10
+ executing.delete(promise);
11
+ return value;
12
+ }
13
+ for (const item of iterable) {
14
+ const result = iteratorFn(item, iterable);
15
+ const promise = result.then((value) => [promise, value]);
16
+ executing.add(promise);
17
+ if (executing.size >= concurrentCount) yield await consume();
18
+ }
19
+ while (executing.size) yield await consume();
22
20
  }
23
- export {
24
- doWorkAndYield
25
- };
21
+
22
+ //#endregion
23
+ export { doWorkAndYield };
24
+ //# sourceMappingURL=doWorkAndYield.js.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./doWork.js";
2
- export * from "./doWorkAndYield.js";
3
- //# sourceMappingURL=index.d.ts.map
1
+ import { IterableItem, doWorkAndYield } from "./doWorkAndYield.js";
2
+ import { doWork } from "./doWork.js";
3
+ export { IterableItem, doWork, doWorkAndYield };
package/dist/index.js CHANGED
@@ -1,2 +1,4 @@
1
- export * from "./doWork.js";
2
- export * from "./doWorkAndYield.js";
1
+ import { doWorkAndYield } from "./doWorkAndYield.js";
2
+ import { doWork } from "./doWork.js";
3
+
4
+ export { doWork, doWorkAndYield };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altano/tiny-async-pool",
3
- "version": "3.0.2",
3
+ "version": "4.0.0",
4
4
  "description": "Run multiple promise-returning & async functions with limited concurrency using native ES9",
5
5
  "keywords": [
6
6
  "race",
@@ -36,26 +36,26 @@
36
36
  "dist/**/*.d.ts"
37
37
  ],
38
38
  "devDependencies": {
39
- "@arethetypeswrong/cli": "^0.15.4",
39
+ "@arethetypeswrong/cli": "^0.17.4",
40
40
  "@types/node": "^22.13.10",
41
- "@vitest/coverage-v8": "^3.0.9",
41
+ "@vitest/coverage-v8": "^3.1.4",
42
42
  "depcheck": "^1.4.7",
43
- "eslint": "^9.22.0",
44
- "prettier": "^3.3.3",
43
+ "eslint": "^9.23.0",
44
+ "prettier": "^3.5.3",
45
+ "tsdown": "^0.12.3",
45
46
  "typescript": "^5.8.2",
46
- "vite": "^6.2.3",
47
- "vitest": "^3.0.9",
48
- "@altano/build-config": "0.0.0",
49
- "@altano/testing": "0.0.0",
50
- "@altano/tsconfig": "0.0.0"
47
+ "vite": "^6.2.6",
48
+ "vitest": "^3.1.4",
49
+ "@altano/build-config": "0.0.1",
50
+ "@altano/testing": "0.0.1",
51
+ "@altano/tsconfig": "0.0.1"
51
52
  },
52
53
  "publishConfig": {
53
54
  "access": "public"
54
55
  },
55
56
  "scripts": {
56
- "build": "tsup --config build-config/tsup.config.node.ts",
57
- "build:types": "tsc --project tsconfig.declarations.json",
58
- "check:exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
57
+ "build": "tsdown --config ../build-config/tsdown.config.node.ts",
58
+ "check:exports": "attw --pack . --profile esm-only --quiet",
59
59
  "check:types:src": "tsc --noEmit",
60
60
  "check:types:test": "tsc --noEmit --project ./tests/tsconfig.json",
61
61
  "check:unused-dependencies": "depcheck",