@standardserver/shared 0.0.12 → 0.0.15

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.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  declare function toArray<T>(value: T): T extends readonly any[] ? T : (T extends undefined | null ? never : T[]);
2
2
 
3
3
  declare const PACKAGE_NAME = "@standardserver/shared";
4
- declare const PACKAGE_VERSION = "0.0.12";
4
+ declare const PACKAGE_VERSION = "0.0.15";
5
5
  /**
6
6
  * Generates a unique symbol for the specified name within the package scope.
7
7
  * The symbol is globally registered using `Symbol.for` to ensure consistency across modules.
@@ -35,11 +35,18 @@ declare class SequentialIdGenerator {
35
35
  generate(): string;
36
36
  }
37
37
 
38
+ type AsyncCleanupFnState = {
39
+ kind: 'success';
40
+ error?: undefined;
41
+ } | {
42
+ kind: 'error';
43
+ error: unknown;
44
+ } | {
45
+ kind: 'cancelled';
46
+ error?: unknown;
47
+ };
38
48
  interface AsyncCleanupFn {
39
- (state: {
40
- isCancelled: boolean;
41
- error?: unknown;
42
- }): Promise<void>;
49
+ (state: AsyncCleanupFnState): Promise<void>;
43
50
  }
44
51
 
45
52
  declare function isAsyncIteratorObject(maybe: unknown): maybe is AsyncIteratorObject<any, any, any>;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  declare function toArray<T>(value: T): T extends readonly any[] ? T : (T extends undefined | null ? never : T[]);
2
2
 
3
3
  declare const PACKAGE_NAME = "@standardserver/shared";
4
- declare const PACKAGE_VERSION = "0.0.12";
4
+ declare const PACKAGE_VERSION = "0.0.15";
5
5
  /**
6
6
  * Generates a unique symbol for the specified name within the package scope.
7
7
  * The symbol is globally registered using `Symbol.for` to ensure consistency across modules.
@@ -35,11 +35,18 @@ declare class SequentialIdGenerator {
35
35
  generate(): string;
36
36
  }
37
37
 
38
+ type AsyncCleanupFnState = {
39
+ kind: 'success';
40
+ error?: undefined;
41
+ } | {
42
+ kind: 'error';
43
+ error: unknown;
44
+ } | {
45
+ kind: 'cancelled';
46
+ error?: unknown;
47
+ };
38
48
  interface AsyncCleanupFn {
39
- (state: {
40
- isCancelled: boolean;
41
- error?: unknown;
42
- }): Promise<void>;
49
+ (state: AsyncCleanupFnState): Promise<void>;
43
50
  }
44
51
 
45
52
  declare function isAsyncIteratorObject(maybe: unknown): maybe is AsyncIteratorObject<any, any, any>;
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ function toArray(value) {
3
3
  }
4
4
 
5
5
  const PACKAGE_NAME = "@standardserver/shared";
6
- const PACKAGE_VERSION = "0.0.12";
6
+ const PACKAGE_VERSION = "0.0.15";
7
7
  function getPackageSymbol(name) {
8
8
  return Symbol.for(`${PACKAGE_NAME}@${PACKAGE_VERSION}/${name}`);
9
9
  }
@@ -72,7 +72,7 @@ class AsyncIteratorClass {
72
72
  } finally {
73
73
  if (this.isDone && !this.isExecuteComplete) {
74
74
  this.isExecuteComplete = true;
75
- await this.cleanup(errorRef ? { isCancelled: false, error: errorRef.value } : { isCancelled: false });
75
+ await this.cleanup(errorRef ? { kind: "error", error: errorRef.value } : { kind: "success" });
76
76
  }
77
77
  }
78
78
  });
@@ -81,7 +81,7 @@ class AsyncIteratorClass {
81
81
  this.isDone = true;
82
82
  if (!this.isExecuteComplete) {
83
83
  this.isExecuteComplete = true;
84
- await this.cleanup({ isCancelled: true });
84
+ await this.cleanup({ kind: "cancelled" });
85
85
  }
86
86
  return { done: true, value };
87
87
  }
@@ -89,7 +89,7 @@ class AsyncIteratorClass {
89
89
  this.isDone = true;
90
90
  if (!this.isExecuteComplete) {
91
91
  this.isExecuteComplete = true;
92
- await this.cleanup({ isCancelled: true, error });
92
+ await this.cleanup({ kind: "cancelled", error });
93
93
  }
94
94
  throw error;
95
95
  }
@@ -100,7 +100,7 @@ class AsyncIteratorClass {
100
100
  this.isDone = true;
101
101
  if (!this.isExecuteComplete) {
102
102
  this.isExecuteComplete = true;
103
- await this.cleanup({ isCancelled: true });
103
+ await this.cleanup({ kind: "cancelled" });
104
104
  }
105
105
  }
106
106
  [Symbol.asyncIterator]() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@standardserver/shared",
3
3
  "type": "module",
4
- "version": "0.0.12",
4
+ "version": "0.0.15",
5
5
  "license": "MIT",
6
6
  "homepage": "https://standardserver.dev",
7
7
  "repository": {