@code-essentials/utils 1.1.0 → 1.1.1

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/barrier.d.ts CHANGED
@@ -3,13 +3,14 @@ interface EnqueuedTask<T> {
3
3
  task: PromiseLike<T>;
4
4
  completion: AsyncVariable<T>;
5
5
  }
6
- export declare class Barrier<T = any> implements PromiseLike<T[]> {
6
+ export declare class Barrier<T = any> implements PromiseLike<T[]>, AsyncDisposable {
7
7
  #private;
8
8
  readonly queue: EnqueuedTask<T>[];
9
9
  await(...asyncTasks: PromiseLike<T>[]): void;
10
10
  run(...asyncTasks: PromiseLike<T>[]): void;
11
11
  clear(): void;
12
12
  complete(): Promise<this>;
13
+ [Symbol.asyncDispose](): Promise<void>;
13
14
  then<TResult1 = T[], TResult2 = never>(onfulfilled?: ((value: T[]) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
14
15
  }
15
16
  export {};
package/dist/barrier.js CHANGED
@@ -21,6 +21,9 @@ export class Barrier {
21
21
  this.clear();
22
22
  return result;
23
23
  }
24
+ async [Symbol.asyncDispose]() {
25
+ await this.complete();
26
+ }
24
27
  async then(onfulfilled, onrejected) {
25
28
  try {
26
29
  const values = await Promise.all(this.queue.map(({ completion }) => completion));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-essentials/utils",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,12 +28,12 @@
28
28
  "license": "MIT",
29
29
  "scripts": {
30
30
  "clean": "rm -rf dist",
31
- "prebuild": "pnpm run clean",
32
- "prebuild:debug": "pnpm run clean",
31
+ "prebuild": "npm run clean",
32
+ "prebuild:debug": "npm run clean",
33
33
  "build": "tsc -p tsconfig.prod.json",
34
34
  "build:debug": "tsc -p tsconfig.debug.json",
35
- "pretest": "pnpm run build:debug",
36
- "test": "pnpm run test:run",
35
+ "pretest": "npm run build:debug",
36
+ "test": "npm run test:run",
37
37
  "pretest:run": "",
38
38
  "test:run": "ava"
39
39
  }