@ls-stack/utils 3.11.2 → 3.12.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.
@@ -50,6 +50,8 @@ var AsyncQueue = class {
50
50
  events = (0, import_evtmitter.evtmitter)();
51
51
  #signal;
52
52
  #taskTimeout;
53
+ failures = [];
54
+ completions = [];
53
55
  constructor({
54
56
  concurrency = 1,
55
57
  signal,
@@ -58,6 +60,12 @@ var AsyncQueue = class {
58
60
  this.#concurrency = concurrency;
59
61
  this.#signal = signal;
60
62
  this.#taskTimeout = taskTimeout;
63
+ this.events.on("error", (e) => {
64
+ this.failures.push(e);
65
+ });
66
+ this.events.on("complete", (e) => {
67
+ this.completions.push(e);
68
+ });
61
69
  }
62
70
  #enqueue(task) {
63
71
  this.#queue.push(task);
@@ -32,6 +32,14 @@ declare class AsyncQueue<T, E extends ResultValidErrors = Error, I = unknown> {
32
32
  meta: I;
33
33
  };
34
34
  }>;
35
+ failures: Array<{
36
+ meta: I;
37
+ error: E | Error;
38
+ }>;
39
+ completions: Array<{
40
+ meta: I;
41
+ value: T;
42
+ }>;
35
43
  constructor({ concurrency, signal, timeout: taskTimeout, }?: AsyncQueueOptions);
36
44
  add(fn: (ctx: RunCtx<I>) => Promise<Result<T, E>> | Result<T, E>, options?: AddOptions<I, T, E>): Promise<Result<T, E | Error>>;
37
45
  resultifyAdd(fn: (ctx: RunCtx<I>) => Promise<T> | T, options?: AddOptions<I, T, E>): Promise<Result<T, E | Error>>;
@@ -32,6 +32,14 @@ declare class AsyncQueue<T, E extends ResultValidErrors = Error, I = unknown> {
32
32
  meta: I;
33
33
  };
34
34
  }>;
35
+ failures: Array<{
36
+ meta: I;
37
+ error: E | Error;
38
+ }>;
39
+ completions: Array<{
40
+ meta: I;
41
+ value: T;
42
+ }>;
35
43
  constructor({ concurrency, signal, timeout: taskTimeout, }?: AsyncQueueOptions);
36
44
  add(fn: (ctx: RunCtx<I>) => Promise<Result<T, E>> | Result<T, E>, options?: AddOptions<I, T, E>): Promise<Result<T, E | Error>>;
37
45
  resultifyAdd(fn: (ctx: RunCtx<I>) => Promise<T> | T, options?: AddOptions<I, T, E>): Promise<Result<T, E | Error>>;
package/lib/asyncQueue.js CHANGED
@@ -21,6 +21,8 @@ var AsyncQueue = class {
21
21
  events = evtmitter();
22
22
  #signal;
23
23
  #taskTimeout;
24
+ failures = [];
25
+ completions = [];
24
26
  constructor({
25
27
  concurrency = 1,
26
28
  signal,
@@ -29,6 +31,12 @@ var AsyncQueue = class {
29
31
  this.#concurrency = concurrency;
30
32
  this.#signal = signal;
31
33
  this.#taskTimeout = taskTimeout;
34
+ this.events.on("error", (e) => {
35
+ this.failures.push(e);
36
+ });
37
+ this.events.on("complete", (e) => {
38
+ this.completions.push(e);
39
+ });
32
40
  }
33
41
  #enqueue(task) {
34
42
  this.#queue.push(task);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ls-stack/utils",
3
3
  "description": "Typescript utils",
4
- "version": "3.11.2",
4
+ "version": "3.12.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "lib"