@handy-common-utils/promise-utils 1.7.0 → 1.7.2

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.
@@ -25,11 +25,12 @@ export declare const EXPONENTIAL_SEQUENCE: number[];
25
25
  /**
26
26
  * The state of a Promise can only be one of: Pending, Fulfilled, and Rejected.
27
27
  */
28
- export declare enum PromiseState {
29
- Pending = "Pending",
30
- Fulfilled = "Fulfilled",
31
- Rejected = "Rejected"
32
- }
28
+ export declare const PromiseState: {
29
+ readonly Pending: "Pending";
30
+ readonly Fulfilled: "Fulfilled";
31
+ readonly Rejected: "Rejected";
32
+ };
33
+ export type PromiseStateType = keyof typeof PromiseState;
33
34
  export declare abstract class PromiseUtils {
34
35
  /**
35
36
  * Executes an operation repeatedly and collects all the results.
@@ -86,7 +87,7 @@ export declare abstract class PromiseUtils {
86
87
  * Executes multiple jobs/operations with a specified level of concurrency.
87
88
  *
88
89
  * Unlike `inParallel(...)`, this function may throw or reject an error when a job/operation fails.
89
- * When an error is re-thrown, remaining operations will not be executed.
90
+ * When an error is thrown, the function rejects immediately, and no further operations will be started.
90
91
  * If you want all the operations to always be executed, use {@link PromiseUtils.inParallel} instead.
91
92
  *
92
93
  * @example
@@ -116,7 +117,7 @@ export declare abstract class PromiseUtils {
116
117
  * This function only resolves when all jobs/operations are settled (either resolved or rejected).
117
118
  *
118
119
  * If `options.abortOnError` is set to true, this function throws (or rejects with) an error immediately when any job/operation fails.
119
- * In this mode, some jobs/operations may not be executed if one fails.
120
+ * In this mode, no further operations will be started after a failure occurs.
120
121
  *
121
122
  * @example
122
123
  * // Capture errors in the returned array
@@ -255,7 +256,7 @@ export declare abstract class PromiseUtils {
255
256
  * @param p The Promise whose state is to be determined.
256
257
  * @returns A Promise that resolves immediately with the state of the input Promise.
257
258
  */
258
- static promiseState(p: Promise<any>): Promise<PromiseState>;
259
+ static promiseState(p: Promise<any>): Promise<PromiseStateType>;
259
260
  private static synchronizationLocks;
260
261
  /**
261
262
  * Provides mutual exclusion similar to `synchronized` in Java.
@@ -269,14 +270,14 @@ export declare abstract class PromiseUtils {
269
270
  * @param operation The function that performs the computation and returns a Promise.
270
271
  * @returns The result of the operation function.
271
272
  */
272
- static synchronized<T>(lock: any, operation: (previousState: PromiseState | undefined, previousSettledState: PromiseState | undefined, previousResult: any) => Promise<T>): Promise<T>;
273
+ static synchronized<T>(lock: any, operation: (previousState: PromiseStateType | undefined, previousSettledState: PromiseStateType | undefined, previousResult: any) => Promise<T>): Promise<T>;
273
274
  /**
274
275
  * This is just another spelling of {@link PromiseUtils.synchronized}.
275
276
  * @param lock The object (such as a string, a number, or `this` in a class) used to identify the lock.
276
277
  * @param operation The function that performs the computation and returns a Promise.
277
278
  * @returns The result of the operation function.
278
279
  */
279
- static synchronised<T>(lock: any, operation: (previousState: PromiseState | undefined, previousSettledState: PromiseState | undefined, previousResult: any) => Promise<T>): Promise<T>;
280
+ static synchronised<T>(lock: any, operation: (previousState: PromiseStateType | undefined, previousSettledState: PromiseStateType | undefined, previousResult: any) => Promise<T>): Promise<T>;
280
281
  /**
281
282
  * Runs an operation periodically with configurable intervals and stopping conditions.
282
283
  *
@@ -290,24 +291,27 @@ export declare abstract class PromiseUtils {
290
291
  * - `maxExecutions` stop after N runs (inclusive).
291
292
  * - `maxDurationMs` stop after elapsed ms since the first scheduled start.
292
293
  * - `schedule` controls how the interval is measured:
293
- * - `'delayAfterEnd'`: wait the interval after the previous operation completes
294
+ * - `'delayAfterEnd'`: wait the interval after the previous operation completes
294
295
  * before scheduling the next one (equivalent to a fixed delay between ends).
295
296
  * - `'delayBetweenStarts'`: keep start times on a regular schedule (interval measured
296
297
  * between the starts of successive operations).
297
- * The default schedule is `'delayBetweenStarts'`.
298
+ * The default schedule is `'delayBetweenStarts'`.
299
+ *
300
+ * Returns an object with `stop()` to cancel further executions and `done` which
301
+ * resolves when the periodic runner stops. If the provided `operation` throws or
302
+ * rejects, the `done` promise will reject with that error so callers can handle it.
298
303
  *
299
- * Returns an object with `stop()` to cancel further executions and `done` which
300
- * resolves when the periodic runner stops. If the provided `operation` throws or
301
- * rejects, the `done` promise will reject with that error so callers can handle it.
302
- *
303
- * Note: The first invocation of `operation` is scheduled after the first interval
304
- * elapses (i.e. this function does NOT call `operation` immediately). If you need
305
- * an immediate run, invoke `operation(1)` yourself before calling `runPeriodically`.
304
+ * Note: The first invocation of `operation` is scheduled after the first interval
305
+ * elapses (i.e. this function does NOT call `operation` immediately). If you need
306
+ * an immediate run, invoke `operation(1)` yourself before calling `runPeriodically`.
306
307
  *
307
308
  * @template T The operation return type (ignored by the runner; used for typing).
308
309
  * @param operation Function to run each iteration. Receives the iteration index (1-based).
309
310
  * @param interval Number | number[] | ((iteration: number) => number|undefined) defining waits.
310
311
  * @param options Optional configuration.
312
+ * @param options.maxExecutions Stop after N executions.
313
+ * @param options.maxDurationMs Stop after N milliseconds.
314
+ * @param options.schedule How to measure intervals: `'delayAfterEnd'` or `'delayBetweenStarts'`.
311
315
  * @returns An object containing `stop()` to cancel further executions and `done` Promise
312
316
  * which resolves when the periodic runner stops (or rejects if the operation errors).
313
317
  */
@@ -360,7 +364,7 @@ export declare const withConcurrency: typeof PromiseUtils.withConcurrency;
360
364
  * This function only resolves when all jobs/operations are settled (either resolved or rejected).
361
365
  *
362
366
  * If options.abortOnError is set to true, this function throws (or rejects with) an error immediately when any job/operation fails.
363
- * In this mode, some jobs/operations may not be executed if one fails.
367
+ * In this mode, no further operations will be started after a failure occurs.
364
368
  *
365
369
  * @param parallelism The number of jobs/operations to run concurrently.
366
370
  * @param jobs The job data to be processed. This function can safely handle an infinite or unknown number of elements.
@@ -495,10 +499,39 @@ export declare const promiseState: typeof PromiseUtils.promiseState;
495
499
  /**
496
500
  * Runs an operation periodically with configurable intervals and stopping conditions.
497
501
  *
498
- * @param operation The operation to run periodically.
499
- * @param interval The interval (ms), array of intervals, or function returning interval per iteration.
500
- * @param options Options for maxExecutions, maxDurationMs, and schedule type.
501
- * @returns An object with stop() and done Promise which resolves when the periodic runner stops (or rejects if the operation errors).
502
+ * - `interval` may be a single number (ms), an array of numbers, or a function
503
+ * that receives the iteration number (starting at 1) and returns the next
504
+ * interval in milliseconds or `undefined` to stop.
505
+ * - If the interval array runs out of elements or the function returns `undefined`
506
+ * (or a negative value), no further invocations will be scheduled.
507
+ *
508
+ * Options:
509
+ * - `maxExecutions` stop after N runs (inclusive).
510
+ * - `maxDurationMs` stop after elapsed ms since the first scheduled start.
511
+ * - `schedule` controls how the interval is measured:
512
+ * - `'delayAfterEnd'`: wait the interval after the previous operation completes
513
+ * before scheduling the next one (equivalent to a fixed delay between ends).
514
+ * - `'delayBetweenStarts'`: keep start times on a regular schedule (interval measured
515
+ * between the starts of successive operations).
516
+ * The default schedule is `'delayBetweenStarts'`.
517
+ *
518
+ * Returns an object with `stop()` to cancel further executions and `done` which
519
+ * resolves when the periodic runner stops. If the provided `operation` throws or
520
+ * rejects, the `done` promise will reject with that error so callers can handle it.
521
+ *
522
+ * Note: The first invocation of `operation` is scheduled after the first interval
523
+ * elapses (i.e. this function does NOT call `operation` immediately). If you need
524
+ * an immediate run, invoke `operation(1)` yourself before calling `runPeriodically`.
525
+ *
526
+ * @template T The operation return type (ignored by the runner; used for typing).
527
+ * @param operation Function to run each iteration. Receives the iteration index (1-based).
528
+ * @param interval Number | number[] | ((iteration: number) => number|undefined) defining waits.
529
+ * @param options Optional configuration.
530
+ * @param options.maxExecutions Stop after N executions.
531
+ * @param options.maxDurationMs Stop after N milliseconds.
532
+ * @param options.schedule How to measure intervals: `'delayAfterEnd'` or `'delayBetweenStarts'`.
533
+ * @returns An object containing `stop()` to cancel further executions and `done` Promise
534
+ * which resolves when the periodic runner stops (or rejects if the operation errors).
502
535
  */
503
536
  export declare const runPeriodically: typeof PromiseUtils.runPeriodically;
504
537
  //# sourceMappingURL=promise-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promise-utils.d.ts","sourceRoot":"","sources":["../src/promise-utils.ts"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AC;QAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE;CAkE7C;AAGD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,4BAAsB,CAAC;AAG1C;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,+BAAyB,CAAC;AAGhD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,qCAA+B,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,UAAU,gCAA0B,CAAC;AAGlD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,oCAA8B,CAAC;AAG1D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,mCAA6B,CAAC;AAGxD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,+CAAyC,CAAC;AAGhF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,8CAAwC,CAAC;AAG9E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,oCAA8B,CAAC;AAG1D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,mCAA6B,CAAC;AAGxD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,kCAA4B,CAAC;AAGtD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,kCAA4B,CAAC;AAGtD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,kCAA4B,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,eAAe,qCAA+B,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runPeriodically = exports.promiseState = exports.synchronised = exports.synchronized = exports.timeoutReject = exports.timeoutResolve = exports.cancellableDelayedReject = exports.cancellableDelayedResolve = exports.delayedReject = exports.delayedResolve = exports.inParallel = exports.withConcurrency = exports.withRetry = exports.repeat = exports.PromiseUtils = exports.PromiseState = exports.EXPONENTIAL_SEQUENCE = exports.FIBONACCI_SEQUENCE = void 0;
4
+ /* c8 ignore next */
4
5
  /**
5
6
  * Array of 25 Fibonacci numbers starting from 1 up to 317811.
6
7
  * It can be used to form your own backoff interval array.
@@ -13,6 +14,7 @@ exports.runPeriodically = exports.promiseState = exports.synchronised = exports.
13
14
  * PromiseUtils.withRetry(() => doSomething(), FIBONACCI_SEQUENCE.slice(0, 5).map(n => 1000 * n * (1 + (Math.random() - 0.5) / 5)), err => err.statusCode === 429);
14
15
  */
15
16
  exports.FIBONACCI_SEQUENCE = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811];
17
+ /* c8 ignore next */
16
18
  /**
17
19
  * Array of 25 exponential numbers starting from 1 up to 33554432.
18
20
  * It can be used to form your own backoff interval array.
@@ -28,12 +30,11 @@ exports.EXPONENTIAL_SEQUENCE = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
28
30
  /**
29
31
  * The state of a Promise can only be one of: Pending, Fulfilled, and Rejected.
30
32
  */
31
- var PromiseState;
32
- (function (PromiseState) {
33
- PromiseState["Pending"] = "Pending";
34
- PromiseState["Fulfilled"] = "Fulfilled";
35
- PromiseState["Rejected"] = "Rejected";
36
- })(PromiseState || (exports.PromiseState = PromiseState = {}));
33
+ exports.PromiseState = {
34
+ Pending: 'Pending',
35
+ Fulfilled: 'Fulfilled',
36
+ Rejected: 'Rejected',
37
+ };
37
38
  class PromiseUtils {
38
39
  /**
39
40
  * Executes an operation repeatedly and collects all the results.
@@ -120,7 +121,7 @@ class PromiseUtils {
120
121
  * Executes multiple jobs/operations with a specified level of concurrency.
121
122
  *
122
123
  * Unlike `inParallel(...)`, this function may throw or reject an error when a job/operation fails.
123
- * When an error is re-thrown, remaining operations will not be executed.
124
+ * When an error is thrown, the function rejects immediately, and no further operations will be started.
124
125
  * If you want all the operations to always be executed, use {@link PromiseUtils.inParallel} instead.
125
126
  *
126
127
  * @example
@@ -152,7 +153,7 @@ class PromiseUtils {
152
153
  * This function only resolves when all jobs/operations are settled (either resolved or rejected).
153
154
  *
154
155
  * If `options.abortOnError` is set to true, this function throws (or rejects with) an error immediately when any job/operation fails.
155
- * In this mode, some jobs/operations may not be executed if one fails.
156
+ * In this mode, no further operations will be started after a failure occurs.
156
157
  *
157
158
  * @example
158
159
  * // Capture errors in the returned array
@@ -188,10 +189,14 @@ class PromiseUtils {
188
189
  }
189
190
  const jobResults = new Array();
190
191
  let index = 0;
192
+ let aborted = false;
191
193
  const iterator = jobs[Symbol.iterator]();
192
- const promises = Array.from({ length: Math.floor(parallelism) }).fill(0).map(async (_) => {
194
+ const promises = Array.from({ length: Math.floor(parallelism) }, (async (_) => {
193
195
  let iteratorResult;
194
196
  while (true) {
197
+ if (aborted) {
198
+ break;
199
+ }
195
200
  iteratorResult = iterator.next();
196
201
  if (iteratorResult.done) {
197
202
  break;
@@ -199,9 +204,15 @@ class PromiseUtils {
199
204
  const job = iteratorResult.value;
200
205
  const jobIndex = index++;
201
206
  const jobResultPromise = operation(job, jobIndex);
202
- jobResults[jobIndex] = (options === null || options === void 0 ? void 0 : options.abortOnError) ? await jobResultPromise : await jobResultPromise.catch(error => error);
207
+ try {
208
+ jobResults[jobIndex] = (options === null || options === void 0 ? void 0 : options.abortOnError) ? await jobResultPromise : await jobResultPromise.catch(error => error);
209
+ }
210
+ catch (error) {
211
+ aborted = true;
212
+ throw error;
213
+ }
203
214
  }
204
- });
215
+ }));
205
216
  await Promise.all(promises);
206
217
  return jobResults;
207
218
  }
@@ -335,12 +346,14 @@ class PromiseUtils {
335
346
  */
336
347
  static timeoutResolve(operation, ms, result) {
337
348
  const promise = typeof operation === 'function' ? operation() : operation;
349
+ const { stop, promise: timeoutPromise } = PromiseUtils.cancellableDelayedResolve(ms, () => PromiseUtils.promiseState(promise)
350
+ .then(state => state === exports.PromiseState.Pending ?
351
+ (typeof result === 'function' ? result() : result) :
352
+ {}));
353
+ promise.then(() => stop(), () => stop());
338
354
  return Promise.race([
339
355
  promise,
340
- PromiseUtils.delayedResolve(ms, () => PromiseUtils.promiseState(promise)
341
- .then(state => state === PromiseState.Pending ?
342
- (typeof result === 'function' ? result() : result) :
343
- {})),
356
+ timeoutPromise,
344
357
  ]);
345
358
  }
346
359
  /**
@@ -357,12 +370,14 @@ class PromiseUtils {
357
370
  */
358
371
  static timeoutReject(operation, ms, rejectReason) {
359
372
  const promise = typeof operation === 'function' ? operation() : operation;
373
+ const { stop, promise: timeoutPromise } = PromiseUtils.cancellableDelayedReject(ms, () => PromiseUtils.promiseState(promise)
374
+ .then(state => state === exports.PromiseState.Pending ?
375
+ (typeof rejectReason === 'function' ? rejectReason() : rejectReason) :
376
+ {}));
377
+ promise.then(() => stop(), () => stop());
360
378
  return Promise.race([
361
379
  promise,
362
- PromiseUtils.delayedReject(ms, () => PromiseUtils.promiseState(promise)
363
- .then(state => state === PromiseState.Pending ?
364
- (typeof rejectReason === 'function' ? rejectReason() : rejectReason) :
365
- {})),
380
+ timeoutPromise,
366
381
  ]);
367
382
  }
368
383
  /**
@@ -375,7 +390,7 @@ class PromiseUtils {
375
390
  static promiseState(p) {
376
391
  const t = {};
377
392
  return Promise.race([p, t])
378
- .then(v => (v === t) ? PromiseState.Pending : PromiseState.Fulfilled, () => PromiseState.Rejected);
393
+ .then(v => (v === t) ? exports.PromiseState.Pending : exports.PromiseState.Fulfilled, () => exports.PromiseState.Rejected);
379
394
  }
380
395
  /**
381
396
  * Provides mutual exclusion similar to `synchronized` in Java.
@@ -397,8 +412,8 @@ class PromiseUtils {
397
412
  previousState = await PromiseUtils.promiseState(previousResultPromise);
398
413
  }
399
414
  switch (previousState) {
400
- case PromiseState.Pending: { // concurrency
401
- resultPromise = previousResultPromise.then(result => operation(PromiseState.Pending, PromiseState.Fulfilled, result), error => operation(PromiseState.Pending, PromiseState.Rejected, error));
415
+ case exports.PromiseState.Pending: { // concurrency
416
+ resultPromise = previousResultPromise.then(result => operation(exports.PromiseState.Pending, exports.PromiseState.Fulfilled, result), error => operation(exports.PromiseState.Pending, exports.PromiseState.Rejected, error));
402
417
  break;
403
418
  }
404
419
  case undefined: { // no concurrency and no history
@@ -436,24 +451,27 @@ class PromiseUtils {
436
451
  * - `maxExecutions` stop after N runs (inclusive).
437
452
  * - `maxDurationMs` stop after elapsed ms since the first scheduled start.
438
453
  * - `schedule` controls how the interval is measured:
439
- * - `'delayAfterEnd'`: wait the interval after the previous operation completes
454
+ * - `'delayAfterEnd'`: wait the interval after the previous operation completes
440
455
  * before scheduling the next one (equivalent to a fixed delay between ends).
441
456
  * - `'delayBetweenStarts'`: keep start times on a regular schedule (interval measured
442
457
  * between the starts of successive operations).
443
- * The default schedule is `'delayBetweenStarts'`.
458
+ * The default schedule is `'delayBetweenStarts'`.
444
459
  *
445
- * Returns an object with `stop()` to cancel further executions and `done` which
446
- * resolves when the periodic runner stops. If the provided `operation` throws or
447
- * rejects, the `done` promise will reject with that error so callers can handle it.
448
- *
449
- * Note: The first invocation of `operation` is scheduled after the first interval
450
- * elapses (i.e. this function does NOT call `operation` immediately). If you need
451
- * an immediate run, invoke `operation(1)` yourself before calling `runPeriodically`.
460
+ * Returns an object with `stop()` to cancel further executions and `done` which
461
+ * resolves when the periodic runner stops. If the provided `operation` throws or
462
+ * rejects, the `done` promise will reject with that error so callers can handle it.
463
+ *
464
+ * Note: The first invocation of `operation` is scheduled after the first interval
465
+ * elapses (i.e. this function does NOT call `operation` immediately). If you need
466
+ * an immediate run, invoke `operation(1)` yourself before calling `runPeriodically`.
452
467
  *
453
468
  * @template T The operation return type (ignored by the runner; used for typing).
454
469
  * @param operation Function to run each iteration. Receives the iteration index (1-based).
455
470
  * @param interval Number | number[] | ((iteration: number) => number|undefined) defining waits.
456
471
  * @param options Optional configuration.
472
+ * @param options.maxExecutions Stop after N executions.
473
+ * @param options.maxDurationMs Stop after N milliseconds.
474
+ * @param options.schedule How to measure intervals: `'delayAfterEnd'` or `'delayBetweenStarts'`.
457
475
  * @returns An object containing `stop()` to cancel further executions and `done` Promise
458
476
  * which resolves when the periodic runner stops (or rejects if the operation errors).
459
477
  */
@@ -521,6 +539,7 @@ class PromiseUtils {
521
539
  }
522
540
  exports.PromiseUtils = PromiseUtils;
523
541
  PromiseUtils.synchronizationLocks = new Map();
542
+ /* c8 ignore next */
524
543
  /**
525
544
  * Executes an operation repeatedly and collects all the results.
526
545
  * This function is very useful for many scenarios, such like client-side pagination.
@@ -533,6 +552,7 @@ PromiseUtils.synchronizationLocks = new Map();
533
552
  * @returns A promise that resolves to a collection of all the results returned by the operation function.
534
553
  */
535
554
  exports.repeat = PromiseUtils.repeat;
555
+ /* c8 ignore next */
536
556
  /**
537
557
  * Repeatedly performs an operation until a specified criteria is met.
538
558
  *
@@ -542,6 +562,7 @@ exports.repeat = PromiseUtils.repeat;
542
562
  * @returns A promise of the operation result, potentially with retries applied.
543
563
  */
544
564
  exports.withRetry = PromiseUtils.withRetry;
565
+ /* c8 ignore next */
545
566
  /**
546
567
  * Executes multiple jobs/operations with a specified level of concurrency.
547
568
  *
@@ -552,6 +573,7 @@ exports.withRetry = PromiseUtils.withRetry;
552
573
  * The results in the returned array are in the same order as the corresponding elements in the jobs array.
553
574
  */
554
575
  exports.withConcurrency = PromiseUtils.withConcurrency;
576
+ /* c8 ignore next */
555
577
  /**
556
578
  * Executes multiple jobs/operations in parallel. By default, all operations are executed regardless of any failures.
557
579
  * In most cases, using withConcurrency might be more convenient.
@@ -561,7 +583,7 @@ exports.withConcurrency = PromiseUtils.withConcurrency;
561
583
  * This function only resolves when all jobs/operations are settled (either resolved or rejected).
562
584
  *
563
585
  * If options.abortOnError is set to true, this function throws (or rejects with) an error immediately when any job/operation fails.
564
- * In this mode, some jobs/operations may not be executed if one fails.
586
+ * In this mode, no further operations will be started after a failure occurs.
565
587
  *
566
588
  * @param parallelism The number of jobs/operations to run concurrently.
567
589
  * @param jobs The job data to be processed. This function can safely handle an infinite or unknown number of elements.
@@ -573,6 +595,7 @@ exports.withConcurrency = PromiseUtils.withConcurrency;
573
595
  * The results or errors in the returned array are in the same order as the corresponding elements in the jobs array.
574
596
  */
575
597
  exports.inParallel = PromiseUtils.inParallel;
598
+ /* c8 ignore next */
576
599
  /**
577
600
  * Creates a Promise that resolves after a specified number of milliseconds.
578
601
  *
@@ -589,6 +612,7 @@ exports.inParallel = PromiseUtils.inParallel;
589
612
  * @returns A Promise that resolves with the specified result after the specified delay.
590
613
  */
591
614
  exports.delayedResolve = PromiseUtils.delayedResolve;
615
+ /* c8 ignore next */
592
616
  /**
593
617
  * Creates a Promise that rejects after a specified number of milliseconds.
594
618
  *
@@ -606,6 +630,7 @@ exports.delayedResolve = PromiseUtils.delayedResolve;
606
630
  * @returns A Promise that rejects with the specified reason after the specified delay.
607
631
  */
608
632
  exports.delayedReject = PromiseUtils.delayedReject;
633
+ /* c8 ignore next */
609
634
  /**
610
635
  * Creates a cancellable timer that will resolve after a specified number of milliseconds.
611
636
  *
@@ -622,6 +647,7 @@ exports.delayedReject = PromiseUtils.delayedReject;
622
647
  * @returns An object with stop() and promise.
623
648
  */
624
649
  exports.cancellableDelayedResolve = PromiseUtils.cancellableDelayedResolve;
650
+ /* c8 ignore next */
625
651
  /**
626
652
  * Creates a cancellable timer that will reject after a specified number of milliseconds.
627
653
  *
@@ -638,6 +664,7 @@ exports.cancellableDelayedResolve = PromiseUtils.cancellableDelayedResolve;
638
664
  * @returns An object with stop() and promise.
639
665
  */
640
666
  exports.cancellableDelayedReject = PromiseUtils.cancellableDelayedReject;
667
+ /* c8 ignore next */
641
668
  /**
642
669
  * Applies a timeout to a Promise or a function that returns a Promise.
643
670
  * If the timeout occurs, the returned Promise resolves to the specified result.
@@ -652,6 +679,7 @@ exports.cancellableDelayedReject = PromiseUtils.cancellableDelayedReject;
652
679
  * @returns A new Promise that resolves to the specified result if the timeout occurs.
653
680
  */
654
681
  exports.timeoutResolve = PromiseUtils.timeoutResolve;
682
+ /* c8 ignore next */
655
683
  /**
656
684
  * Applies a timeout to a Promise or a function that returns a Promise.
657
685
  * If the timeout occurs, the returned Promise rejects with the specified reason.
@@ -665,6 +693,7 @@ exports.timeoutResolve = PromiseUtils.timeoutResolve;
665
693
  * @returns A new Promise that rejects with the specified reason if the timeout occurs.
666
694
  */
667
695
  exports.timeoutReject = PromiseUtils.timeoutReject;
696
+ /* c8 ignore next */
668
697
  /**
669
698
  * Provides mutual exclusion similar to synchronized in Java.
670
699
  * Ensures no concurrent execution of any operation function associated with the same lock.
@@ -678,6 +707,7 @@ exports.timeoutReject = PromiseUtils.timeoutReject;
678
707
  * @returns The result of the operation function.
679
708
  */
680
709
  exports.synchronized = PromiseUtils.synchronized;
710
+ /* c8 ignore next */
681
711
  /**
682
712
  * This is just another spelling of synchronized.
683
713
  * @param lock The object (such as a string, a number, or this in a class) used to identify the lock.
@@ -685,6 +715,7 @@ exports.synchronized = PromiseUtils.synchronized;
685
715
  * @returns The result of the operation function.
686
716
  */
687
717
  exports.synchronised = PromiseUtils.synchronised;
718
+ /* c8 ignore next */
688
719
  /**
689
720
  * Retrieves the state of the specified Promise.
690
721
  * Note: The returned value is a Promise that resolves immediately.
@@ -693,12 +724,43 @@ exports.synchronised = PromiseUtils.synchronised;
693
724
  * @returns A Promise that resolves immediately with the state of the input Promise.
694
725
  */
695
726
  exports.promiseState = PromiseUtils.promiseState;
727
+ /* c8 ignore next */
696
728
  /**
697
729
  * Runs an operation periodically with configurable intervals and stopping conditions.
698
730
  *
699
- * @param operation The operation to run periodically.
700
- * @param interval The interval (ms), array of intervals, or function returning interval per iteration.
701
- * @param options Options for maxExecutions, maxDurationMs, and schedule type.
702
- * @returns An object with stop() and done Promise which resolves when the periodic runner stops (or rejects if the operation errors).
731
+ * - `interval` may be a single number (ms), an array of numbers, or a function
732
+ * that receives the iteration number (starting at 1) and returns the next
733
+ * interval in milliseconds or `undefined` to stop.
734
+ * - If the interval array runs out of elements or the function returns `undefined`
735
+ * (or a negative value), no further invocations will be scheduled.
736
+ *
737
+ * Options:
738
+ * - `maxExecutions` stop after N runs (inclusive).
739
+ * - `maxDurationMs` stop after elapsed ms since the first scheduled start.
740
+ * - `schedule` controls how the interval is measured:
741
+ * - `'delayAfterEnd'`: wait the interval after the previous operation completes
742
+ * before scheduling the next one (equivalent to a fixed delay between ends).
743
+ * - `'delayBetweenStarts'`: keep start times on a regular schedule (interval measured
744
+ * between the starts of successive operations).
745
+ * The default schedule is `'delayBetweenStarts'`.
746
+ *
747
+ * Returns an object with `stop()` to cancel further executions and `done` which
748
+ * resolves when the periodic runner stops. If the provided `operation` throws or
749
+ * rejects, the `done` promise will reject with that error so callers can handle it.
750
+ *
751
+ * Note: The first invocation of `operation` is scheduled after the first interval
752
+ * elapses (i.e. this function does NOT call `operation` immediately). If you need
753
+ * an immediate run, invoke `operation(1)` yourself before calling `runPeriodically`.
754
+ *
755
+ * @template T The operation return type (ignored by the runner; used for typing).
756
+ * @param operation Function to run each iteration. Receives the iteration index (1-based).
757
+ * @param interval Number | number[] | ((iteration: number) => number|undefined) defining waits.
758
+ * @param options Optional configuration.
759
+ * @param options.maxExecutions Stop after N executions.
760
+ * @param options.maxDurationMs Stop after N milliseconds.
761
+ * @param options.schedule How to measure intervals: `'delayAfterEnd'` or `'delayBetweenStarts'`.
762
+ * @returns An object containing `stop()` to cancel further executions and `done` Promise
763
+ * which resolves when the periodic runner stops (or rejects if the operation errors).
703
764
  */
704
765
  exports.runPeriodically = PromiseUtils.runPeriodically;
766
+ //# sourceMappingURL=promise-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise-utils.js","sourceRoot":"","sources":["../src/promise-utils.ts"],"names":[],"mappings":";;;AAAA,oBAAoB;AACpB;;;;;;;;;;GAUG;AACU,QAAA,kBAAkB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EA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-utils",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "Promise related utilities",
5
5
  "scripts": {
6
6
  "pretest": "eslint . --ext .ts",
7
- "test": "nyc mocha",
7
+ "test": "c8 mocha",
8
8
  "prepare": "shx rm -rf dist && tsc && es-check",
9
9
  "preversion": "generate-api-docs-and-update-readme && git add README.md"
10
10
  },
@@ -16,8 +16,8 @@
16
16
  "types": "dist/promise-utils.d.ts",
17
17
  "bin": {},
18
18
  "devDependencies": {
19
- "@handy-common-utils/dev-dependencies-mocha": "^1.5.4",
20
- "@types/node": "^18.17.1"
19
+ "@handy-common-utils/dev-dependencies-mocha": "^1.11.13",
20
+ "@types/node": "^22.19.21"
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "public"