vivth 1.2.3 → 1.3.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/README.md +609 -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 +101 -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 +34 -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
package/README.md
CHANGED
|
@@ -31,19 +31,24 @@ npm i vivth
|
|
|
31
31
|
|
|
32
32
|
## versions:
|
|
33
33
|
|
|
34
|
-
- `1.0.0+:
|
|
34
|
+
- `1.0.0+:beta`:
|
|
35
|
+
|
|
35
36
|
> - beta release;
|
|
36
37
|
> - checking edge cases;
|
|
37
38
|
> - stable API, the exposed API access are highly unlikely to changes, only the underlying code
|
|
38
39
|
> might changes for improving performance;
|
|
40
|
+
|
|
41
|
+
- `1.3.x:beta`:
|
|
42
|
+
> - type should now fully fixed, even with strict ts check;
|
|
39
43
|
|
|
40
44
|
<h2 id="list-of-exported-api-and-typehelpers">list of exported API and typehelpers</h2>
|
|
41
45
|
|
|
46
|
+
- [CompileJS](#compilejs)
|
|
42
47
|
- [CreateESPlugin](#createesplugin)
|
|
43
48
|
- [EsBundler](#esbundler)
|
|
44
49
|
- [FSInline](#fsinline)
|
|
45
50
|
- [FSInlineAnalyzer](#fsinlineanalyzer)
|
|
46
|
-
- [
|
|
51
|
+
- [Console](#console)
|
|
47
52
|
- [Derived](#derived)
|
|
48
53
|
- [Effect](#effect)
|
|
49
54
|
- [EnvSignal](#envsignal)
|
|
@@ -51,42 +56,125 @@ npm i vivth
|
|
|
51
56
|
- [FileSafe](#filesafe)
|
|
52
57
|
- [ListDerived](#listderived)
|
|
53
58
|
- [ListSignal](#listsignal)
|
|
59
|
+
- [LitExp](#litexp)
|
|
54
60
|
- [Paths](#paths)
|
|
55
61
|
- [QChannel](#qchannel)
|
|
56
62
|
- [SafeExit](#safeexit)
|
|
57
63
|
- [Setup](#setup)
|
|
58
64
|
- [Signal](#signal)
|
|
59
65
|
- [WorkerMainThread](#workermainthread)
|
|
60
|
-
- [
|
|
66
|
+
- [Base64URL](#base64url)
|
|
61
67
|
- [Base64URLFromFile](#base64urlfromfile)
|
|
62
68
|
- [EventNameSpace](#eventnamespace)
|
|
63
69
|
- [JSautoDOC](#jsautodoc)
|
|
64
|
-
- [
|
|
65
|
-
- [ExtnameType](#extnametype)
|
|
66
|
-
- [IsListSignal](#islistsignal)
|
|
67
|
-
- [LitExp](#litexp)
|
|
68
|
-
- [ListArg](#listarg)
|
|
69
|
-
- [LitExpKeyType](#litexpkeytype)
|
|
70
|
-
- [MutationType](#mutationtype)
|
|
71
|
-
- [QCBFIFOReturn](#qcbfiforeturn)
|
|
72
|
-
- [QCBReturn](#qcbreturn)
|
|
73
|
-
- [Runtime](#runtime)
|
|
70
|
+
- [CreateImmutable](#createimmutable)
|
|
74
71
|
- [EventCheck](#eventcheck)
|
|
75
72
|
- [EventObject](#eventobject)
|
|
76
|
-
- [IsAsync](#isasync)
|
|
77
73
|
- [GetRuntime](#getruntime)
|
|
74
|
+
- [IsAsync](#isasync)
|
|
78
75
|
- [LazyFactory](#lazyfactory)
|
|
79
76
|
- [Timeout](#timeout)
|
|
80
77
|
- [Try](#try)
|
|
81
78
|
- [TryAsync](#tryasync)
|
|
82
79
|
- [TrySync](#trysync)
|
|
83
80
|
- [TsToMjs](#tstomjs)
|
|
84
|
-
- [
|
|
85
|
-
- [
|
|
81
|
+
- [AnyButUndefined](#anybutundefined)
|
|
82
|
+
- [ExtnameType](#extnametype)
|
|
83
|
+
- [IsListSignal](#islistsignal)
|
|
84
|
+
- [ListArg](#listarg)
|
|
85
|
+
- [LitExpKeyType](#litexpkeytype)
|
|
86
|
+
- [LitExpResultType](#litexpresulttype)
|
|
87
|
+
- [MutationType](#mutationtype)
|
|
88
|
+
- [QCBFIFOReturn](#qcbfiforeturn)
|
|
89
|
+
- [QCBReturn](#qcbreturn)
|
|
90
|
+
- [Runtime](#runtime)
|
|
86
91
|
- [WorkerResult](#workerresult)
|
|
87
92
|
- [WorkerThread](#workerthread)
|
|
88
93
|
- [ToBundledJSPlugin](#tobundledjsplugin)
|
|
89
94
|
|
|
95
|
+
<h2 id="compilejs">CompileJS</h2>
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
#### reference:`CompileJS`
|
|
99
|
+
- function to compile `.ts`|`.mts`|`.mjs` file, into a single executable;
|
|
100
|
+
- also generate js representation;
|
|
101
|
+
- uses [pkg](https://www.npmjs.com/package/pkg), [bun](https://bun.com/docs/bundler/executables), and [deno](https://docs.deno.com/runtime/reference/cli/compile/) compiler under the hood;
|
|
102
|
+
>- they are used only as packaging agent, and doesn't necessarily supports their advanced feature, such as, assets bundling(use [FSInline](#fsinline) instead);
|
|
103
|
+
>- `WorkerThread` will be converted to inline using `FSInline` too;
|
|
104
|
+
|
|
105
|
+
!!!WARNING!!!
|
|
106
|
+
!!!WARNING!!!
|
|
107
|
+
!!!WARNING!!!
|
|
108
|
+
|
|
109
|
+
- This function does not obfuscate and will not prevent decompilation. Do not embed environment variables or sensitive information inside `options.entryPoint`;
|
|
110
|
+
- It is designed for quick binarization, allowing execution on machines without `Node.js`, `Bun`, or `Deno` installed;
|
|
111
|
+
- The resulting binary will contain `FSInline` and `WorkerMainThread` target paths Buffers, which are loaded into memory at runtime. If your logic depends on the file system, use `node:fs` or `node:fs/promises` APIs and ship external files alongside the binary (not compiled);
|
|
112
|
+
|
|
113
|
+
!!!WARNING!!!
|
|
114
|
+
!!!WARNING!!!
|
|
115
|
+
!!!WARNING!!!
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
/**
|
|
119
|
+
* @param {Object} options
|
|
120
|
+
* @param {string} options.entryPoint
|
|
121
|
+
* - need to be manually prefixed;
|
|
122
|
+
* @param {BufferEncoding} [options.encoding]
|
|
123
|
+
* - write and read encoding for the sources;
|
|
124
|
+
* - default: `utf-8`;
|
|
125
|
+
* @param {boolean} options.minifyFirst
|
|
126
|
+
* - minify the bundle before compilation;
|
|
127
|
+
* @param {string} options.outDir
|
|
128
|
+
* - need manual prefix;
|
|
129
|
+
* @param {'pkg'|'bun'|'deno'} [options.compiler]
|
|
130
|
+
* - default: no comilation, just bundling;
|
|
131
|
+
* - `bun` and `pkg` is checked, if there's bug on `deno`, please report on github for issues;
|
|
132
|
+
* @param {Record<string, string>} [options.compilerArguments]
|
|
133
|
+
* - `key` are to used as `--keyName`;
|
|
134
|
+
* - value are the following value of the key;
|
|
135
|
+
* - no need to add the output/outdir, as it use the `options.outDir`;
|
|
136
|
+
* @param {ReturnType<CreateESPlugin>[]} [options.esBundlerPlugins]
|
|
137
|
+
* - plugins for `EsBundler`;
|
|
138
|
+
* @return {ReturnType<typeof TryAsync<{compileResult:Promise<any>|undefined,
|
|
139
|
+
* commandCalled: string|undefined;
|
|
140
|
+
* compiledBinFile: string|undefined;
|
|
141
|
+
* bundledJSFile:string|undefined
|
|
142
|
+
* }>>}
|
|
143
|
+
*/
|
|
144
|
+
```
|
|
145
|
+
- <i>example</i>:
|
|
146
|
+
```js
|
|
147
|
+
import { join } from 'node:path';
|
|
148
|
+
|
|
149
|
+
import { CompileJS, Paths } from 'vivth';
|
|
150
|
+
|
|
151
|
+
const [[resultPkg, errorPkg], [resultBun, errorBun]] = await Promise.all([
|
|
152
|
+
CompileJS({
|
|
153
|
+
entryPoint: join(Paths.root, '/dev'),
|
|
154
|
+
minifyFirst: true,
|
|
155
|
+
outDir: join(Paths.root, '/dev-pkg'),
|
|
156
|
+
compiler: 'pkg',
|
|
157
|
+
compilerArguments: {
|
|
158
|
+
target: ['node18-win-x64'],
|
|
159
|
+
},
|
|
160
|
+
esBundlerPlugins: [],
|
|
161
|
+
}),
|
|
162
|
+
CompileJS({
|
|
163
|
+
entryPoint: join(Paths.root, '/dev'),
|
|
164
|
+
minifyFirst: true,
|
|
165
|
+
outDir: join(Paths.root, '/dev-pkg'),
|
|
166
|
+
compiler: 'bun',
|
|
167
|
+
compilerArguments: {
|
|
168
|
+
target: ['bun-win-x64'],
|
|
169
|
+
},
|
|
170
|
+
esBundlerPlugins: [],
|
|
171
|
+
}),
|
|
172
|
+
])
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
177
|
+
|
|
90
178
|
<h2 id="createesplugin">CreateESPlugin</h2>
|
|
91
179
|
|
|
92
180
|
|
|
@@ -248,84 +336,86 @@ npm i vivth
|
|
|
248
336
|
|
|
249
337
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
250
338
|
|
|
251
|
-
<h2 id="
|
|
339
|
+
<h2 id="console">Console</h2>
|
|
252
340
|
|
|
253
341
|
|
|
254
|
-
#### reference:`
|
|
255
|
-
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
342
|
+
#### reference:`Console`
|
|
343
|
+
- class with static methods to print to standard console with bare minimum ANSI styles;
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
#### reference:`Console.log`
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
```js
|
|
350
|
+
/**
|
|
351
|
+
* @param {any} data
|
|
352
|
+
* @returns {void}
|
|
353
|
+
*/
|
|
354
|
+
```
|
|
355
|
+
- <i>example</i>:
|
|
356
|
+
```js
|
|
357
|
+
import { Console } from 'vivth';
|
|
358
|
+
|
|
359
|
+
Console.log({
|
|
360
|
+
hello: 'world!!',
|
|
361
|
+
});
|
|
260
362
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
#### reference:`Console.info`
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
```js
|
|
369
|
+
/**
|
|
370
|
+
* @param {any} data
|
|
371
|
+
* @returns {void}
|
|
372
|
+
*/
|
|
373
|
+
```
|
|
374
|
+
- <i>example</i>:
|
|
375
|
+
```js
|
|
376
|
+
import { Console } from 'vivth';
|
|
377
|
+
|
|
378
|
+
Console.info({
|
|
379
|
+
hello: 'world!!',
|
|
380
|
+
});
|
|
264
381
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
#### reference:`Console.warn`
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
```js
|
|
388
|
+
/**
|
|
389
|
+
* @param {any} data
|
|
390
|
+
* @returns {void}
|
|
391
|
+
*/
|
|
392
|
+
```
|
|
393
|
+
- <i>example</i>:
|
|
394
|
+
```js
|
|
395
|
+
import { Console } from 'vivth';
|
|
396
|
+
|
|
397
|
+
Console.warn({
|
|
398
|
+
hello: 'world!!',
|
|
399
|
+
});
|
|
268
400
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
#### reference:`Console.error`
|
|
404
|
+
|
|
272
405
|
|
|
273
406
|
```js
|
|
274
407
|
/**
|
|
275
|
-
* @param {
|
|
276
|
-
* @
|
|
277
|
-
* - need to be manually prefixed;
|
|
278
|
-
* @param {BufferEncoding} [options.encoding]
|
|
279
|
-
* - write and read encoding for the sources;
|
|
280
|
-
* - default: `utf-8`;
|
|
281
|
-
* @param {boolean} options.minifyFirst
|
|
282
|
-
* - minify the bundle before compilation;
|
|
283
|
-
* @param {string} options.outDir
|
|
284
|
-
* - need manual prefix;
|
|
285
|
-
* @param {'pkg'|'bun'|'deno'} [options.compiler]
|
|
286
|
-
* - default: no comilation, just bundling;
|
|
287
|
-
* - `bun` and `pkg` is checked, if there's bug on `deno`, please report on github for issues;
|
|
288
|
-
* @param {Record<string, string>} [options.compilerArguments]
|
|
289
|
-
* - `key` are to used as `--keyName`;
|
|
290
|
-
* - value are the following value of the key;
|
|
291
|
-
* - no need to add the output/outdir, as it use the `options.outDir`;
|
|
292
|
-
* @param {ReturnType<CreateESPlugin>[]} [options.esBundlerPlugins]
|
|
293
|
-
* - plugins for `EsBundler`;
|
|
294
|
-
* @return {ReturnType<TryAsync<{compileResult:Promise<any>,
|
|
295
|
-
* commandCalled: string;
|
|
296
|
-
* compiledBinFile: string;
|
|
297
|
-
* bundledJSFile:string
|
|
298
|
-
* }>>}
|
|
408
|
+
* @param {any} data
|
|
409
|
+
* @returns {void}
|
|
299
410
|
*/
|
|
300
411
|
```
|
|
301
412
|
- <i>example</i>:
|
|
302
|
-
```js
|
|
303
|
-
import {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
CompileJS({
|
|
309
|
-
entryPoint: join(Paths.root, '/dev'),
|
|
310
|
-
minifyFirst: true,
|
|
311
|
-
outDir: join(Paths.root, '/dev-pkg'),
|
|
312
|
-
compiler: 'pkg',
|
|
313
|
-
compilerArguments: {
|
|
314
|
-
target: ['node18-win-x64'],
|
|
315
|
-
},
|
|
316
|
-
esBundlerPlugins: [],
|
|
317
|
-
}),
|
|
318
|
-
CompileJS({
|
|
319
|
-
entryPoint: join(Paths.root, '/dev'),
|
|
320
|
-
minifyFirst: true,
|
|
321
|
-
outDir: join(Paths.root, '/dev-pkg'),
|
|
322
|
-
compiler: 'bun',
|
|
323
|
-
compilerArguments: {
|
|
324
|
-
target: ['bun-win-x64'],
|
|
325
|
-
},
|
|
326
|
-
esBundlerPlugins: [],
|
|
327
|
-
}),
|
|
328
|
-
])
|
|
413
|
+
```js
|
|
414
|
+
import { Console } from 'vivth';
|
|
415
|
+
|
|
416
|
+
Console.error({
|
|
417
|
+
hello: 'world!!',
|
|
418
|
+
});
|
|
329
419
|
|
|
330
420
|
```
|
|
331
421
|
|
|
@@ -350,7 +440,7 @@ npm i vivth
|
|
|
350
440
|
```js
|
|
351
441
|
/**
|
|
352
442
|
* @param {(effectInstanceOptions:Omit<Effect["options"] &
|
|
353
|
-
* Derived["options"], unwrapLazy>) =>
|
|
443
|
+
* Derived<VALUE>["options"], unwrapLazy>) =>
|
|
354
444
|
* Promise<VALUE>} derivedFunction
|
|
355
445
|
*/
|
|
356
446
|
```
|
|
@@ -412,11 +502,13 @@ npm i vivth
|
|
|
412
502
|
|
|
413
503
|
#### reference:`Derived_instance.value:getter`
|
|
414
504
|
- the most recent value of the instance
|
|
415
|
-
- can be turn into reactive with Effect or Derived instantiation;
|
|
505
|
+
- can be turn into reactive with Effect or Derived instantiation;
|
|
506
|
+
- initial value are always `undefined`, make sure to put a check before consuming(inside an `Effect`);
|
|
416
507
|
|
|
417
508
|
```js
|
|
418
509
|
/**
|
|
419
|
-
* @returns {VALUE}
|
|
510
|
+
* @returns {VALUE}
|
|
511
|
+
* @override
|
|
420
512
|
*/
|
|
421
513
|
```
|
|
422
514
|
|
|
@@ -427,7 +519,8 @@ npm i vivth
|
|
|
427
519
|
```js
|
|
428
520
|
/**
|
|
429
521
|
* @private
|
|
430
|
-
* @type {VALUE}
|
|
522
|
+
* @type {VALUE}
|
|
523
|
+
* @override
|
|
431
524
|
*/
|
|
432
525
|
```
|
|
433
526
|
|
|
@@ -484,9 +577,9 @@ npm i vivth
|
|
|
484
577
|
|
|
485
578
|
```js
|
|
486
579
|
/**
|
|
487
|
-
* @template
|
|
488
|
-
* @param {
|
|
489
|
-
* @returns {
|
|
580
|
+
* @template V
|
|
581
|
+
* @param {Signal<V>} signal
|
|
582
|
+
* @returns {Signal<V>}
|
|
490
583
|
*/
|
|
491
584
|
```
|
|
492
585
|
- <i>example</i>:
|
|
@@ -574,7 +667,6 @@ npm i vivth
|
|
|
574
667
|
|
|
575
668
|
|
|
576
669
|
#### reference:`EnvSignal`
|
|
577
|
-
- non browser API;
|
|
578
670
|
- uses [Signal](#signal) and [Derived](#derived) under the hood;
|
|
579
671
|
|
|
580
672
|
```js
|
|
@@ -656,7 +748,7 @@ npm i vivth
|
|
|
656
748
|
|
|
657
749
|
```js
|
|
658
750
|
/**
|
|
659
|
-
* @type {Map<string, EventSignal
|
|
751
|
+
* @type {Map<string, EventSignal<any>>}
|
|
660
752
|
*/
|
|
661
753
|
```
|
|
662
754
|
|
|
@@ -669,7 +761,7 @@ npm i vivth
|
|
|
669
761
|
/**
|
|
670
762
|
* @param {string} stringName
|
|
671
763
|
* @param {IsListSignal} [isList_]
|
|
672
|
-
* @returns {Promise<EventSignal
|
|
764
|
+
* @returns {Promise<EventSignal<any>>}
|
|
673
765
|
*/
|
|
674
766
|
```
|
|
675
767
|
- <i>example</i>:
|
|
@@ -687,7 +779,7 @@ npm i vivth
|
|
|
687
779
|
|
|
688
780
|
```js
|
|
689
781
|
/**
|
|
690
|
-
* @type {Signal
|
|
782
|
+
* @type {Signal<any>|ListSignal<any>}
|
|
691
783
|
*/
|
|
692
784
|
```
|
|
693
785
|
- <i>example</i>:
|
|
@@ -712,7 +804,7 @@ npm i vivth
|
|
|
712
804
|
|
|
713
805
|
```js
|
|
714
806
|
/**
|
|
715
|
-
* @type {Derived
|
|
807
|
+
* @type {Derived<any>|ListDerived<any>}
|
|
716
808
|
*/
|
|
717
809
|
```
|
|
718
810
|
- <i>example</i>:
|
|
@@ -959,7 +1051,7 @@ npm i vivth
|
|
|
959
1051
|
/**
|
|
960
1052
|
* @param {Parameters<mkdir>[0]} outDir
|
|
961
1053
|
* - absolute path
|
|
962
|
-
* @returns {ReturnType<typeof TryAsync<string>>}
|
|
1054
|
+
* @returns {ReturnType<typeof TryAsync<string|undefined>>}
|
|
963
1055
|
*/
|
|
964
1056
|
```
|
|
965
1057
|
- <i>example</i>:
|
|
@@ -1067,7 +1159,8 @@ npm i vivth
|
|
|
1067
1159
|
|
|
1068
1160
|
```js
|
|
1069
1161
|
/**
|
|
1070
|
-
* @returns {LISTARG[]}
|
|
1162
|
+
* @returns {LISTARG[]}
|
|
1163
|
+
* @override
|
|
1071
1164
|
*/
|
|
1072
1165
|
```
|
|
1073
1166
|
|
|
@@ -1077,7 +1170,8 @@ npm i vivth
|
|
|
1077
1170
|
```js
|
|
1078
1171
|
/**
|
|
1079
1172
|
* @private
|
|
1080
|
-
* @type {LISTARG[]}
|
|
1173
|
+
* @type {LISTARG[]}
|
|
1174
|
+
* @override
|
|
1081
1175
|
*/
|
|
1082
1176
|
```
|
|
1083
1177
|
|
|
@@ -1216,16 +1310,237 @@ npm i vivth
|
|
|
1216
1310
|
|
|
1217
1311
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
1218
1312
|
|
|
1219
|
-
<h2 id="
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
#### reference:`Paths`
|
|
1223
|
-
- class helpers to define pathReference;
|
|
1224
|
-
- is a singleton;
|
|
1225
|
-
- most of functionality need to access `Paths.root`, if you get warning, you can instantiate `Paths` before running anything;
|
|
1226
|
-
|
|
1313
|
+
<h2 id="litexp">LitExp</h2>
|
|
1227
1314
|
|
|
1228
|
-
|
|
1315
|
+
|
|
1316
|
+
#### reference:`LitExp`
|
|
1317
|
+
- class helper to created opionated regex helper;
|
|
1318
|
+
- named capture uses `es6+` feature, you might need to add polyfill to target extremely old browser;
|
|
1319
|
+
- class name refer to `Literal Expression`;
|
|
1320
|
+
- please be patient when using this class;
|
|
1321
|
+
>- destructuring is meant for extensive typehelper;
|
|
1322
|
+
>- and destructuring can lead to unhandled error here and there;
|
|
1323
|
+
>- therefore error as value is introduced to help to prevent error on runtime;
|
|
1324
|
+
|
|
1325
|
+
```js
|
|
1326
|
+
/**
|
|
1327
|
+
* @template {LitExpKeyType} KEYS
|
|
1328
|
+
*/
|
|
1329
|
+
```
|
|
1330
|
+
|
|
1331
|
+
#### reference:`LitExp.escape`
|
|
1332
|
+
- to escape special chars from string literal;
|
|
1333
|
+
- returned value can be used to create instance of RegExp;
|
|
1334
|
+
|
|
1335
|
+
```js
|
|
1336
|
+
/**
|
|
1337
|
+
* @param {string} string
|
|
1338
|
+
* @returns {string}
|
|
1339
|
+
*/
|
|
1340
|
+
```
|
|
1341
|
+
- <i>example</i>:
|
|
1342
|
+
```js
|
|
1343
|
+
import { LitExp } from 'vivt';
|
|
1344
|
+
|
|
1345
|
+
const escapedLiteral = LitExp.escape(`something[][;alerk325]`);
|
|
1346
|
+
new RegExp(escapedLiteral, 'g');
|
|
1347
|
+
|
|
1348
|
+
```
|
|
1349
|
+
|
|
1350
|
+
#### reference:`LitExp.prepare`
|
|
1351
|
+
- constructor helper;
|
|
1352
|
+
- under the hood it is an abstraction of `RegExp`, with more template literal touch;
|
|
1353
|
+
>- you can apply inline `RegExp` features on the string template literal(as constructor RegExp arg0);
|
|
1354
|
+
>>- by doing so you are opting in to make:
|
|
1355
|
+
>>>- your regex detection more robust; but
|
|
1356
|
+
>>>- `litExp_instance.make.string` to be `unusable`;
|
|
1357
|
+
>>- also mind the needs of escape for special characters;
|
|
1358
|
+
|
|
1359
|
+
```js
|
|
1360
|
+
/**
|
|
1361
|
+
* @template {LitExpKeyType} KEYS
|
|
1362
|
+
* @param {KEYS} keysAndDefaultValuePair
|
|
1363
|
+
* - keys and whether to override regex detection;
|
|
1364
|
+
* >- example:
|
|
1365
|
+
* ```js
|
|
1366
|
+
* myKey: /myCustomCapture/ // all flags will be stripped;
|
|
1367
|
+
* ```
|
|
1368
|
+
* - default value === `false` is "[\\s\\S]
|
|
1369
|
+
*?", as in whiteSpace and nonWhiteSpace 0 to more occurence;
|
|
1370
|
+
* @returns {ReturnType<typeof TrySync<(templateStringArray:TemplateStringsArray,
|
|
1371
|
+
* ...values:(keyof KEYS)[]
|
|
1372
|
+
* )=>LitExp<KEYS>>>}
|
|
1373
|
+
* - placement of `key` will determine the named capture group will be placed in the template literal;
|
|
1374
|
+
* - it is recomended to not end template literal with any of the `key`s as the regex detection might failed to detects the boundary of the end of matched string of that capture group;
|
|
1375
|
+
*/
|
|
1376
|
+
```
|
|
1377
|
+
- <i>example</i>:
|
|
1378
|
+
```js
|
|
1379
|
+
import { LitExp } from 'vivth';
|
|
1380
|
+
|
|
1381
|
+
(()=>{
|
|
1382
|
+
const [liteal, errorPrep] = LitExp.prepare({
|
|
1383
|
+
myKey: /myCustomCapture/, // is placed on (?<myKey>myCustomCapture)
|
|
1384
|
+
// use false to place "[\\s\\S]*?" instead;
|
|
1385
|
+
...keyCaptureLogicPair
|
|
1386
|
+
})
|
|
1387
|
+
if (errorPrep) {
|
|
1388
|
+
console.error(error);
|
|
1389
|
+
return;
|
|
1390
|
+
}
|
|
1391
|
+
const litExp_instance = liteal`templateLiteral:${'myKey'};`
|
|
1392
|
+
// recommended to end the template literal with any string but `key`;
|
|
1393
|
+
})()
|
|
1394
|
+
|
|
1395
|
+
```
|
|
1396
|
+
|
|
1397
|
+
#### reference:`LitExp_instance.make`
|
|
1398
|
+
- instance methods for generating things;
|
|
1399
|
+
|
|
1400
|
+
|
|
1401
|
+
#### reference:`LitExp_instance.make.string`
|
|
1402
|
+
- to make string based on the template literal;
|
|
1403
|
+
|
|
1404
|
+
```js
|
|
1405
|
+
/**
|
|
1406
|
+
* @param {Partial<{ [K in keyof KEYS]?: string }>} overrides
|
|
1407
|
+
* @returns {string|undefined}
|
|
1408
|
+
*/
|
|
1409
|
+
```
|
|
1410
|
+
- <i>example</i>:
|
|
1411
|
+
```js
|
|
1412
|
+
import { LitExp } from 'vivth';
|
|
1413
|
+
|
|
1414
|
+
const [literal, errorPreparing] = LitExp.prepare({
|
|
1415
|
+
myKey: false,
|
|
1416
|
+
...keyCaptureLogicPair
|
|
1417
|
+
})
|
|
1418
|
+
|
|
1419
|
+
// asuming no error
|
|
1420
|
+
litExp_instance = `templateLiteral:${'myKey'};`;
|
|
1421
|
+
const [result, error] = litExp_instance.make.string({
|
|
1422
|
+
myKey: 'actualvalue',
|
|
1423
|
+
});
|
|
1424
|
+
|
|
1425
|
+
console.log(result); // "templateLiteral:actualvalue;"
|
|
1426
|
+
|
|
1427
|
+
```
|
|
1428
|
+
|
|
1429
|
+
#### reference:`LitExp_instance.evaluate`
|
|
1430
|
+
- methods collections to evaluate string with `Literal Expression`;
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
#### reference:`LitExp_instance.evaluate.execGroups`
|
|
1434
|
+
- to exec and grouped based on `key`;
|
|
1435
|
+
|
|
1436
|
+
```js
|
|
1437
|
+
/**
|
|
1438
|
+
* @param {string} string
|
|
1439
|
+
* @param {Object} options
|
|
1440
|
+
* @param {ConstructorParameters<typeof RegExp>[1]} options.flags
|
|
1441
|
+
* @param {boolean} options.whiteSpaceSensitive
|
|
1442
|
+
* - true: leave any whitespace as is to be used as regex detection;
|
|
1443
|
+
* - false: convert all whitespace to `\s+`;
|
|
1444
|
+
* @param {boolean} options.absoluteLeadAndFollowing
|
|
1445
|
+
* - false: standard capture;
|
|
1446
|
+
* - true: add `^` and `<h2 id="litexp">LitExp</h2>
|
|
1447
|
+
|
|
1448
|
+
to capture definition:
|
|
1449
|
+
* >- meaning string will have to match starting and end of line from capture definition;
|
|
1450
|
+
* @returns {ReturnType<typeof TrySync<{
|
|
1451
|
+
* result:{ whole:string, named: Record<keyof KEYS, string>},
|
|
1452
|
+
* regexp:RegExp}>>
|
|
1453
|
+
* }
|
|
1454
|
+
*/
|
|
1455
|
+
```
|
|
1456
|
+
- <i>example</i>:
|
|
1457
|
+
```js
|
|
1458
|
+
import { LitExp } from 'vivth';
|
|
1459
|
+
|
|
1460
|
+
const [literal, errorPreparing] = LitExp.prepare({
|
|
1461
|
+
myKey: false,
|
|
1462
|
+
...keyCaptureLogicPair
|
|
1463
|
+
})
|
|
1464
|
+
|
|
1465
|
+
// asuming no eror
|
|
1466
|
+
const litExp_instance = literal`templateLiteral:${'myKey'};`
|
|
1467
|
+
|
|
1468
|
+
const [{
|
|
1469
|
+
result:{ // asuming there's no error
|
|
1470
|
+
named: { myKey },
|
|
1471
|
+
whole,
|
|
1472
|
+
},
|
|
1473
|
+
regex, // for reference
|
|
1474
|
+
}, error] = litExp_instance.evaluate.execGroups(
|
|
1475
|
+
`templateLiteral:Something;`,
|
|
1476
|
+
{ ...options }
|
|
1477
|
+
)
|
|
1478
|
+
|
|
1479
|
+
console.log(whole); // "templateLiteral:Something;"
|
|
1480
|
+
console.log(myKey); // "Something"
|
|
1481
|
+
|
|
1482
|
+
```
|
|
1483
|
+
|
|
1484
|
+
#### reference:`LitExp_instance.evaluate.matchedAllAndGrouped`
|
|
1485
|
+
- to match all and grouped based on `key`;
|
|
1486
|
+
|
|
1487
|
+
```js
|
|
1488
|
+
/**
|
|
1489
|
+
* @param {Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[0]} string
|
|
1490
|
+
* @param {Omit<Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[1], 'absoluteLeadAndFollowing'>} options
|
|
1491
|
+
* @returns {ReturnType<typeof TrySync<import('../types/LitExpResultType.mjs').LitExpResultType<KEYS>>>
|
|
1492
|
+
* }
|
|
1493
|
+
*/
|
|
1494
|
+
```
|
|
1495
|
+
- <i>example</i>:
|
|
1496
|
+
```js
|
|
1497
|
+
import { LitExp, Console } from 'vivth';
|
|
1498
|
+
|
|
1499
|
+
const [literal, errorPreparing] = LitExp.prepare({
|
|
1500
|
+
myKey: false,
|
|
1501
|
+
...keyCaptureLogicPair
|
|
1502
|
+
})
|
|
1503
|
+
|
|
1504
|
+
// asuming no error;
|
|
1505
|
+
litExp_instance = literal`templateLiteral:${'myKey'};`
|
|
1506
|
+
|
|
1507
|
+
const [resultOfMatchedAllAndGrouped, error] = litExp_instance.evaluate.matchedAllAndGrouped(
|
|
1508
|
+
`templateLiteral:Something;
|
|
1509
|
+
templateLiteral:SomethingElse;`,
|
|
1510
|
+
{ ...options }
|
|
1511
|
+
)
|
|
1512
|
+
(()=>{
|
|
1513
|
+
if (error) {
|
|
1514
|
+
Console.error(error);
|
|
1515
|
+
return;
|
|
1516
|
+
}
|
|
1517
|
+
const {
|
|
1518
|
+
result: { whole, named },
|
|
1519
|
+
regexp
|
|
1520
|
+
} = resultOfMatchedAllAndGrouped;
|
|
1521
|
+
|
|
1522
|
+
named.foreach(({myKey})=>{
|
|
1523
|
+
// code
|
|
1524
|
+
})
|
|
1525
|
+
whole.foreach((capturedString)=>{
|
|
1526
|
+
// code
|
|
1527
|
+
})
|
|
1528
|
+
})()
|
|
1529
|
+
|
|
1530
|
+
```
|
|
1531
|
+
|
|
1532
|
+
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
1533
|
+
|
|
1534
|
+
<h2 id="paths">Paths</h2>
|
|
1535
|
+
|
|
1536
|
+
|
|
1537
|
+
#### reference:`Paths`
|
|
1538
|
+
- class helpers to define pathReference;
|
|
1539
|
+
- is a singleton;
|
|
1540
|
+
- most of functionality need to access `Paths.root`, if you get warning, you can instantiate `Paths` before running anything;
|
|
1541
|
+
|
|
1542
|
+
|
|
1543
|
+
#### reference:`new Paths`
|
|
1229
1544
|
|
|
1230
1545
|
|
|
1231
1546
|
```js
|
|
@@ -1269,7 +1584,7 @@ npm i vivth
|
|
|
1269
1584
|
|
|
1270
1585
|
```js
|
|
1271
1586
|
/**
|
|
1272
|
-
* @type {string}
|
|
1587
|
+
* @type {string|undefined}
|
|
1273
1588
|
*/
|
|
1274
1589
|
```
|
|
1275
1590
|
|
|
@@ -1473,7 +1788,7 @@ npm i vivth
|
|
|
1473
1788
|
|
|
1474
1789
|
```js
|
|
1475
1790
|
/**
|
|
1476
|
-
* @type {SafeExit}
|
|
1791
|
+
* @type {SafeExit|undefined}
|
|
1477
1792
|
*/
|
|
1478
1793
|
```
|
|
1479
1794
|
|
|
@@ -1765,7 +2080,7 @@ npm i vivth
|
|
|
1765
2080
|
|
|
1766
2081
|
```js
|
|
1767
2082
|
/**
|
|
1768
|
-
* @returns {VALUE}
|
|
2083
|
+
* @returns {VALUE|undefined}
|
|
1769
2084
|
*/
|
|
1770
2085
|
```
|
|
1771
2086
|
|
|
@@ -1823,7 +2138,7 @@ npm i vivth
|
|
|
1823
2138
|
|
|
1824
2139
|
```js
|
|
1825
2140
|
/**
|
|
1826
|
-
* @template {WorkerThread} WT
|
|
2141
|
+
* @template {WorkerThread<any, any>} WT
|
|
1827
2142
|
*/
|
|
1828
2143
|
```
|
|
1829
2144
|
|
|
@@ -1957,86 +2272,34 @@ npm i vivth
|
|
|
1957
2272
|
|
|
1958
2273
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
1959
2274
|
|
|
1960
|
-
<h2 id="
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
#### reference:`Console`
|
|
1964
|
-
- class with static methods to print to standard console with bare minimum ANSI styles;
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
#### reference:`Console.log`
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
```js
|
|
1971
|
-
/**
|
|
1972
|
-
* @param {any} data
|
|
1973
|
-
* @returns {void}
|
|
1974
|
-
*/
|
|
1975
|
-
```
|
|
1976
|
-
- <i>example</i>:
|
|
1977
|
-
```js
|
|
1978
|
-
import { Console } from 'vivth';
|
|
1979
|
-
|
|
1980
|
-
Console.log({
|
|
1981
|
-
hello: 'world!!',
|
|
1982
|
-
});
|
|
1983
|
-
|
|
1984
|
-
```
|
|
1985
|
-
|
|
1986
|
-
#### reference:`Console.info`
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
```js
|
|
1990
|
-
/**
|
|
1991
|
-
* @param {any} data
|
|
1992
|
-
* @returns {void}
|
|
1993
|
-
*/
|
|
1994
|
-
```
|
|
1995
|
-
- <i>example</i>:
|
|
1996
|
-
```js
|
|
1997
|
-
import { Console } from 'vivth';
|
|
1998
|
-
|
|
1999
|
-
Console.info({
|
|
2000
|
-
hello: 'world!!',
|
|
2001
|
-
});
|
|
2002
|
-
|
|
2003
|
-
```
|
|
2004
|
-
|
|
2005
|
-
#### reference:`Console.warn`
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
```js
|
|
2009
|
-
/**
|
|
2010
|
-
* @param {any} data
|
|
2011
|
-
* @returns {void}
|
|
2012
|
-
*/
|
|
2013
|
-
```
|
|
2014
|
-
- <i>example</i>:
|
|
2015
|
-
```js
|
|
2016
|
-
import { Console } from 'vivth';
|
|
2017
|
-
|
|
2018
|
-
Console.warn({
|
|
2019
|
-
hello: 'world!!',
|
|
2020
|
-
});
|
|
2021
|
-
|
|
2022
|
-
```
|
|
2275
|
+
<h2 id="base64url">Base64URL</h2>
|
|
2023
2276
|
|
|
2024
|
-
#### reference:`Console.error`
|
|
2025
2277
|
|
|
2278
|
+
#### reference:`Base64URL`
|
|
2279
|
+
- create inline base64 url;
|
|
2280
|
+
- usage:
|
|
2281
|
+
>- can be extremely usefull to display file on desktop app webview, without exposing http server;
|
|
2026
2282
|
|
|
2027
2283
|
```js
|
|
2028
2284
|
/**
|
|
2029
|
-
* @param {
|
|
2030
|
-
* @
|
|
2285
|
+
* @param {string} fileString
|
|
2286
|
+
* @param {string} mimeType
|
|
2287
|
+
* @param {(string:string)=>string} btoaFunction
|
|
2288
|
+
* - check your js runtime `btoa`;
|
|
2289
|
+
* - node compatible:
|
|
2290
|
+
* ```js
|
|
2291
|
+
* (str, prevBufferEncoding) =>
|
|
2292
|
+
* Buffer.from(str, prevBufferEncoding).toString('base64')
|
|
2293
|
+
* ```
|
|
2294
|
+
* @returns {string}
|
|
2031
2295
|
*/
|
|
2032
2296
|
```
|
|
2033
2297
|
- <i>example</i>:
|
|
2034
|
-
```js
|
|
2035
|
-
import {
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
});
|
|
2298
|
+
```js
|
|
2299
|
+
import { Base64URL } from 'vivth'
|
|
2300
|
+
import fileString from './fileString.mjs';
|
|
2301
|
+
|
|
2302
|
+
Base64URL(fileString, 'application/javascript', btoa);
|
|
2040
2303
|
|
|
2041
2304
|
```
|
|
2042
2305
|
|
|
@@ -2054,7 +2317,7 @@ npm i vivth
|
|
|
2054
2317
|
```js
|
|
2055
2318
|
/**
|
|
2056
2319
|
* @param {string} filePath
|
|
2057
|
-
* @returns {Promise<
|
|
2320
|
+
* @returns {Promise<string>}
|
|
2058
2321
|
*/
|
|
2059
2322
|
```
|
|
2060
2323
|
- <i>example</i>:
|
|
@@ -2101,7 +2364,11 @@ npm i vivth
|
|
|
2101
2364
|
>>- `"at"description` are treated as plain `markdown`;
|
|
2102
2365
|
>>- first `"at"${string}` after `"at"description` until `"at"example` will be treated as `javascript` comment block on the `markdown`;
|
|
2103
2366
|
>>- `"at"example` are treated as `javascript` block on the `markdown` file, and should be placed last on the same comment block;
|
|
2104
|
-
>>- you can always look at `vivth/src` files to check how the source, and the `README.md` and `index.mjs` documentation/generation results;
|
|
2367
|
+
>>- you can always look at `vivth/src` files to check how the source, and the `README.md` and `index.mjs` documentation/generation results;
|
|
2368
|
+
>6) this types of arrow functions will be converted to regullar function, for concise type emition:
|
|
2369
|
+
>>- validly exported function;
|
|
2370
|
+
>>- static/instance method(s) with generic template;
|
|
2371
|
+
>7) transpile `.ts` and `.mts` to `.mjs` same name and directory;
|
|
2105
2372
|
|
|
2106
2373
|
|
|
2107
2374
|
#### reference:`new JSautoDOC`
|
|
@@ -2111,11 +2378,11 @@ npm i vivth
|
|
|
2111
2378
|
/**
|
|
2112
2379
|
* @param {Object} [options]
|
|
2113
2380
|
* @param {Object} [options.paths]
|
|
2114
|
-
* @param {string}
|
|
2381
|
+
* @param {string} options.paths.file
|
|
2115
2382
|
* - entry point;
|
|
2116
|
-
* @param {string}
|
|
2383
|
+
* @param {string} options.paths.readMe
|
|
2117
2384
|
* - readme target;
|
|
2118
|
-
* @param {string}
|
|
2385
|
+
* @param {string} options.paths.dir
|
|
2119
2386
|
* - source directory;
|
|
2120
2387
|
* @param {string} [options.copyright]
|
|
2121
2388
|
* @param {string} [options.tableOfContentTitle]
|
|
@@ -2137,323 +2404,43 @@ npm i vivth
|
|
|
2137
2404
|
|
|
2138
2405
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2139
2406
|
|
|
2140
|
-
<h2 id="
|
|
2407
|
+
<h2 id="createimmutable">CreateImmutable</h2>
|
|
2141
2408
|
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
* @typedef {{}|null|number|string|boolean|symbol|bigint|function} AnyButUndefined
|
|
2148
|
-
*/
|
|
2149
|
-
```
|
|
2150
|
-
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2151
|
-
|
|
2152
|
-
<h2 id="extnametype">ExtnameType</h2>
|
|
2153
|
-
|
|
2154
|
-
- jsdoc types:
|
|
2155
|
-
|
|
2156
|
-
```js
|
|
2157
|
-
/**
|
|
2158
|
-
* - jsRuntime extention naming convention;
|
|
2159
|
-
* @typedef {`.${string}`} ExtnameType
|
|
2160
|
-
*/
|
|
2161
|
-
```
|
|
2162
|
-
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2163
|
-
|
|
2164
|
-
<h2 id="islistsignal">IsListSignal</h2>
|
|
2165
|
-
|
|
2166
|
-
- jsdoc types:
|
|
2167
|
-
|
|
2168
|
-
```js
|
|
2169
|
-
/**
|
|
2170
|
-
* - `EnvSignal.get` argument whether signal need to be a list or not;
|
|
2171
|
-
* @typedef {boolean} IsListSignal
|
|
2172
|
-
*/
|
|
2173
|
-
```
|
|
2174
|
-
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2175
|
-
|
|
2176
|
-
<h2 id="litexp">LitExp</h2>
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
#### reference:`LitExp`
|
|
2180
|
-
- class helper to created opionated regex helper;
|
|
2181
|
-
- named capture uses `es6+` feature, you might need to add polyfill to target extremely old browser;
|
|
2182
|
-
- class name refer to `Literal Expression`;
|
|
2183
|
-
- please be patient when using this class;
|
|
2184
|
-
>- destructuring is meant for extensive typehelper;
|
|
2185
|
-
>- and destructuring can lead to unhandled error here and there;
|
|
2186
|
-
>- therefore error as value is introduced to help to prevent error on runtime;
|
|
2409
|
+
|
|
2410
|
+
#### reference:`CreateImmutable`
|
|
2411
|
+
- function for create immutable object;
|
|
2412
|
+
- usefull for binding immutable object to global for shared object:
|
|
2413
|
+
>- e.g. to window object in browser;
|
|
2187
2414
|
|
|
2188
2415
|
```js
|
|
2189
2416
|
/**
|
|
2190
|
-
* @template {
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
>>- by doing so you are opting in to make:
|
|
2199
|
-
>>>- your regex detection more robust; but
|
|
2200
|
-
>>>- `litExp_instance.make.string` to be `unusable`;
|
|
2201
|
-
>>- also mind the needs of escape for special characters;
|
|
2202
|
-
|
|
2203
|
-
```js
|
|
2204
|
-
/**
|
|
2205
|
-
* @template {LitExpKeyType} KEYS
|
|
2206
|
-
* @param {KEYS} keysAndDefaultValuePair
|
|
2207
|
-
* - keys and whether to override regex detection;
|
|
2208
|
-
* >- example:
|
|
2209
|
-
* ```js
|
|
2210
|
-
* myKey: /myCustomCapture/ // all flags will be stripped;
|
|
2211
|
-
* ```
|
|
2212
|
-
* - default value === `false` is "[\\s\\S]
|
|
2213
|
-
*?", as in whiteSpace and nonWhiteSpace 0 to more occurence;
|
|
2214
|
-
* @returns {ReturnType<typeof TrySync<(templateStringArray:TemplateStringsArray,
|
|
2215
|
-
* ...values:(keyof KEYS)[]
|
|
2216
|
-
* )=>LitExp<KEYS>>>}
|
|
2217
|
-
* - placement of `key` will determine the named capture group will be placed in the template literal;
|
|
2218
|
-
* - it is recomended to not end template literal with any of the `key`s as the regex detection might failed to detects the boundary of the end of matched string of that capture group;
|
|
2219
|
-
*/
|
|
2220
|
-
```
|
|
2221
|
-
- <i>example</i>:
|
|
2222
|
-
```js
|
|
2223
|
-
import { LitExp } from 'vivth';
|
|
2224
|
-
|
|
2225
|
-
(()=>{
|
|
2226
|
-
const [liteal, errorPrep] = LitExp.prepare({
|
|
2227
|
-
myKey: /myCustomCapture/, // is placed on (?<myKey>myCustomCapture)
|
|
2228
|
-
// use false to place "[\\s\\S]*?" instead;
|
|
2229
|
-
...keyCaptureLogicPair
|
|
2230
|
-
})
|
|
2231
|
-
if (errorPrep) {
|
|
2232
|
-
console.error(error);
|
|
2233
|
-
return;
|
|
2234
|
-
}
|
|
2235
|
-
const litExp_instance = liteal`templateLiteral:${'myKey'};`
|
|
2236
|
-
// recommended to end the template literal with any string but `key`;
|
|
2237
|
-
})()
|
|
2238
|
-
|
|
2239
|
-
```
|
|
2240
|
-
|
|
2241
|
-
#### reference:`LitExp_instance.make`
|
|
2242
|
-
- instance methods for generating things;
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
#### reference:`LitExp_instance.make.string`
|
|
2246
|
-
- to make string based on the template literal;
|
|
2247
|
-
|
|
2248
|
-
```js
|
|
2249
|
-
/**
|
|
2250
|
-
* @param {Partial<ReturnType<LitExp<KEYS>["evaluate"]["execGroups"]>>[0]["result"]} overrides
|
|
2251
|
-
* @returns {string}
|
|
2252
|
-
*/
|
|
2253
|
-
```
|
|
2254
|
-
- <i>example</i>:
|
|
2255
|
-
```js
|
|
2256
|
-
import { LitExp } from 'vivth';
|
|
2257
|
-
|
|
2258
|
-
const [literal, errorPreparing] = LitExp.prepare({
|
|
2259
|
-
myKey: false,
|
|
2260
|
-
...keyCaptureLogicPair
|
|
2261
|
-
})
|
|
2262
|
-
|
|
2263
|
-
// asuming no error
|
|
2264
|
-
litExp_instance = `templateLiteral:${'myKey'};`;
|
|
2265
|
-
const [result, error] = litExp_instance.make.string({
|
|
2266
|
-
myKey: 'actualvalue',
|
|
2267
|
-
});
|
|
2268
|
-
|
|
2269
|
-
console.log(result); // "templateLiteral:actualvalue;"
|
|
2270
|
-
|
|
2271
|
-
```
|
|
2272
|
-
|
|
2273
|
-
#### reference:`LitExp_instance.evaluate`
|
|
2274
|
-
- methods collections to evaluate string with `Literal Expression`;
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
#### reference:`LitExp_instance.evaluate.execGroups`
|
|
2278
|
-
- to exec and grouped based on `key`;
|
|
2279
|
-
|
|
2280
|
-
```js
|
|
2281
|
-
/**
|
|
2282
|
-
* @param {string} string
|
|
2283
|
-
* @param {Object} options
|
|
2284
|
-
* @param {ConstructorParameters<typeof RegExp>[1]} options.flags
|
|
2285
|
-
* @param {boolean} options.whiteSpaceSensitive
|
|
2286
|
-
* - true: leave any whitespace as is to be used as regex detection;
|
|
2287
|
-
* - false: convert all whitespace to `\s+`;
|
|
2288
|
-
* @param {boolean} options.absoluteLeadAndFollowing
|
|
2289
|
-
* - false: standard capture;
|
|
2290
|
-
* - true: add `^` and `<h2 id="litexp">LitExp</h2>
|
|
2291
|
-
|
|
2292
|
-
to capture definition:
|
|
2293
|
-
* >- meaning string will have to match starting and end of line from capture definition;
|
|
2294
|
-
* @returns {ReturnType<typeof TrySync<{
|
|
2295
|
-
* result:{ whole:string, named: Record<keyof KEYS, string>},
|
|
2296
|
-
* regexp:RegExp}>>
|
|
2297
|
-
* }
|
|
2298
|
-
*/
|
|
2299
|
-
```
|
|
2300
|
-
- <i>example</i>:
|
|
2301
|
-
```js
|
|
2302
|
-
import { LitExp } from 'vivth';
|
|
2303
|
-
|
|
2304
|
-
const [literal, errorPreparing] = LitExp.prepare({
|
|
2305
|
-
myKey: false,
|
|
2306
|
-
...keyCaptureLogicPair
|
|
2307
|
-
})
|
|
2308
|
-
|
|
2309
|
-
// asuming no eror
|
|
2310
|
-
const litExp_instance = literal`templateLiteral:${'myKey'};`
|
|
2311
|
-
|
|
2312
|
-
const [{
|
|
2313
|
-
result:{ // asuming there's no error
|
|
2314
|
-
named: { myKey },
|
|
2315
|
-
whole,
|
|
2316
|
-
},
|
|
2317
|
-
regex, // for reference
|
|
2318
|
-
}, error] = litExp_instance.evaluate.execGroups(
|
|
2319
|
-
`templateLiteral:Something;`,
|
|
2320
|
-
{ ...options }
|
|
2321
|
-
)
|
|
2322
|
-
|
|
2323
|
-
console.log(whole); // "templateLiteral:Something;"
|
|
2324
|
-
console.log(myKey); // "Something"
|
|
2325
|
-
|
|
2326
|
-
```
|
|
2327
|
-
|
|
2328
|
-
#### reference:`LitExp_instance.evaluate.matchedAllAndGrouped`
|
|
2329
|
-
- to match all and grouped based on `key`;
|
|
2330
|
-
|
|
2331
|
-
```js
|
|
2332
|
-
/**
|
|
2333
|
-
* @param {Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[0]} string
|
|
2334
|
-
* @param {Omit<Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[1], 'absoluteLeadAndFollowing'>} options
|
|
2335
|
-
* @returns {ReturnType<typeof TrySync<{result:{whole:string[], named:Array<Record<keyof KEYS, string>>},
|
|
2336
|
-
* regexp: RegExp}>>
|
|
2337
|
-
* }
|
|
2417
|
+
* @template {Object} PARENT
|
|
2418
|
+
* @template {Object} OBJECT
|
|
2419
|
+
* @param {string} keyName
|
|
2420
|
+
* @param {PARENT} parent
|
|
2421
|
+
* @param {(this:PARENT)=>OBJECT} object
|
|
2422
|
+
* @param {Object} [options]
|
|
2423
|
+
* @param {boolean} [options.lazy]
|
|
2424
|
+
* @return {OBJECT}
|
|
2338
2425
|
*/
|
|
2339
2426
|
```
|
|
2340
2427
|
- <i>example</i>:
|
|
2341
|
-
```js
|
|
2342
|
-
import {
|
|
2343
|
-
|
|
2344
|
-
const
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
const [resultOfMatchedAllAndGrouped, error] = litExp_instance.evaluate.matchedAllAndGrouped(
|
|
2353
|
-
`templateLiteral:Something;
|
|
2354
|
-
templateLiteral:SomethingElse;`,
|
|
2355
|
-
{ ...options }
|
|
2356
|
-
)
|
|
2357
|
-
(()=>{
|
|
2358
|
-
if (error) {
|
|
2359
|
-
Console.error(error);
|
|
2360
|
-
return;
|
|
2361
|
-
}
|
|
2362
|
-
const {
|
|
2363
|
-
result: {
|
|
2364
|
-
whole: [whole0, whole1],
|
|
2365
|
-
named: [
|
|
2366
|
-
{ myKey: myKeyExec0, },
|
|
2367
|
-
{ myKey: myKeyExec1, },
|
|
2368
|
-
],
|
|
2369
|
-
},
|
|
2370
|
-
regexp
|
|
2371
|
-
} = resultOfMatchedAllAndGrouped;
|
|
2372
|
-
|
|
2373
|
-
console.log(whole0); // "templateLiteral:Something;"
|
|
2374
|
-
console.log(whole1); // "templateLiteral:SomethingElse;"
|
|
2375
|
-
console.log(myKeyExec0); // "Something"
|
|
2376
|
-
console.log(myKeyExec1); // "SomethingElse"
|
|
2377
|
-
})()
|
|
2428
|
+
```js
|
|
2429
|
+
import { CreateImmutable } from 'vivth';
|
|
2430
|
+
|
|
2431
|
+
const mappedObject = new Map();
|
|
2432
|
+
|
|
2433
|
+
CreateImmutable(window, 'mySharedObject', {
|
|
2434
|
+
setMap(name_, value) => {
|
|
2435
|
+
mappedObject.set(name_, value)
|
|
2436
|
+
},
|
|
2437
|
+
getMap(name_) => mappedObject.get(name_),
|
|
2438
|
+
})
|
|
2378
2439
|
|
|
2379
2440
|
```
|
|
2380
2441
|
|
|
2381
2442
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2382
2443
|
|
|
2383
|
-
<h2 id="listarg">ListArg</h2>
|
|
2384
|
-
|
|
2385
|
-
- jsdoc types:
|
|
2386
|
-
|
|
2387
|
-
```js
|
|
2388
|
-
/**
|
|
2389
|
-
* - ListSignal argument type;
|
|
2390
|
-
* @typedef {Record<string, string>} ListArg
|
|
2391
|
-
*/
|
|
2392
|
-
```
|
|
2393
|
-
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2394
|
-
|
|
2395
|
-
<h2 id="litexpkeytype">LitExpKeyType</h2>
|
|
2396
|
-
|
|
2397
|
-
- jsdoc types:
|
|
2398
|
-
|
|
2399
|
-
```js
|
|
2400
|
-
/**
|
|
2401
|
-
* @typedef {Record<string, RegExp|false>} LitExpKeyType
|
|
2402
|
-
*/
|
|
2403
|
-
```
|
|
2404
|
-
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2405
|
-
|
|
2406
|
-
<h2 id="mutationtype">MutationType</h2>
|
|
2407
|
-
|
|
2408
|
-
- jsdoc types:
|
|
2409
|
-
|
|
2410
|
-
```js
|
|
2411
|
-
/**
|
|
2412
|
-
* - `ListSignal` mutation type;
|
|
2413
|
-
* @typedef {'push'|'unshift'|'splice'|'swap'|'modify'|'shift'|'remove'} MutationType
|
|
2414
|
-
* - instance method: serves as helper to mutate, and notify for `effects`;
|
|
2415
|
-
* > - `slice` uses `splice` in the background, you don't need to manually reindex when using it;
|
|
2416
|
-
*/
|
|
2417
|
-
```
|
|
2418
|
-
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2419
|
-
|
|
2420
|
-
<h2 id="qcbfiforeturn">QCBFIFOReturn</h2>
|
|
2421
|
-
|
|
2422
|
-
- jsdoc types:
|
|
2423
|
-
|
|
2424
|
-
```js
|
|
2425
|
-
/**
|
|
2426
|
-
* - return type of Q callback fifo;
|
|
2427
|
-
* @typedef {Omit<import("./src/types/QCBReturn.mjs").QCBReturn, "isLastOnQ">} QCBFIFOReturn
|
|
2428
|
-
*/
|
|
2429
|
-
```
|
|
2430
|
-
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2431
|
-
|
|
2432
|
-
<h2 id="qcbreturn">QCBReturn</h2>
|
|
2433
|
-
|
|
2434
|
-
- jsdoc types:
|
|
2435
|
-
|
|
2436
|
-
```js
|
|
2437
|
-
/**
|
|
2438
|
-
* - return type of Q callback;
|
|
2439
|
-
* @typedef {{resume:()=>void, isLastOnQ:()=>boolean}} QCBReturn
|
|
2440
|
-
*/
|
|
2441
|
-
```
|
|
2442
|
-
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2443
|
-
|
|
2444
|
-
<h2 id="runtime">Runtime</h2>
|
|
2445
|
-
|
|
2446
|
-
- jsdoc types:
|
|
2447
|
-
|
|
2448
|
-
```js
|
|
2449
|
-
/**
|
|
2450
|
-
* @description
|
|
2451
|
-
* - for popular runtimes check;
|
|
2452
|
-
* @typedef {'node' | 'bun' | 'deno' | 'browser' | 'unknown'} Runtime
|
|
2453
|
-
*/
|
|
2454
|
-
```
|
|
2455
|
-
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2456
|
-
|
|
2457
2444
|
<h2 id="eventcheck">EventCheck</h2>
|
|
2458
2445
|
|
|
2459
2446
|
|
|
@@ -2508,52 +2495,52 @@ npm i vivth
|
|
|
2508
2495
|
|
|
2509
2496
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2510
2497
|
|
|
2511
|
-
<h2 id="
|
|
2498
|
+
<h2 id="getruntime">GetRuntime</h2>
|
|
2512
2499
|
|
|
2513
2500
|
|
|
2514
|
-
#### reference:`
|
|
2515
|
-
-
|
|
2501
|
+
#### reference:`GetRuntime`
|
|
2502
|
+
- detects the current JavaScript runtime;
|
|
2516
2503
|
|
|
2517
2504
|
```js
|
|
2518
2505
|
/**
|
|
2519
|
-
* @
|
|
2520
|
-
* @returns {boolean}
|
|
2506
|
+
* @type {()=>Runtime}
|
|
2521
2507
|
*/
|
|
2522
2508
|
```
|
|
2523
2509
|
- <i>example</i>:
|
|
2524
2510
|
```js
|
|
2525
|
-
import {
|
|
2526
|
-
|
|
2527
|
-
const a = function (params) {
|
|
2528
|
-
// code
|
|
2529
|
-
}
|
|
2530
|
-
const b = async () => {
|
|
2531
|
-
// code
|
|
2532
|
-
}
|
|
2511
|
+
import { GetRuntime } form 'vivth';
|
|
2533
2512
|
|
|
2534
|
-
|
|
2535
|
-
IsAsync(b); // true
|
|
2513
|
+
const runtime = GetRuntime();
|
|
2536
2514
|
|
|
2537
2515
|
```
|
|
2538
2516
|
|
|
2539
2517
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2540
2518
|
|
|
2541
|
-
<h2 id="
|
|
2519
|
+
<h2 id="isasync">IsAsync</h2>
|
|
2542
2520
|
|
|
2543
2521
|
|
|
2544
|
-
#### reference:`
|
|
2545
|
-
-
|
|
2522
|
+
#### reference:`IsAsync`
|
|
2523
|
+
- function helper for checking whether `functionReference` is async;
|
|
2546
2524
|
|
|
2547
2525
|
```js
|
|
2548
2526
|
/**
|
|
2549
|
-
* @
|
|
2527
|
+
* @param {(...any:any)=>(any|Promise<any>)} functionReference
|
|
2528
|
+
* @returns {boolean}
|
|
2550
2529
|
*/
|
|
2551
2530
|
```
|
|
2552
2531
|
- <i>example</i>:
|
|
2553
2532
|
```js
|
|
2554
|
-
import {
|
|
2533
|
+
import { IsAsync } from 'vivth';
|
|
2555
2534
|
|
|
2556
|
-
const
|
|
2535
|
+
const a = function (params) {
|
|
2536
|
+
// code
|
|
2537
|
+
}
|
|
2538
|
+
const b = async () => {
|
|
2539
|
+
// code
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
IsAsync(a); // false
|
|
2543
|
+
IsAsync(b); // true
|
|
2557
2544
|
|
|
2558
2545
|
```
|
|
2559
2546
|
|
|
@@ -2653,7 +2640,7 @@ npm i vivth
|
|
|
2653
2640
|
* @param {RecordTryType} tryRecord
|
|
2654
2641
|
* @returns {Promise<
|
|
2655
2642
|
* [[keyof RecordTryType, RETURNTYPE], undefined]
|
|
2656
|
-
* | [[undefined, undefined], Error]
|
|
2643
|
+
* | [[undefined, undefined], Error|undefined]
|
|
2657
2644
|
* >}
|
|
2658
2645
|
*/
|
|
2659
2646
|
```
|
|
@@ -2704,7 +2691,7 @@ npm i vivth
|
|
|
2704
2691
|
/**
|
|
2705
2692
|
* @template RESULT
|
|
2706
2693
|
* @param {()=>Promise<RESULT>} asyncFunction_
|
|
2707
|
-
* @returns {Promise<[RESULT|undefined,
|
|
2694
|
+
* @returns {Promise<[RESULT,undefined]|[undefined,Error]>}
|
|
2708
2695
|
*/
|
|
2709
2696
|
```
|
|
2710
2697
|
- <i>example</i>:
|
|
@@ -2737,7 +2724,8 @@ npm i vivth
|
|
|
2737
2724
|
/**
|
|
2738
2725
|
* @template RESULT
|
|
2739
2726
|
* @param {()=>RESULT} function_
|
|
2740
|
-
* @returns {[RESULT
|
|
2727
|
+
* @returns {[RESULT,undefined]|
|
|
2728
|
+
* [undefined,Error]}
|
|
2741
2729
|
*/
|
|
2742
2730
|
```
|
|
2743
2731
|
- <i>example</i>:
|
|
@@ -2784,74 +2772,127 @@ npm i vivth
|
|
|
2784
2772
|
|
|
2785
2773
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2786
2774
|
|
|
2787
|
-
<h2 id="
|
|
2775
|
+
<h2 id="anybutundefined">AnyButUndefined</h2>
|
|
2788
2776
|
|
|
2777
|
+
- jsdoc types:
|
|
2789
2778
|
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
-
|
|
2793
|
-
|
|
2779
|
+
```js
|
|
2780
|
+
/**
|
|
2781
|
+
* - type helper for ID or objects;
|
|
2782
|
+
* @typedef {{}|null|number|string|boolean|symbol|bigint|function} AnyButUndefined
|
|
2783
|
+
*/
|
|
2784
|
+
```
|
|
2785
|
+
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2786
|
+
|
|
2787
|
+
<h2 id="extnametype">ExtnameType</h2>
|
|
2788
|
+
|
|
2789
|
+
- jsdoc types:
|
|
2794
2790
|
|
|
2795
2791
|
```js
|
|
2796
|
-
/**
|
|
2797
|
-
*
|
|
2798
|
-
* @
|
|
2799
|
-
* @param {(string:string)=>string} btoaFunction
|
|
2800
|
-
* - check your js runtime `btoa`;
|
|
2801
|
-
* - node compatible:
|
|
2802
|
-
* ```js
|
|
2803
|
-
* (str, prevBufferEncoding) =>
|
|
2804
|
-
* Buffer.from(str, prevBufferEncoding).toString('base64')
|
|
2805
|
-
* ```
|
|
2806
|
-
* @returns {Base64URLString}
|
|
2792
|
+
/**
|
|
2793
|
+
* - jsRuntime extention naming convention;
|
|
2794
|
+
* @typedef {`.${string}`} ExtnameType
|
|
2807
2795
|
*/
|
|
2808
2796
|
```
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2797
|
+
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2798
|
+
|
|
2799
|
+
<h2 id="islistsignal">IsListSignal</h2>
|
|
2800
|
+
|
|
2801
|
+
- jsdoc types:
|
|
2802
|
+
|
|
2803
|
+
```js
|
|
2804
|
+
/**
|
|
2805
|
+
* - `EnvSignal.get` argument whether signal need to be a list or not;
|
|
2806
|
+
* @typedef {boolean} IsListSignal
|
|
2807
|
+
*/
|
|
2816
2808
|
```
|
|
2809
|
+
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2810
|
+
|
|
2811
|
+
<h2 id="listarg">ListArg</h2>
|
|
2817
2812
|
|
|
2813
|
+
- jsdoc types:
|
|
2814
|
+
|
|
2815
|
+
```js
|
|
2816
|
+
/**
|
|
2817
|
+
* - ListSignal argument type;
|
|
2818
|
+
* @typedef {Record<string, string>} ListArg
|
|
2819
|
+
*/
|
|
2820
|
+
```
|
|
2818
2821
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2819
2822
|
|
|
2820
|
-
<h2 id="
|
|
2823
|
+
<h2 id="litexpkeytype">LitExpKeyType</h2>
|
|
2824
|
+
|
|
2825
|
+
- jsdoc types:
|
|
2826
|
+
|
|
2827
|
+
```js
|
|
2828
|
+
/**
|
|
2829
|
+
* @typedef {Record<string, RegExp|false>} LitExpKeyType
|
|
2830
|
+
*/
|
|
2831
|
+
```
|
|
2832
|
+
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2821
2833
|
|
|
2834
|
+
<h2 id="litexpresulttype">LitExpResultType</h2>
|
|
2822
2835
|
|
|
2823
|
-
|
|
2824
|
-
- function for create immutable object;
|
|
2825
|
-
- usefull for binding immutable object to global for shared object:
|
|
2826
|
-
>- e.g. to window object in browser;
|
|
2836
|
+
- jsdoc types:
|
|
2827
2837
|
|
|
2828
2838
|
```js
|
|
2829
|
-
/**
|
|
2830
|
-
* @template {
|
|
2831
|
-
* @
|
|
2832
|
-
*
|
|
2833
|
-
* @param {PARENT} parent
|
|
2834
|
-
* @param {(this:PARENT)=>OBJECT} object
|
|
2835
|
-
* @param {Object} [options]
|
|
2836
|
-
* @param {boolean} [options.lazy]
|
|
2837
|
-
* @return {OBJECT}
|
|
2839
|
+
/**
|
|
2840
|
+
* @template {import('./src/types/LitExpKeyType.mjs').LitExpKeyType} KEYS
|
|
2841
|
+
* @typedef {{result:{whole:string[], named:Array<Record<keyof KEYS, string>>},
|
|
2842
|
+
* regexp: RegExp}} LitExpResultType
|
|
2838
2843
|
*/
|
|
2839
2844
|
```
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2845
|
+
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2846
|
+
|
|
2847
|
+
<h2 id="mutationtype">MutationType</h2>
|
|
2848
|
+
|
|
2849
|
+
- jsdoc types:
|
|
2850
|
+
|
|
2851
|
+
```js
|
|
2852
|
+
/**
|
|
2853
|
+
* - `ListSignal` mutation type;
|
|
2854
|
+
* @typedef {'push'|'unshift'|'splice'|'swap'|'modify'|'shift'|'remove'} MutationType
|
|
2855
|
+
* - instance method: serves as helper to mutate, and notify for `effects`;
|
|
2856
|
+
* > - `slice` uses `splice` in the background, you don't need to manually reindex when using it;
|
|
2857
|
+
*/
|
|
2858
|
+
```
|
|
2859
|
+
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2860
|
+
|
|
2861
|
+
<h2 id="qcbfiforeturn">QCBFIFOReturn</h2>
|
|
2862
|
+
|
|
2863
|
+
- jsdoc types:
|
|
2864
|
+
|
|
2865
|
+
```js
|
|
2866
|
+
/**
|
|
2867
|
+
* - return type of Q callback fifo;
|
|
2868
|
+
* @typedef {Omit<import("./src/types/QCBReturn.mjs").QCBReturn, "isLastOnQ">} QCBFIFOReturn
|
|
2869
|
+
*/
|
|
2870
|
+
```
|
|
2871
|
+
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2872
|
+
|
|
2873
|
+
<h2 id="qcbreturn">QCBReturn</h2>
|
|
2874
|
+
|
|
2875
|
+
- jsdoc types:
|
|
2876
|
+
|
|
2877
|
+
```js
|
|
2878
|
+
/**
|
|
2879
|
+
* - return type of Q callback;
|
|
2880
|
+
* @typedef {{resume:()=>void, isLastOnQ:()=>boolean}} QCBReturn
|
|
2881
|
+
*/
|
|
2853
2882
|
```
|
|
2883
|
+
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2884
|
+
|
|
2885
|
+
<h2 id="runtime">Runtime</h2>
|
|
2886
|
+
|
|
2887
|
+
- jsdoc types:
|
|
2854
2888
|
|
|
2889
|
+
```js
|
|
2890
|
+
/**
|
|
2891
|
+
* @description
|
|
2892
|
+
* - for popular runtimes check;
|
|
2893
|
+
* @typedef {'node' | 'bun' | 'deno' | 'browser' | 'unknown'} Runtime
|
|
2894
|
+
*/
|
|
2895
|
+
```
|
|
2855
2896
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2856
2897
|
|
|
2857
2898
|
<h2 id="workerresult">WorkerResult</h2>
|
|
@@ -2930,7 +2971,7 @@ npm i vivth
|
|
|
2930
2971
|
|
|
2931
2972
|
```js
|
|
2932
2973
|
/**
|
|
2933
|
-
* @param {WorkerThread["handler"]} handler
|
|
2974
|
+
* @param {WorkerThread<RECEIVE, POST>["handler"]} handler
|
|
2934
2975
|
*/
|
|
2935
2976
|
```
|
|
2936
2977
|
- <i>example</i>:
|
|
@@ -2959,24 +3000,6 @@ npm i vivth
|
|
|
2959
3000
|
*/
|
|
2960
3001
|
```
|
|
2961
3002
|
|
|
2962
|
-
#### reference:`WorkerThread_instance.RECEIVE`
|
|
2963
|
-
- helper type, hold no actual value;
|
|
2964
|
-
|
|
2965
|
-
```js
|
|
2966
|
-
/**
|
|
2967
|
-
* @type {RECEIVE}
|
|
2968
|
-
*/
|
|
2969
|
-
```
|
|
2970
|
-
|
|
2971
|
-
#### reference:`WorkerThread_instance.POST`
|
|
2972
|
-
- helper type, hold no actual value;
|
|
2973
|
-
|
|
2974
|
-
```js
|
|
2975
|
-
/**
|
|
2976
|
-
* @type {POST}
|
|
2977
|
-
*/
|
|
2978
|
-
```
|
|
2979
|
-
|
|
2980
3003
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2981
3004
|
|
|
2982
3005
|
<h2 id="tobundledjsplugin">ToBundledJSPlugin</h2>
|