@ls-stack/utils 3.21.0 → 3.22.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.
@@ -15,7 +15,7 @@
15
15
  ### concurrentCalls()
16
16
 
17
17
  ```ts
18
- function concurrentCalls<R, E>(): ConcurrentCalls<R, E>;
18
+ function concurrentCalls<R>(): ConcurrentCalls<R, Error>;
19
19
  ```
20
20
 
21
21
  Defined in: [packages/utils/src/concurrentCalls.ts:180](https://github.com/lucasols/utils/blob/main/packages/utils/src/concurrentCalls.ts#L180)
@@ -30,22 +30,16 @@ Executes multiple asynchronous calls concurrently and collects the results in a
30
30
 
31
31
  The type of the result value.
32
32
 
33
- ##### E
34
-
35
- `E` *extends* `Error` = `Error`
36
-
37
- The type of the error.
38
-
39
33
  #### Returns
40
34
 
41
- [`ConcurrentCalls`](-internal-.md#concurrentcalls)\<`R`, `E`\>
35
+ [`ConcurrentCalls`](-internal-.md#concurrentcalls)\<`R`, `Error`\>
42
36
 
43
37
  ***
44
38
 
45
39
  ### concurrentCallsWithMetadata()
46
40
 
47
41
  ```ts
48
- function concurrentCallsWithMetadata<M, R, E>(): ConcurrentCallsWithMetadata<M, R, E>;
42
+ function concurrentCallsWithMetadata<M, R>(): ConcurrentCallsWithMetadata<M, R, Error>;
49
43
  ```
50
44
 
51
45
  Defined in: [packages/utils/src/concurrentCalls.ts:373](https://github.com/lucasols/utils/blob/main/packages/utils/src/concurrentCalls.ts#L373)
@@ -66,12 +60,6 @@ The type of the call metadata.
66
60
 
67
61
  The type of the result value.
68
62
 
69
- ##### E
70
-
71
- `E` *extends* `Error` = `Error`
72
-
73
- The type of the error from individual Result objects.
74
-
75
63
  #### Returns
76
64
 
77
- [`ConcurrentCallsWithMetadata`](-internal-.md#concurrentcallswithmetadata)\<`M`, `R`, `E`\>
65
+ [`ConcurrentCallsWithMetadata`](-internal-.md#concurrentcallswithmetadata)\<`M`, `R`, `Error`\>
@@ -23,7 +23,7 @@ function retryOnError<T>(
23
23
  originalMaxRetries): Promise<T>;
24
24
  ```
25
25
 
26
- Defined in: [packages/utils/src/retryOnError.ts:38](https://github.com/lucasols/utils/blob/main/packages/utils/src/retryOnError.ts#L38)
26
+ Defined in: [packages/utils/src/retryOnError.ts:36](https://github.com/lucasols/utils/blob/main/packages/utils/src/retryOnError.ts#L36)
27
27
 
28
28
  Retries a function on error with configurable retry logic.
29
29
 
@@ -57,14 +57,10 @@ Configuration options
57
57
 
58
58
  `number` = `0`
59
59
 
60
- Internal parameter tracking current retry count
61
-
62
60
  ##### originalMaxRetries
63
61
 
64
62
  `number` = `maxRetries`
65
63
 
66
- Internal parameter tracking original max retries for logging
67
-
68
64
  #### Returns
69
65
 
70
66
  `Promise`\<`T`\>
@@ -42,7 +42,7 @@ declare class ConcurrentCalls<R = unknown, E extends Error = Error> {
42
42
  * @template R - The type of the result value.
43
43
  * @template E - The type of the error.
44
44
  */
45
- declare function concurrentCalls<R = unknown, E extends Error = Error>(): ConcurrentCalls<R, E>;
45
+ declare function concurrentCalls<R = unknown>(): ConcurrentCalls<R, Error>;
46
46
  declare class ConcurrentCallsWithMetadata<M extends ValidMetadata, R = unknown, E extends Error = Error> {
47
47
  #private;
48
48
  add(...calls: {
@@ -72,6 +72,6 @@ declare class ConcurrentCallsWithMetadata<M extends ValidMetadata, R = unknown,
72
72
  * @template R - The type of the result value.
73
73
  * @template E - The type of the error from individual Result objects.
74
74
  */
75
- declare function concurrentCallsWithMetadata<M extends ValidMetadata, R = unknown, E extends Error = Error>(): ConcurrentCallsWithMetadata<M, R, E>;
75
+ declare function concurrentCallsWithMetadata<M extends ValidMetadata, R = unknown>(): ConcurrentCallsWithMetadata<M, R, Error>;
76
76
 
77
77
  export { concurrentCalls, concurrentCallsWithMetadata };
@@ -42,7 +42,7 @@ declare class ConcurrentCalls<R = unknown, E extends Error = Error> {
42
42
  * @template R - The type of the result value.
43
43
  * @template E - The type of the error.
44
44
  */
45
- declare function concurrentCalls<R = unknown, E extends Error = Error>(): ConcurrentCalls<R, E>;
45
+ declare function concurrentCalls<R = unknown>(): ConcurrentCalls<R, Error>;
46
46
  declare class ConcurrentCallsWithMetadata<M extends ValidMetadata, R = unknown, E extends Error = Error> {
47
47
  #private;
48
48
  add(...calls: {
@@ -72,6 +72,6 @@ declare class ConcurrentCallsWithMetadata<M extends ValidMetadata, R = unknown,
72
72
  * @template R - The type of the result value.
73
73
  * @template E - The type of the error from individual Result objects.
74
74
  */
75
- declare function concurrentCallsWithMetadata<M extends ValidMetadata, R = unknown, E extends Error = Error>(): ConcurrentCallsWithMetadata<M, R, E>;
75
+ declare function concurrentCallsWithMetadata<M extends ValidMetadata, R = unknown>(): ConcurrentCallsWithMetadata<M, R, Error>;
76
76
 
77
77
  export { concurrentCalls, concurrentCallsWithMetadata };
@@ -54,7 +54,13 @@ async function retryOnError(fn, maxRetries, options = {}, retry = 0, originalMax
54
54
  typeof delayBetweenRetriesMs === "function" ? delayBetweenRetriesMs(retry) : delayBetweenRetriesMs
55
55
  );
56
56
  }
57
- return retryOnError(fn, maxRetries - 1, options, retry + 1, originalMaxRetries);
57
+ return retryOnError(
58
+ fn,
59
+ maxRetries - 1,
60
+ options,
61
+ retry + 1,
62
+ originalMaxRetries
63
+ );
58
64
  } else {
59
65
  throw error;
60
66
  }
@@ -18,8 +18,6 @@ type RetryOptions = {
18
18
  * @param fn - Function to retry that receives context with retry count
19
19
  * @param maxRetries - Maximum number of retries
20
20
  * @param options - Configuration options
21
- * @param retry - Internal parameter tracking current retry count
22
- * @param originalMaxRetries - Internal parameter tracking original max retries for logging
23
21
  * @returns Promise resolving to the function result or rejecting with the final error
24
22
  *
25
23
  * @example
@@ -33,6 +31,7 @@ type RetryOptions = {
33
31
  * );
34
32
  */
35
33
  declare function retryOnError<T>(fn: (ctx: {
34
+ /** Current retry count, (0 for first attempt) */
36
35
  retry: number;
37
36
  }) => Promise<T>, maxRetries: number, options?: RetryOptions, retry?: number, originalMaxRetries?: number): Promise<T>;
38
37
 
@@ -18,8 +18,6 @@ type RetryOptions = {
18
18
  * @param fn - Function to retry that receives context with retry count
19
19
  * @param maxRetries - Maximum number of retries
20
20
  * @param options - Configuration options
21
- * @param retry - Internal parameter tracking current retry count
22
- * @param originalMaxRetries - Internal parameter tracking original max retries for logging
23
21
  * @returns Promise resolving to the function result or rejecting with the final error
24
22
  *
25
23
  * @example
@@ -33,6 +31,7 @@ type RetryOptions = {
33
31
  * );
34
32
  */
35
33
  declare function retryOnError<T>(fn: (ctx: {
34
+ /** Current retry count, (0 for first attempt) */
36
35
  retry: number;
37
36
  }) => Promise<T>, maxRetries: number, options?: RetryOptions, retry?: number, originalMaxRetries?: number): Promise<T>;
38
37
 
@@ -27,7 +27,13 @@ async function retryOnError(fn, maxRetries, options = {}, retry = 0, originalMax
27
27
  typeof delayBetweenRetriesMs === "function" ? delayBetweenRetriesMs(retry) : delayBetweenRetriesMs
28
28
  );
29
29
  }
30
- return retryOnError(fn, maxRetries - 1, options, retry + 1, originalMaxRetries);
30
+ return retryOnError(
31
+ fn,
32
+ maxRetries - 1,
33
+ options,
34
+ retry + 1,
35
+ originalMaxRetries
36
+ );
31
37
  } else {
32
38
  throw error;
33
39
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ls-stack/utils",
3
3
  "description": "Universal TypeScript utilities for browser and Node.js",
4
- "version": "3.21.0",
4
+ "version": "3.22.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "lib",