vivth 1.3.0 → 1.3.2
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
|
@@ -1881,9 +1881,32 @@ npm i vivth
|
|
|
1881
1881
|
```js
|
|
1882
1882
|
import { SafeExit } from 'vivth';
|
|
1883
1883
|
|
|
1884
|
-
|
|
1884
|
+
const exitCallback () => {
|
|
1885
1885
|
// code
|
|
1886
|
-
}
|
|
1886
|
+
}
|
|
1887
|
+
SafeExit.instance.addCallback(exitCallback);
|
|
1888
|
+
|
|
1889
|
+
```
|
|
1890
|
+
|
|
1891
|
+
#### reference:`SafeExit_instance.removeCallback`
|
|
1892
|
+
- optional exit event removal;
|
|
1893
|
+
- the callbacks will be removed from registered via `addCallback` exiting;
|
|
1894
|
+
|
|
1895
|
+
```js
|
|
1896
|
+
/**
|
|
1897
|
+
* @param {()=>(Promise<void>)} cb
|
|
1898
|
+
*/
|
|
1899
|
+
```
|
|
1900
|
+
- <i>example</i>:
|
|
1901
|
+
```js
|
|
1902
|
+
import { SafeExit } from 'vivth';
|
|
1903
|
+
|
|
1904
|
+
const exitCallback () => {
|
|
1905
|
+
// code
|
|
1906
|
+
}
|
|
1907
|
+
SafeExit.instance.addCallback(exitCallback);
|
|
1908
|
+
|
|
1909
|
+
SafeExit.instance.removeCallback(exitCallback);
|
|
1887
1910
|
|
|
1888
1911
|
```
|
|
1889
1912
|
|
|
@@ -2367,7 +2390,8 @@ npm i vivth
|
|
|
2367
2390
|
>>- you can always look at `vivth/src` files to check how the source, and the `README.md` and `index.mjs` documentation/generation results;
|
|
2368
2391
|
>6) this types of arrow functions will be converted to regullar function, for concise type emition:
|
|
2369
2392
|
>>- validly exported function;
|
|
2370
|
-
>>- static/instance method(s) with generic template;
|
|
2393
|
+
>>- static/instance method(s) with generic template;
|
|
2394
|
+
>7) transpile `.ts` and `.mts` to `.mjs` same name and directory;
|
|
2371
2395
|
|
|
2372
2396
|
|
|
2373
2397
|
#### reference:`new JSautoDOC`
|
package/package.json
CHANGED
package/src/class/SafeExit.mjs
CHANGED
|
@@ -137,13 +137,32 @@ export class SafeExit {
|
|
|
137
137
|
* @example
|
|
138
138
|
* import { SafeExit } from 'vivth';
|
|
139
139
|
*
|
|
140
|
-
*
|
|
140
|
+
* const exitCallback () => {
|
|
141
141
|
* // code
|
|
142
|
-
* }
|
|
142
|
+
* }
|
|
143
|
+
* SafeExit.instance.addCallback(exitCallback);
|
|
143
144
|
*/
|
|
144
145
|
addCallback = (cb) => {
|
|
145
146
|
safeCleanUpCBs.add(cb);
|
|
146
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* @description
|
|
150
|
+
* - optional exit event removal;
|
|
151
|
+
* - the callbacks will be removed from registered via `addCallback` exiting;
|
|
152
|
+
* @param {()=>(Promise<void>)} cb
|
|
153
|
+
* @example
|
|
154
|
+
* import { SafeExit } from 'vivth';
|
|
155
|
+
*
|
|
156
|
+
* const exitCallback () => {
|
|
157
|
+
* // code
|
|
158
|
+
* }
|
|
159
|
+
* SafeExit.instance.addCallback(exitCallback);
|
|
160
|
+
*
|
|
161
|
+
* SafeExit.instance.removeCallback(exitCallback);
|
|
162
|
+
*/
|
|
163
|
+
removeCallback = (cb) => {
|
|
164
|
+
safeCleanUpCBs.delete(cb);
|
|
165
|
+
};
|
|
147
166
|
/**
|
|
148
167
|
* @type {()=>void}
|
|
149
168
|
*/
|
package/src/doc/JSautoDOC.mjs
CHANGED
|
@@ -50,6 +50,7 @@ const acceptableExt = new Set(['.mjs', '.mts', '.ts']);
|
|
|
50
50
|
* >6) this types of arrow functions will be converted to regullar function, for concise type emition:
|
|
51
51
|
* >>- validly exported function;
|
|
52
52
|
* >>- static/instance method(s) with generic template;
|
|
53
|
+
* >7) transpile `.ts` and `.mts` to `.mjs` same name and directory;
|
|
53
54
|
*/
|
|
54
55
|
export class JSautoDOC {
|
|
55
56
|
/**
|
|
@@ -114,6 +115,7 @@ export class JSautoDOC {
|
|
|
114
115
|
return;
|
|
115
116
|
}
|
|
116
117
|
if (ext !== '.mjs') {
|
|
118
|
+
// no need to be awaited
|
|
117
119
|
TsToMjs(path, {
|
|
118
120
|
encoding,
|
|
119
121
|
});
|
|
@@ -75,7 +75,7 @@ export function CompileJS({ entryPoint, minifyFirst, encoding, outDir, compiler,
|
|
|
75
75
|
encoding?: BufferEncoding | undefined;
|
|
76
76
|
minifyFirst: boolean;
|
|
77
77
|
outDir: string;
|
|
78
|
-
compiler?: "
|
|
78
|
+
compiler?: "bun" | "deno" | "pkg" | undefined;
|
|
79
79
|
compilerArguments?: Record<string, string> | undefined;
|
|
80
80
|
esBundlerPlugins?: import("esbuild").Plugin[] | undefined;
|
|
81
81
|
}): ReturnType<typeof TryAsync<{
|
|
@@ -93,11 +93,28 @@ export class SafeExit {
|
|
|
93
93
|
* @example
|
|
94
94
|
* import { SafeExit } from 'vivth';
|
|
95
95
|
*
|
|
96
|
-
*
|
|
96
|
+
* const exitCallback () => {
|
|
97
97
|
* // code
|
|
98
|
-
* }
|
|
98
|
+
* }
|
|
99
|
+
* SafeExit.instance.addCallback(exitCallback);
|
|
99
100
|
*/
|
|
100
101
|
addCallback: (cb: () => (Promise<void>)) => void;
|
|
102
|
+
/**
|
|
103
|
+
* @description
|
|
104
|
+
* - optional exit event removal;
|
|
105
|
+
* - the callbacks will be removed from registered via `addCallback` exiting;
|
|
106
|
+
* @param {()=>(Promise<void>)} cb
|
|
107
|
+
* @example
|
|
108
|
+
* import { SafeExit } from 'vivth';
|
|
109
|
+
*
|
|
110
|
+
* const exitCallback () => {
|
|
111
|
+
* // code
|
|
112
|
+
* }
|
|
113
|
+
* SafeExit.instance.addCallback(exitCallback);
|
|
114
|
+
*
|
|
115
|
+
* SafeExit.instance.removeCallback(exitCallback);
|
|
116
|
+
*/
|
|
117
|
+
removeCallback: (cb: () => (Promise<void>)) => void;
|
|
101
118
|
#private;
|
|
102
119
|
}
|
|
103
120
|
import { EnvSignal } from './EnvSignal.mjs';
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* >6) this types of arrow functions will be converted to regullar function, for concise type emition:
|
|
19
19
|
* >>- validly exported function;
|
|
20
20
|
* >>- static/instance method(s) with generic template;
|
|
21
|
+
* >7) transpile `.ts` and `.mts` to `.mjs` same name and directory;
|
|
21
22
|
*/
|
|
22
23
|
export class JSautoDOC {
|
|
23
24
|
/**
|