@inox-tools/utils 0.1.1 → 0.1.3

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/README.md CHANGED
@@ -4,10 +4,14 @@
4
4
 
5
5
  # Utils
6
6
 
7
- A collection of utilities used throughout Inox Tools
7
+ A collection of utilities used throughout Inox Tools.
8
8
 
9
9
  ## Install
10
10
 
11
11
  ```js
12
12
  npm i -D @inox-tools/utils
13
13
  ```
14
+
15
+ ### License
16
+
17
+ These utilities are available under the MIT license.
package/dist/once.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  declare class Once {
2
2
  #private;
3
3
  do(callback: () => void): void;
4
+ doAsync(callback: () => Promise<void>): Promise<void>;
4
5
  }
5
6
 
6
7
  export { Once };
package/dist/once.js CHANGED
@@ -1,5 +1,5 @@
1
- class e{#o=!1;do(o){this.#o||o();}}
1
+ class o{#i=!1;do(i){this.#i||(i(),this.#i=!0);}async doAsync(i){this.#i||(await i(),this.#i=!0);}}
2
2
 
3
- export { e as Once };
3
+ export { o as Once };
4
4
  //# sourceMappingURL=out.js.map
5
5
  //# sourceMappingURL=once.js.map
package/dist/once.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/once.ts"],"names":["Once","#done","callback"],"mappings":"AAAO,MAAMA,CAAK,CACRC,GAAQ,GAEV,GAAGC,EAA4B,CAChC,KAAKD,IACTC,EAAS,CAEX,CACD","sourcesContent":["export class Once {\n\treadonly #done = false;\n\n\tpublic do(callback: () => void): void {\n\t\tif (!this.#done) {\n\t\t\tcallback();\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../src/once.ts"],"names":["Once","#done","callback"],"mappings":"AAAO,MAAMA,CAAK,CACjBC,GAAQ,GAED,GAAGC,EAA4B,CAChC,KAAKD,KACTC,EAAS,EACT,KAAKD,GAAQ,GAEf,CAEA,MAAa,QAAQC,EAA8C,CAC7D,KAAKD,KACT,MAAMC,EAAS,EACf,KAAKD,GAAQ,GAEf,CACD","sourcesContent":["export class Once {\n\t#done = false;\n\n\tpublic do(callback: () => void): void {\n\t\tif (!this.#done) {\n\t\t\tcallback();\n\t\t\tthis.#done = true;\n\t\t}\n\t}\n\n\tpublic async doAsync(callback: () => Promise<void>): Promise<void> {\n\t\tif (!this.#done) {\n\t\t\tawait callback();\n\t\t\tthis.#done = true;\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,5 @@
1
+ type Prettify<T> = {
2
+ [K in keyof T]: T[K];
3
+ } & {};
4
+
5
+ export type { Prettify };
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inox-tools/utils",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "A collection of utilities used throughout Inox Tools",
5
5
  "keywords": [
6
6
  "utilities"
@@ -20,15 +20,15 @@
20
20
  "src"
21
21
  ],
22
22
  "devDependencies": {
23
- "@types/node": "^20",
24
- "@vitest/coverage-v8": "^1.5.0",
25
- "@vitest/ui": "^1.5.0",
23
+ "@types/node": "^20.14.10",
24
+ "@vitest/coverage-v8": "^2.0.2",
25
+ "@vitest/ui": "^2.0.2",
26
+ "astro": "^4.11.5",
26
27
  "jest-extended": "^4.0.2",
27
- "astro": "^4",
28
- "tsup": "^8",
29
- "typescript": "^5",
30
- "vite": "^5",
31
- "vitest": "^1.5.0"
28
+ "tsup": "^8.1.0",
29
+ "typescript": "^5.5.3",
30
+ "vite": "^5.3.3",
31
+ "vitest": "^2.0.2"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "tsup",
package/src/once.ts CHANGED
@@ -1,9 +1,17 @@
1
1
  export class Once {
2
- readonly #done = false;
2
+ #done = false;
3
3
 
4
4
  public do(callback: () => void): void {
5
5
  if (!this.#done) {
6
6
  callback();
7
+ this.#done = true;
8
+ }
9
+ }
10
+
11
+ public async doAsync(callback: () => Promise<void>): Promise<void> {
12
+ if (!this.#done) {
13
+ await callback();
14
+ this.#done = true;
7
15
  }
8
16
  }
9
17
  }
package/src/types.ts ADDED
@@ -0,0 +1,4 @@
1
+ // Source: https://www.totaltypescript.com/concepts/the-prettify-helper
2
+ export type Prettify<T> = {
3
+ [K in keyof T]: T[K];
4
+ } & {};