@ls-stack/utils 3.11.1 → 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);
@@ -78,7 +78,12 @@ function serializeWithLevel(node, options = {}, level) {
78
78
  if (node.type === "emptyLine") {
79
79
  return "";
80
80
  }
81
- const { name, attributes = {}, children, escapeText: nodeEscapeText } = node;
81
+ const {
82
+ name,
83
+ attrs: attributes = {},
84
+ children,
85
+ escapeText: nodeEscapeText
86
+ } = node;
82
87
  const shouldEscapeText = nodeEscapeText !== void 0 ? nodeEscapeText : globalEscapeText;
83
88
  if (validateTagName && !isValidXmlTagName(name)) {
84
89
  if (invalidNodes === "throw") {
@@ -1,7 +1,7 @@
1
1
  type XMLNode = {
2
2
  type?: 'node';
3
3
  name: string;
4
- attributes?: Record<string, string | number | boolean | null | undefined>;
4
+ attrs?: Record<string, string | number | boolean | null | undefined>;
5
5
  children?: (XMLNode | null | undefined | false)[] | string;
6
6
  escapeText?: boolean;
7
7
  } | {
@@ -1,7 +1,7 @@
1
1
  type XMLNode = {
2
2
  type?: 'node';
3
3
  name: string;
4
- attributes?: Record<string, string | number | boolean | null | undefined>;
4
+ attrs?: Record<string, string | number | boolean | null | undefined>;
5
5
  children?: (XMLNode | null | undefined | false)[] | string;
6
6
  escapeText?: boolean;
7
7
  } | {
@@ -43,7 +43,12 @@ function serializeWithLevel(node, options = {}, level) {
43
43
  if (node.type === "emptyLine") {
44
44
  return "";
45
45
  }
46
- const { name, attributes = {}, children, escapeText: nodeEscapeText } = node;
46
+ const {
47
+ name,
48
+ attrs: attributes = {},
49
+ children,
50
+ escapeText: nodeEscapeText
51
+ } = node;
47
52
  const shouldEscapeText = nodeEscapeText !== void 0 ? nodeEscapeText : globalEscapeText;
48
53
  if (validateTagName && !isValidXmlTagName(name)) {
49
54
  if (invalidNodes === "throw") {
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.1",
4
+ "version": "3.12.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "lib"