@ts-utilities/core 1.0.11 → 1.0.12

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/index.d.cts CHANGED
@@ -343,6 +343,8 @@ declare function poll<T>(cond: () => Promise<T | null | false | undefined>, {
343
343
  }>): Promise<T>;
344
344
  //#endregion
345
345
  //#region src/functions/promise.d.ts
346
+ type AwaitedTuple<T extends readonly (() => Promise<any>)[] | []> = { -readonly [P in keyof T]: Awaited<ReturnType<T[P]>> };
347
+ type ObjectValues<T extends Record<string, () => Promise<any>>> = { [K in keyof T]: Awaited<ReturnType<T[K]>> };
346
348
  type ConcurrenceResult<T> = {
347
349
  results: T;
348
350
  errors: Error[];
@@ -359,8 +361,8 @@ type ConcurrenceOptions = {
359
361
  throwOnFirstError?: boolean;
360
362
  ignoreErrors?: boolean;
361
363
  };
362
- declare function withConcurrency<T>(tasks: readonly (() => Promise<T>)[], options?: ConcurrenceOptions): Promise<ConcurrenceResult<T[]>>;
363
- declare function withConcurrency<T>(tasks: Record<string, () => Promise<T>>, options?: ConcurrenceOptions): Promise<ConcurrenceResult<Record<string, T>>>;
364
+ declare function withConcurrency<T extends readonly (() => Promise<any>)[] | []>(tasks: T, options?: ConcurrenceOptions): Promise<ConcurrenceResult<AwaitedTuple<T>>>;
365
+ declare function withConcurrency<T extends Record<string, () => Promise<any>>>(tasks: T, options?: ConcurrenceOptions): Promise<ConcurrenceResult<ObjectValues<T>>>;
364
366
  //#endregion
365
367
  //#region src/functions/schedule.d.ts
366
368
  /**
package/dist/index.d.ts CHANGED
@@ -343,6 +343,8 @@ declare function poll<T>(cond: () => Promise<T | null | false | undefined>, {
343
343
  }>): Promise<T>;
344
344
  //#endregion
345
345
  //#region src/functions/promise.d.ts
346
+ type AwaitedTuple<T extends readonly (() => Promise<any>)[] | []> = { -readonly [P in keyof T]: Awaited<ReturnType<T[P]>> };
347
+ type ObjectValues<T extends Record<string, () => Promise<any>>> = { [K in keyof T]: Awaited<ReturnType<T[K]>> };
346
348
  type ConcurrenceResult<T> = {
347
349
  results: T;
348
350
  errors: Error[];
@@ -359,8 +361,8 @@ type ConcurrenceOptions = {
359
361
  throwOnFirstError?: boolean;
360
362
  ignoreErrors?: boolean;
361
363
  };
362
- declare function withConcurrency<T>(tasks: readonly (() => Promise<T>)[], options?: ConcurrenceOptions): Promise<ConcurrenceResult<T[]>>;
363
- declare function withConcurrency<T>(tasks: Record<string, () => Promise<T>>, options?: ConcurrenceOptions): Promise<ConcurrenceResult<Record<string, T>>>;
364
+ declare function withConcurrency<T extends readonly (() => Promise<any>)[] | []>(tasks: T, options?: ConcurrenceOptions): Promise<ConcurrenceResult<AwaitedTuple<T>>>;
365
+ declare function withConcurrency<T extends Record<string, () => Promise<any>>>(tasks: T, options?: ConcurrenceOptions): Promise<ConcurrenceResult<ObjectValues<T>>>;
364
366
  //#endregion
365
367
  //#region src/functions/schedule.d.ts
366
368
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-utilities/core",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "author": "Sohan Emon <sohanemon@outlook.com>",
5
5
  "description": "Core utilities for JavaScript/TypeScript projects",
6
6
  "type": "module",