vivth 1.2.3 → 1.3.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.
- package/README.md +608 -586
- package/README.src.md +5 -1
- package/bun.lock +6 -0
- package/index.mjs +10 -6
- package/package.json +3 -1
- package/src/bundler/CompileJS.mjs +11 -8
- package/src/bundler/EsBundler.mjs +4 -2
- package/src/bundler/FSInline.mjs +3 -0
- package/src/bundler/FSInlineAnalyzer.mjs +31 -7
- package/src/bundler/FSInlineBundled.mjs +5 -1
- package/src/bundler/adds/ToBundledJSPlugin.mjs +3 -4
- package/src/class/Console.mjs +12 -4
- package/src/class/Derived.mjs +5 -1
- package/src/class/Effect.mjs +6 -6
- package/src/class/EnvSignal.mjs +1 -8
- package/src/class/EventSignal.mjs +8 -7
- package/src/class/FileSafe.mjs +1 -1
- package/src/class/ListSignal.mjs +18 -10
- package/src/class/LitExp.mjs +241 -204
- package/src/class/Paths.mjs +10 -8
- package/src/class/QChannel.mjs +14 -7
- package/src/class/SafeExit.mjs +16 -7
- package/src/class/Signal.mjs +8 -7
- package/src/class/WorkerMainThread.mjs +45 -24
- package/src/class/WorkerMainThreadBundled.mjs +42 -24
- package/src/class/WorkerThread.mjs +21 -7
- package/src/common/Base64URL.mjs +2 -2
- package/src/common/Base64URLFromFile.mjs +1 -1
- package/src/doc/JSautoDOC.mjs +99 -62
- package/src/doc/correctBeforeParse.mjs +139 -0
- package/src/doc/parsedFile.mjs +127 -76
- package/src/function/CreateImmutable.mjs +12 -7
- package/src/function/GetRuntime.mjs +8 -3
- package/src/function/LazyFactory.mjs +10 -4
- package/src/function/Try.mjs +4 -1
- package/src/function/TryAsync.mjs +2 -1
- package/src/function/TrySync.mjs +3 -1
- package/src/function/TsToMjs.mjs +7 -4
- package/src/types/AnyButUndefined.mjs +1 -0
- package/src/types/LitExpResultType.mjs +7 -0
- package/src/types/Runtime.mjs +1 -1
- package/tsconfig.json +27 -5
- package/types/dev/workerThreadClass.d.mts +1 -1
- package/types/index.d.mts +7 -6
- package/types/src/bundler/CompileJS.d.mts +14 -9
- package/types/src/bundler/EsBundler.d.mts +1 -1
- package/types/src/class/Derived.d.mts +4 -64
- package/types/src/class/Effect.d.mts +8 -8
- package/types/src/class/EnvSignal.d.mts +0 -1
- package/types/src/class/EventSignal.d.mts +5 -5
- package/types/src/class/FileSafe.d.mts +2 -2
- package/types/src/class/ListSignal.d.mts +1 -1
- package/types/src/class/LitExp.d.mts +49 -53
- package/types/src/class/Paths.d.mts +4 -4
- package/types/src/class/QChannel.d.mts +1 -1
- package/types/src/class/SafeExit.d.mts +3 -3
- package/types/src/class/Signal.d.mts +3 -3
- package/types/src/class/WorkerMainThread.d.mts +13 -8
- package/types/src/class/WorkerMainThreadBundled.d.mts +13 -8
- package/types/src/class/WorkerThread.d.mts +4 -4
- package/types/src/common/Base64URL.d.mts +2 -2
- package/types/src/common/Base64URLFromFile.d.mts +2 -2
- package/types/src/doc/JSautoDOC.d.mts +33 -12
- package/types/src/doc/correctBeforeParse.d.mts +2 -0
- package/types/src/doc/parsedFile.d.mts +7 -10
- package/types/src/function/CreateImmutable.d.mts +2 -2
- package/types/src/function/Try.d.mts +2 -2
- package/types/src/function/TryAsync.d.mts +2 -2
- package/types/src/function/TrySync.d.mts +3 -2
- package/types/src/function/TsToMjs.d.mts +2 -2
- package/types/src/types/LitExpResultType.d.mts +7 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @type {Set<Signal
|
|
2
|
+
* @type {Set<Signal<any>>}
|
|
3
3
|
*/
|
|
4
4
|
export const setOFSignals: Set<Signal<any>>;
|
|
5
5
|
/**
|
|
@@ -149,9 +149,9 @@ export class Signal<VALUE> {
|
|
|
149
149
|
/**
|
|
150
150
|
* @description
|
|
151
151
|
* - value before change;
|
|
152
|
-
* @returns {VALUE}
|
|
152
|
+
* @returns {VALUE|undefined}
|
|
153
153
|
*/
|
|
154
|
-
get prev(): VALUE;
|
|
154
|
+
get prev(): VALUE | undefined;
|
|
155
155
|
/**
|
|
156
156
|
* @description
|
|
157
157
|
* - assign new value then automatically notify all subscribers;
|
|
@@ -3,16 +3,20 @@
|
|
|
3
3
|
* @typedef {import('./WorkerResult.mjs').WorkerResult<POST>} WorkerResult
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* @
|
|
6
|
+
* @template RECEIVE
|
|
7
|
+
* @template POST
|
|
8
|
+
* @typedef {import('./WorkerThread.mjs').WorkerThread<RECEIVE, POST>} WorkerThread
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
7
11
|
* @typedef {import('../common/lazie.mjs').unwrapLazy} unwrapLazy
|
|
8
12
|
*/
|
|
9
13
|
/**
|
|
10
14
|
* @description
|
|
11
15
|
* - class helper to create `Worker` instance;
|
|
12
16
|
* - before any `Worker` functionaily to be used, you need to setup it with `WorkerThread.setup` and `WorkerMainThread.setup` before runing anytyhing;
|
|
13
|
-
* @template {WorkerThread} WT
|
|
17
|
+
* @template {WorkerThread<any, any>} WT
|
|
14
18
|
*/
|
|
15
|
-
export class WorkerMainThread<WT extends WorkerThread
|
|
19
|
+
export class WorkerMainThread<WT extends WorkerThread<any, any>> {
|
|
16
20
|
/**
|
|
17
21
|
* @type {boolean}
|
|
18
22
|
*/
|
|
@@ -79,7 +83,7 @@ export class WorkerMainThread<WT extends WorkerThread> {
|
|
|
79
83
|
type?: "module";
|
|
80
84
|
};
|
|
81
85
|
/**
|
|
82
|
-
* @template {WorkerThread} WT
|
|
86
|
+
* @template {WorkerThread<any, any>} WT
|
|
83
87
|
* @description
|
|
84
88
|
* - create Worker_instance;
|
|
85
89
|
* @param {string} handler
|
|
@@ -90,16 +94,17 @@ export class WorkerMainThread<WT extends WorkerThread> {
|
|
|
90
94
|
*
|
|
91
95
|
* export const myDoubleWorker = WorkerMainThread.newVivthWorker('./doubleWorkerThread.mjs');
|
|
92
96
|
*/
|
|
93
|
-
static newVivthWorker
|
|
97
|
+
static newVivthWorker<WT_1 extends WorkerThread<any, any>>(handler: string, options?: Omit<WorkerOptions | import("worker_threads").WorkerOptions, "eval" | "type">): WorkerMainThread<WT_1>;
|
|
94
98
|
/**
|
|
99
|
+
* @template {WorkerThread<any, any>} WT
|
|
95
100
|
* @param {string} handler
|
|
96
101
|
* @param { WorkerOptions
|
|
97
102
|
* | import('worker_threads').WorkerOptions} options
|
|
98
|
-
* @param {WorkerMainThread} worker
|
|
103
|
+
* @param {WorkerMainThread<WT>} worker
|
|
99
104
|
* @param {(any:any)=>void} listener
|
|
100
105
|
* @returns {Promise<void>}
|
|
101
106
|
*/
|
|
102
|
-
static #workerFilehandler
|
|
107
|
+
static #workerFilehandler<WT_1 extends WorkerThread<any, any>>(handler: string, options: WorkerOptions | import("worker_threads").WorkerOptions, worker: WorkerMainThread<WT_1>, listener: (any: any) => void): Promise<void>;
|
|
103
108
|
/**
|
|
104
109
|
* @private
|
|
105
110
|
* @param {Parameters<typeof WorkerMainThread<WT>["newVivthWorker"]>[0]} handler
|
|
@@ -144,6 +149,6 @@ export class WorkerMainThread<WT extends WorkerThread> {
|
|
|
144
149
|
#private;
|
|
145
150
|
}
|
|
146
151
|
export type WorkerResult<POST> = import("./WorkerResult.mjs").WorkerResult<POST>;
|
|
147
|
-
export type WorkerThread = import("./WorkerThread.mjs").WorkerThread<
|
|
152
|
+
export type WorkerThread<RECEIVE, POST> = import("./WorkerThread.mjs").WorkerThread<RECEIVE, POST>;
|
|
148
153
|
export type unwrapLazy = "vivth:unwrapLazy;";
|
|
149
154
|
import { Derived } from './Derived.mjs';
|
|
@@ -3,13 +3,17 @@
|
|
|
3
3
|
* @typedef {import('./WorkerResult.mjs').WorkerResult<POST>} WorkerResult
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* @
|
|
6
|
+
* @template RECEIVE
|
|
7
|
+
* @template POST
|
|
8
|
+
* @typedef {import('./WorkerThread.mjs').WorkerThread<RECEIVE, POST>} WorkerThread
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
7
11
|
* @typedef {import('../common/lazie.mjs').unwrapLazy} unwrapLazy
|
|
8
12
|
*/
|
|
9
13
|
/**
|
|
10
|
-
* @template {WorkerThread} WT
|
|
14
|
+
* @template {WorkerThread<any, any>} WT
|
|
11
15
|
*/
|
|
12
|
-
export class WorkerMainThread<WT extends WorkerThread
|
|
16
|
+
export class WorkerMainThread<WT extends WorkerThread<any, any>> {
|
|
13
17
|
/**
|
|
14
18
|
* @type {boolean}
|
|
15
19
|
*/
|
|
@@ -38,21 +42,22 @@ export class WorkerMainThread<WT extends WorkerThread> {
|
|
|
38
42
|
type?: "module";
|
|
39
43
|
};
|
|
40
44
|
/**
|
|
41
|
-
* @template {WorkerThread} WT
|
|
45
|
+
* @template {WorkerThread<any, any>} WT
|
|
42
46
|
* @param {string} handler
|
|
43
47
|
* @param {Omit<WorkerOptions|import('worker_threads').WorkerOptions, 'eval'|'type'>} [options]
|
|
44
48
|
* @returns {WorkerMainThread<WT>}
|
|
45
49
|
*/
|
|
46
|
-
static newVivthWorker
|
|
50
|
+
static newVivthWorker<WT_1 extends WorkerThread<any, any>>(handler: string, options?: Omit<WorkerOptions | import("worker_threads").WorkerOptions, "eval" | "type">): WorkerMainThread<WT_1>;
|
|
47
51
|
/**
|
|
52
|
+
* @template {WorkerThread<any, any>} WT
|
|
48
53
|
* @param {string} handler
|
|
49
54
|
* @param { WorkerOptions
|
|
50
55
|
* | import('worker_threads').WorkerOptions} options
|
|
51
|
-
* @param {WorkerMainThread} worker
|
|
56
|
+
* @param {WorkerMainThread<WT>} worker
|
|
52
57
|
* @param {(any:any)=>void} listener
|
|
53
58
|
* @returns {Promise<void>}
|
|
54
59
|
*/
|
|
55
|
-
static #workerFilehandler
|
|
60
|
+
static #workerFilehandler<WT_1 extends WorkerThread<any, any>>(handler: string, options: WorkerOptions | import("worker_threads").WorkerOptions, worker: WorkerMainThread<WT_1>, listener: (any: any) => void): Promise<void>;
|
|
56
61
|
/**
|
|
57
62
|
* @param {Parameters<typeof WorkerMainThread<WT>["newVivthWorker"]>[0]} handler
|
|
58
63
|
* @param {Parameters<typeof WorkerMainThread<WT>["newVivthWorker"]>[1]} [options]
|
|
@@ -73,6 +78,6 @@ export class WorkerMainThread<WT extends WorkerThread> {
|
|
|
73
78
|
#private;
|
|
74
79
|
}
|
|
75
80
|
export type WorkerResult<POST> = import("./WorkerResult.mjs").WorkerResult<POST>;
|
|
76
|
-
export type WorkerThread = import("./WorkerThread.mjs").WorkerThread<
|
|
81
|
+
export type WorkerThread<RECEIVE, POST> = import("./WorkerThread.mjs").WorkerThread<RECEIVE, POST>;
|
|
77
82
|
export type unwrapLazy = "vivth:unwrapLazy;";
|
|
78
83
|
import { Derived } from './Derived.mjs';
|
|
@@ -10,9 +10,9 @@ export class WorkerThread<RECEIVE, POST> {
|
|
|
10
10
|
* @typedef {import('../types/QCBReturn.mjs').QCBReturn} QCBReturn
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
-
* @type {Parameters<typeof WorkerThread["setup"]>[0]}
|
|
13
|
+
* @type {Parameters<typeof WorkerThread["setup"]>[0]|undefined}
|
|
14
14
|
*/
|
|
15
|
-
static #refs: Parameters<(typeof WorkerThread)["setup"]>[0];
|
|
15
|
+
static #refs: Parameters<(typeof WorkerThread)["setup"]>[0] | undefined;
|
|
16
16
|
/**
|
|
17
17
|
* @description
|
|
18
18
|
* - need to be called and exported as new `WorkerThread` class reference;
|
|
@@ -40,7 +40,7 @@ export class WorkerThread<RECEIVE, POST> {
|
|
|
40
40
|
/**
|
|
41
41
|
* @description
|
|
42
42
|
* - instantiate via created class from `setup` static method;
|
|
43
|
-
* @param {WorkerThread["handler"]} handler
|
|
43
|
+
* @param {WorkerThread<RECEIVE, POST>["handler"]} handler
|
|
44
44
|
* @example
|
|
45
45
|
* import { MyWorkerThread } from './MyWorkerThread.mjs';
|
|
46
46
|
*
|
|
@@ -55,7 +55,7 @@ export class WorkerThread<RECEIVE, POST> {
|
|
|
55
55
|
* return ev = ev \* 2;
|
|
56
56
|
* });
|
|
57
57
|
*/
|
|
58
|
-
constructor(handler:
|
|
58
|
+
constructor(handler: WorkerThread<RECEIVE, POST>["handler"]);
|
|
59
59
|
/**
|
|
60
60
|
* @description
|
|
61
61
|
* - type helper;
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
* (str, prevBufferEncoding) =>
|
|
13
13
|
* Buffer.from(str, prevBufferEncoding).toString('base64')
|
|
14
14
|
* ```
|
|
15
|
-
* @returns {
|
|
15
|
+
* @returns {string}
|
|
16
16
|
* @example
|
|
17
17
|
* import { Base64URL } from 'vivth'
|
|
18
18
|
* import fileString from './fileString.mjs';
|
|
19
19
|
*
|
|
20
20
|
* Base64URL(fileString, 'application/javascript', btoa);
|
|
21
21
|
*/
|
|
22
|
-
export function Base64URL(fileString: string, mimeType: string, btoaFunction: (string: string) => string):
|
|
22
|
+
export function Base64URL(fileString: string, mimeType: string, btoaFunction: (string: string) => string): string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* >- can be extremely usefull to display file on desktop app webview, without exposing http server;
|
|
6
6
|
* >- when using `FSInline`, use [Base64URL](#base64url) instead;
|
|
7
7
|
* @param {string} filePath
|
|
8
|
-
* @returns {Promise<
|
|
8
|
+
* @returns {Promise<string>}
|
|
9
9
|
* @example
|
|
10
10
|
* import { join } from 'node:path'
|
|
11
11
|
*
|
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
*
|
|
14
14
|
* await Base64URLFromFile(join(Paths.root, '/path/to/file'));
|
|
15
15
|
*/
|
|
16
|
-
export function Base64URLFromFile(filePath: string): Promise<
|
|
16
|
+
export function Base64URLFromFile(filePath: string): Promise<string>;
|
|
@@ -15,21 +15,24 @@
|
|
|
15
15
|
* >>- first `"at"${string}` after `"at"description` until `"at"example` will be treated as `javascript` comment block on the `markdown`;
|
|
16
16
|
* >>- `"at"example` are treated as `javascript` block on the `markdown` file, and should be placed last on the same comment block;
|
|
17
17
|
* >>- you can always look at `vivth/src` files to check how the source, and the `README.md` and `index.mjs` documentation/generation results;
|
|
18
|
+
* >6) this types of arrow functions will be converted to regullar function, for concise type emition:
|
|
19
|
+
* >>- validly exported function;
|
|
20
|
+
* >>- static/instance method(s) with generic template;
|
|
18
21
|
*/
|
|
19
22
|
export class JSautoDOC {
|
|
20
23
|
/**
|
|
21
|
-
* @type {JSautoDOC}
|
|
24
|
+
* @type {JSautoDOC|undefined}
|
|
22
25
|
*/
|
|
23
|
-
static #instance: JSautoDOC;
|
|
26
|
+
static #instance: JSautoDOC | undefined;
|
|
24
27
|
/**
|
|
25
28
|
* @description
|
|
26
29
|
* @param {Object} [options]
|
|
27
30
|
* @param {Object} [options.paths]
|
|
28
|
-
* @param {string}
|
|
31
|
+
* @param {string} options.paths.file
|
|
29
32
|
* - entry point;
|
|
30
|
-
* @param {string}
|
|
33
|
+
* @param {string} options.paths.readMe
|
|
31
34
|
* - readme target;
|
|
32
|
-
* @param {string}
|
|
35
|
+
* @param {string} options.paths.dir
|
|
33
36
|
* - source directory;
|
|
34
37
|
* @param {string} [options.copyright]
|
|
35
38
|
* @param {string} [options.tableOfContentTitle]
|
|
@@ -47,13 +50,31 @@ export class JSautoDOC {
|
|
|
47
50
|
*/
|
|
48
51
|
constructor({ paths, tableOfContentTitle, copyright, option, }?: {
|
|
49
52
|
paths?: {
|
|
50
|
-
file
|
|
51
|
-
readMe
|
|
52
|
-
dir
|
|
53
|
-
};
|
|
54
|
-
copyright?: string;
|
|
55
|
-
tableOfContentTitle?: string;
|
|
56
|
-
option?:
|
|
53
|
+
file: string;
|
|
54
|
+
readMe: string;
|
|
55
|
+
dir: string;
|
|
56
|
+
} | undefined;
|
|
57
|
+
copyright?: string | undefined;
|
|
58
|
+
tableOfContentTitle?: string | undefined;
|
|
59
|
+
option?: Partial<{
|
|
60
|
+
persistent: boolean;
|
|
61
|
+
ignoreInitial: boolean;
|
|
62
|
+
followSymlinks: boolean;
|
|
63
|
+
cwd?: string;
|
|
64
|
+
usePolling: boolean;
|
|
65
|
+
interval: number;
|
|
66
|
+
binaryInterval: number;
|
|
67
|
+
alwaysStat?: boolean;
|
|
68
|
+
depth?: number;
|
|
69
|
+
ignorePermissionErrors: boolean;
|
|
70
|
+
atomic: boolean | number;
|
|
71
|
+
} & {
|
|
72
|
+
ignored: import("chokidar").Matcher | import("chokidar").Matcher[];
|
|
73
|
+
awaitWriteFinish: boolean | Partial<{
|
|
74
|
+
stabilityThreshold: number;
|
|
75
|
+
pollInterval: number;
|
|
76
|
+
}>;
|
|
77
|
+
}> | undefined;
|
|
57
78
|
});
|
|
58
79
|
#private;
|
|
59
80
|
}
|
|
@@ -22,15 +22,16 @@ export class parsedFile {
|
|
|
22
22
|
*/
|
|
23
23
|
/**
|
|
24
24
|
* @param {string} path__
|
|
25
|
+
* @param {import('fs').Stats} _stats
|
|
25
26
|
* @param {BufferEncoding} [encoding]
|
|
26
27
|
*/
|
|
27
|
-
constructor(path__: string, encoding?: BufferEncoding);
|
|
28
|
+
constructor(path__: string, _stats: import("fs").Stats, encoding?: BufferEncoding);
|
|
28
29
|
parse: () => Promise<void>;
|
|
29
30
|
documented: {
|
|
30
31
|
typedef: () => Promise<{
|
|
31
32
|
module: string;
|
|
32
33
|
readme: string;
|
|
33
|
-
}>;
|
|
34
|
+
} | undefined>;
|
|
34
35
|
/**
|
|
35
36
|
* @type {Set<refType>}
|
|
36
37
|
*/
|
|
@@ -54,7 +55,7 @@ export class parsedFile {
|
|
|
54
55
|
typedef: () => Promise<{
|
|
55
56
|
module: string;
|
|
56
57
|
readme: string;
|
|
57
|
-
}>;
|
|
58
|
+
} | undefined>;
|
|
58
59
|
/**
|
|
59
60
|
* @type {Set<refType>}
|
|
60
61
|
*/
|
|
@@ -153,11 +154,6 @@ export class parsedFile {
|
|
|
153
154
|
*/
|
|
154
155
|
readonly noDot: string | undefined;
|
|
155
156
|
};
|
|
156
|
-
/**
|
|
157
|
-
* @private
|
|
158
|
-
* @returns {Promise<Stats>}
|
|
159
|
-
*/
|
|
160
|
-
private stats;
|
|
161
157
|
get timeStamp(): {
|
|
162
158
|
/**
|
|
163
159
|
* @returns {Promise<number>}
|
|
@@ -206,8 +202,9 @@ export class parsedFile {
|
|
|
206
202
|
};
|
|
207
203
|
};
|
|
208
204
|
/**
|
|
209
|
-
* @returns {
|
|
205
|
+
* @returns {ReturnType<typeof TryAsync<any>>}
|
|
210
206
|
*/
|
|
211
|
-
|
|
207
|
+
importAsModuleJS: () => ReturnType<typeof TryAsync<any>>;
|
|
212
208
|
#private;
|
|
213
209
|
}
|
|
210
|
+
import { TryAsync } from '../function/TryAsync.mjs';
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
* getMap(name_) => mappedObject.get(name_),
|
|
24
24
|
* })
|
|
25
25
|
*/
|
|
26
|
-
export function CreateImmutable<PARENT extends
|
|
27
|
-
lazy?: boolean;
|
|
26
|
+
export function CreateImmutable<PARENT extends Object, OBJECT extends Object>(parent: PARENT, keyName: string, object: (this: PARENT) => OBJECT, { lazy }?: {
|
|
27
|
+
lazy?: boolean | undefined;
|
|
28
28
|
}): OBJECT;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* @param {RecordTryType} tryRecord
|
|
15
15
|
* @returns {Promise<
|
|
16
16
|
* [[keyof RecordTryType, RETURNTYPE], undefined]
|
|
17
|
-
* | [[undefined, undefined], Error]
|
|
17
|
+
* | [[undefined, undefined], Error|undefined]
|
|
18
18
|
* >}
|
|
19
19
|
* @example
|
|
20
20
|
* import { Try } from 'vivth';
|
|
@@ -49,4 +49,4 @@
|
|
|
49
49
|
*/
|
|
50
50
|
export function Try<KEY extends string, RETURNTYPE, RecordTryType extends Record<KEY, (err: {
|
|
51
51
|
prevError: undefined | Error;
|
|
52
|
-
}) => Promise<RETURNTYPE>>>(tryRecord: RecordTryType): Promise<[[keyof RecordTryType, RETURNTYPE], undefined] | [[undefined, undefined], Error]>;
|
|
52
|
+
}) => Promise<RETURNTYPE>>>(tryRecord: RecordTryType): Promise<[[keyof RecordTryType, RETURNTYPE], undefined] | [[undefined, undefined], Error | undefined]>;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* - usefull to flatten indentation for error handlings;
|
|
5
5
|
* @template RESULT
|
|
6
6
|
* @param {()=>Promise<RESULT>} asyncFunction_
|
|
7
|
-
* @returns {Promise<[RESULT|undefined,
|
|
7
|
+
* @returns {Promise<[RESULT,undefined]|[undefined,Error]>}
|
|
8
8
|
* @example
|
|
9
9
|
* import { TryAsync } from 'vivth';
|
|
10
10
|
*
|
|
@@ -19,4 +19,4 @@
|
|
|
19
19
|
* return await res.json();
|
|
20
20
|
* })
|
|
21
21
|
*/
|
|
22
|
-
export function TryAsync<RESULT>(asyncFunction_: () => Promise<RESULT>): Promise<[RESULT | undefined, Error
|
|
22
|
+
export function TryAsync<RESULT>(asyncFunction_: () => Promise<RESULT>): Promise<[RESULT, undefined] | [undefined, Error]>;
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* - usefull to flatten indentation for error handlings;
|
|
5
5
|
* @template RESULT
|
|
6
6
|
* @param {()=>RESULT} function_
|
|
7
|
-
* @returns {[RESULT
|
|
7
|
+
* @returns {[RESULT,undefined]|
|
|
8
|
+
* [undefined,Error]}
|
|
8
9
|
* @example
|
|
9
10
|
* import { readFileSync } from 'fs';
|
|
10
11
|
* import { TrySync } from './yourModule.js';
|
|
@@ -13,4 +14,4 @@
|
|
|
13
14
|
* return readFileSync('./some/file.txt', 'utf-8');
|
|
14
15
|
* });
|
|
15
16
|
*/
|
|
16
|
-
export function TrySync<RESULT>(function_: () => RESULT): [RESULT | undefined, Error
|
|
17
|
+
export function TrySync<RESULT>(function_: () => RESULT): [RESULT, undefined] | [undefined, Error];
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
* TsToMjs('./myFile.mts', { encoding: 'utf-8', overrideDir: './other/dir' });
|
|
19
19
|
*/
|
|
20
20
|
export function TsToMjs(path_: string, { overrideDir, encoding }?: {
|
|
21
|
-
overrideDir?: string;
|
|
22
|
-
encoding?: BufferEncoding;
|
|
21
|
+
overrideDir?: string | undefined;
|
|
22
|
+
encoding?: BufferEncoding | undefined;
|
|
23
23
|
}): Promise<void>;
|