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.
Files changed (71) hide show
  1. package/README.md +608 -586
  2. package/README.src.md +5 -1
  3. package/bun.lock +6 -0
  4. package/index.mjs +10 -6
  5. package/package.json +3 -1
  6. package/src/bundler/CompileJS.mjs +11 -8
  7. package/src/bundler/EsBundler.mjs +4 -2
  8. package/src/bundler/FSInline.mjs +3 -0
  9. package/src/bundler/FSInlineAnalyzer.mjs +31 -7
  10. package/src/bundler/FSInlineBundled.mjs +5 -1
  11. package/src/bundler/adds/ToBundledJSPlugin.mjs +3 -4
  12. package/src/class/Console.mjs +12 -4
  13. package/src/class/Derived.mjs +5 -1
  14. package/src/class/Effect.mjs +6 -6
  15. package/src/class/EnvSignal.mjs +1 -8
  16. package/src/class/EventSignal.mjs +8 -7
  17. package/src/class/FileSafe.mjs +1 -1
  18. package/src/class/ListSignal.mjs +18 -10
  19. package/src/class/LitExp.mjs +241 -204
  20. package/src/class/Paths.mjs +10 -8
  21. package/src/class/QChannel.mjs +14 -7
  22. package/src/class/SafeExit.mjs +16 -7
  23. package/src/class/Signal.mjs +8 -7
  24. package/src/class/WorkerMainThread.mjs +45 -24
  25. package/src/class/WorkerMainThreadBundled.mjs +42 -24
  26. package/src/class/WorkerThread.mjs +21 -7
  27. package/src/common/Base64URL.mjs +2 -2
  28. package/src/common/Base64URLFromFile.mjs +1 -1
  29. package/src/doc/JSautoDOC.mjs +99 -62
  30. package/src/doc/correctBeforeParse.mjs +139 -0
  31. package/src/doc/parsedFile.mjs +127 -76
  32. package/src/function/CreateImmutable.mjs +12 -7
  33. package/src/function/GetRuntime.mjs +8 -3
  34. package/src/function/LazyFactory.mjs +10 -4
  35. package/src/function/Try.mjs +4 -1
  36. package/src/function/TryAsync.mjs +2 -1
  37. package/src/function/TrySync.mjs +3 -1
  38. package/src/function/TsToMjs.mjs +7 -4
  39. package/src/types/AnyButUndefined.mjs +1 -0
  40. package/src/types/LitExpResultType.mjs +7 -0
  41. package/src/types/Runtime.mjs +1 -1
  42. package/tsconfig.json +27 -5
  43. package/types/dev/workerThreadClass.d.mts +1 -1
  44. package/types/index.d.mts +7 -6
  45. package/types/src/bundler/CompileJS.d.mts +14 -9
  46. package/types/src/bundler/EsBundler.d.mts +1 -1
  47. package/types/src/class/Derived.d.mts +4 -64
  48. package/types/src/class/Effect.d.mts +8 -8
  49. package/types/src/class/EnvSignal.d.mts +0 -1
  50. package/types/src/class/EventSignal.d.mts +5 -5
  51. package/types/src/class/FileSafe.d.mts +2 -2
  52. package/types/src/class/ListSignal.d.mts +1 -1
  53. package/types/src/class/LitExp.d.mts +49 -53
  54. package/types/src/class/Paths.d.mts +4 -4
  55. package/types/src/class/QChannel.d.mts +1 -1
  56. package/types/src/class/SafeExit.d.mts +3 -3
  57. package/types/src/class/Signal.d.mts +3 -3
  58. package/types/src/class/WorkerMainThread.d.mts +13 -8
  59. package/types/src/class/WorkerMainThreadBundled.d.mts +13 -8
  60. package/types/src/class/WorkerThread.d.mts +4 -4
  61. package/types/src/common/Base64URL.d.mts +2 -2
  62. package/types/src/common/Base64URLFromFile.d.mts +2 -2
  63. package/types/src/doc/JSautoDOC.d.mts +33 -12
  64. package/types/src/doc/correctBeforeParse.d.mts +2 -0
  65. package/types/src/doc/parsedFile.d.mts +7 -10
  66. package/types/src/function/CreateImmutable.d.mts +2 -2
  67. package/types/src/function/Try.d.mts +2 -2
  68. package/types/src/function/TryAsync.d.mts +2 -2
  69. package/types/src/function/TrySync.d.mts +3 -2
  70. package/types/src/function/TsToMjs.d.mts +2 -2
  71. 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+:b`:
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
- - [CompileJS](#compilejs)
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
- - [Console](#console)
66
+ - [Base64URL](#base64url)
61
67
  - [Base64URLFromFile](#base64urlfromfile)
62
68
  - [EventNameSpace](#eventnamespace)
63
69
  - [JSautoDOC](#jsautodoc)
64
- - [AnyButUndefined](#anybutundefined)
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
- - [Base64URL](#base64url)
85
- - [CreateImmutable](#createimmutable)
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="compilejs">CompileJS</h2>
339
+ <h2 id="console">Console</h2>
252
340
 
253
341
 
254
- #### reference:`CompileJS`
255
- - function to compile `.ts`|`.mts`|`.mjs` file, into a single executable;
256
- - also generate js representation;
257
- - 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;
258
- >- they are used only as packaging agent, and doesn't necessarily supports their advanced feature, such as, assets bundling(use [FSInline](#fsinline) instead);
259
- >- `WorkerThread` will be converted to inline using `FSInline` too;
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
- !!!WARNING!!!
262
- !!!WARNING!!!
263
- !!!WARNING!!!
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
- - This function does not obfuscate and will not prevent decompilation. Do not embed environment variables or sensitive information inside `options.entryPoint`;
266
- - It is designed for quick binarization, allowing execution on machines without `Node.js`, `Bun`, or `Deno` installed;
267
- - 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);
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
- !!!WARNING!!!
270
- !!!WARNING!!!
271
- !!!WARNING!!!
401
+ ```
402
+
403
+ #### reference:`Console.error`
404
+
272
405
 
273
406
  ```js
274
407
  /**
275
- * @param {Object} options
276
- * @param {string} options.entryPoint
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 { join } from 'node:path';
304
-
305
- import { CompileJS, Paths } from 'vivth';
306
-
307
- const [[resultPkg, errorPkg], [resultBun, errorBun]] = await Promise.all([
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 {Signal} SIGNAL
488
- * @param {SIGNAL} signal
489
- * @returns {SIGNAL}
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|ListSignal}
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|ListDerived}
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="paths">Paths</h2>
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
- #### reference:`new Paths`
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="console">Console</h2>
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 {any} data
2030
- * @returns {void}
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 { Console } from 'vivth';
2036
-
2037
- Console.error({
2038
- hello: 'world!!',
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<Base64URLString>}
2320
+ * @returns {Promise<string>}
2058
2321
  */
2059
2322
  ```
2060
2323
  - <i>example</i>:
@@ -2101,7 +2364,10 @@ 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;
2105
2371
 
2106
2372
 
2107
2373
  #### reference:`new JSautoDOC`
@@ -2111,11 +2377,11 @@ npm i vivth
2111
2377
  /**
2112
2378
  * @param {Object} [options]
2113
2379
  * @param {Object} [options.paths]
2114
- * @param {string} [options.paths.file]
2380
+ * @param {string} options.paths.file
2115
2381
  * - entry point;
2116
- * @param {string} [options.paths.readMe]
2382
+ * @param {string} options.paths.readMe
2117
2383
  * - readme target;
2118
- * @param {string} [options.paths.dir]
2384
+ * @param {string} options.paths.dir
2119
2385
  * - source directory;
2120
2386
  * @param {string} [options.copyright]
2121
2387
  * @param {string} [options.tableOfContentTitle]
@@ -2137,323 +2403,43 @@ npm i vivth
2137
2403
 
2138
2404
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2139
2405
 
2140
- <h2 id="anybutundefined">AnyButUndefined</h2>
2406
+ <h2 id="createimmutable">CreateImmutable</h2>
2141
2407
 
2142
- - jsdoc types:
2143
-
2144
- ```js
2145
- /**
2146
- * - type helper for ID or objects;
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;
2408
+
2409
+ #### reference:`CreateImmutable`
2410
+ - function for create immutable object;
2411
+ - usefull for binding immutable object to global for shared object:
2412
+ >- e.g. to window object in browser;
2187
2413
 
2188
2414
  ```js
2189
2415
  /**
2190
- * @template {LitExpKeyType} KEYS
2191
- */
2192
- ```
2193
-
2194
- #### reference:`LitExp.prepare`
2195
- - constructor helper;
2196
- - under the hood it is an abstraction of `RegExp`, with more template literal touch;
2197
- >- you can apply inline `RegExp` features on the string template literal(as constructor RegExp arg0);
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
- * }
2416
+ * @template {Object} PARENT
2417
+ * @template {Object} OBJECT
2418
+ * @param {string} keyName
2419
+ * @param {PARENT} parent
2420
+ * @param {(this:PARENT)=>OBJECT} object
2421
+ * @param {Object} [options]
2422
+ * @param {boolean} [options.lazy]
2423
+ * @return {OBJECT}
2338
2424
  */
2339
2425
  ```
2340
2426
  - <i>example</i>:
2341
- ```js
2342
- import { LitExp, Console } from 'vivth';
2343
-
2344
- const [literal, errorPreparing] = LitExp.prepare({
2345
- myKey: false,
2346
- ...keyCaptureLogicPair
2347
- })
2348
-
2349
- // asuming no error;
2350
- litExp_instance = literal`templateLiteral:${'myKey'};`
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
- })()
2427
+ ```js
2428
+ import { CreateImmutable } from 'vivth';
2429
+
2430
+ const mappedObject = new Map();
2431
+
2432
+ CreateImmutable(window, 'mySharedObject', {
2433
+ setMap(name_, value) => {
2434
+ mappedObject.set(name_, value)
2435
+ },
2436
+ getMap(name_) => mappedObject.get(name_),
2437
+ })
2378
2438
 
2379
2439
  ```
2380
2440
 
2381
2441
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2382
2442
 
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
2443
  <h2 id="eventcheck">EventCheck</h2>
2458
2444
 
2459
2445
 
@@ -2508,52 +2494,52 @@ npm i vivth
2508
2494
 
2509
2495
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2510
2496
 
2511
- <h2 id="isasync">IsAsync</h2>
2497
+ <h2 id="getruntime">GetRuntime</h2>
2512
2498
 
2513
2499
 
2514
- #### reference:`IsAsync`
2515
- - function helper for checking whether `functionReference` is async;
2500
+ #### reference:`GetRuntime`
2501
+ - detects the current JavaScript runtime;
2516
2502
 
2517
2503
  ```js
2518
2504
  /**
2519
- * @param {(...any:any)=>(any|Promise<any>)} functionReference
2520
- * @returns {boolean}
2505
+ * @type {()=>Runtime}
2521
2506
  */
2522
2507
  ```
2523
2508
  - <i>example</i>:
2524
2509
  ```js
2525
- import { IsAsync } from 'vivth';
2526
-
2527
- const a = function (params) {
2528
- // code
2529
- }
2530
- const b = async () => {
2531
- // code
2532
- }
2510
+ import { GetRuntime } form 'vivth';
2533
2511
 
2534
- IsAsync(a); // false
2535
- IsAsync(b); // true
2512
+ const runtime = GetRuntime();
2536
2513
 
2537
2514
  ```
2538
2515
 
2539
2516
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2540
2517
 
2541
- <h2 id="getruntime">GetRuntime</h2>
2518
+ <h2 id="isasync">IsAsync</h2>
2542
2519
 
2543
2520
 
2544
- #### reference:`GetRuntime`
2545
- - detects the current JavaScript runtime;
2521
+ #### reference:`IsAsync`
2522
+ - function helper for checking whether `functionReference` is async;
2546
2523
 
2547
2524
  ```js
2548
2525
  /**
2549
- * @type {()=>Runtime}
2526
+ * @param {(...any:any)=>(any|Promise<any>)} functionReference
2527
+ * @returns {boolean}
2550
2528
  */
2551
2529
  ```
2552
2530
  - <i>example</i>:
2553
2531
  ```js
2554
- import { GetRuntime } form 'vivth';
2532
+ import { IsAsync } from 'vivth';
2555
2533
 
2556
- const runtime = GetRuntime();
2534
+ const a = function (params) {
2535
+ // code
2536
+ }
2537
+ const b = async () => {
2538
+ // code
2539
+ }
2540
+
2541
+ IsAsync(a); // false
2542
+ IsAsync(b); // true
2557
2543
 
2558
2544
  ```
2559
2545
 
@@ -2653,7 +2639,7 @@ npm i vivth
2653
2639
  * @param {RecordTryType} tryRecord
2654
2640
  * @returns {Promise<
2655
2641
  * [[keyof RecordTryType, RETURNTYPE], undefined]
2656
- * | [[undefined, undefined], Error]
2642
+ * | [[undefined, undefined], Error|undefined]
2657
2643
  * >}
2658
2644
  */
2659
2645
  ```
@@ -2704,7 +2690,7 @@ npm i vivth
2704
2690
  /**
2705
2691
  * @template RESULT
2706
2692
  * @param {()=>Promise<RESULT>} asyncFunction_
2707
- * @returns {Promise<[RESULT|undefined, Error|undefined]>}
2693
+ * @returns {Promise<[RESULT,undefined]|[undefined,Error]>}
2708
2694
  */
2709
2695
  ```
2710
2696
  - <i>example</i>:
@@ -2737,7 +2723,8 @@ npm i vivth
2737
2723
  /**
2738
2724
  * @template RESULT
2739
2725
  * @param {()=>RESULT} function_
2740
- * @returns {[RESULT|undefined, Error|undefined]}
2726
+ * @returns {[RESULT,undefined]|
2727
+ * [undefined,Error]}
2741
2728
  */
2742
2729
  ```
2743
2730
  - <i>example</i>:
@@ -2784,74 +2771,127 @@ npm i vivth
2784
2771
 
2785
2772
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2786
2773
 
2787
- <h2 id="base64url">Base64URL</h2>
2774
+ <h2 id="anybutundefined">AnyButUndefined</h2>
2788
2775
 
2776
+ - jsdoc types:
2789
2777
 
2790
- #### reference:`Base64URL`
2791
- - create inline base64 url;
2792
- - usage:
2793
- >- can be extremely usefull to display file on desktop app webview, without exposing http server;
2778
+ ```js
2779
+ /**
2780
+ * - type helper for ID or objects;
2781
+ * @typedef {{}|null|number|string|boolean|symbol|bigint|function} AnyButUndefined
2782
+ */
2783
+ ```
2784
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2785
+
2786
+ <h2 id="extnametype">ExtnameType</h2>
2787
+
2788
+ - jsdoc types:
2794
2789
 
2795
2790
  ```js
2796
- /**
2797
- * @param {string} fileString
2798
- * @param {string} mimeType
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}
2791
+ /**
2792
+ * - jsRuntime extention naming convention;
2793
+ * @typedef {`.${string}`} ExtnameType
2807
2794
  */
2808
2795
  ```
2809
- - <i>example</i>:
2810
- ```js
2811
- import { Base64URL } from 'vivth'
2812
- import fileString from './fileString.mjs';
2813
-
2814
- Base64URL(fileString, 'application/javascript', btoa);
2815
-
2796
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2797
+
2798
+ <h2 id="islistsignal">IsListSignal</h2>
2799
+
2800
+ - jsdoc types:
2801
+
2802
+ ```js
2803
+ /**
2804
+ * - `EnvSignal.get` argument whether signal need to be a list or not;
2805
+ * @typedef {boolean} IsListSignal
2806
+ */
2816
2807
  ```
2808
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2809
+
2810
+ <h2 id="listarg">ListArg</h2>
2817
2811
 
2812
+ - jsdoc types:
2813
+
2814
+ ```js
2815
+ /**
2816
+ * - ListSignal argument type;
2817
+ * @typedef {Record<string, string>} ListArg
2818
+ */
2819
+ ```
2818
2820
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2819
2821
 
2820
- <h2 id="createimmutable">CreateImmutable</h2>
2822
+ <h2 id="litexpkeytype">LitExpKeyType</h2>
2823
+
2824
+ - jsdoc types:
2825
+
2826
+ ```js
2827
+ /**
2828
+ * @typedef {Record<string, RegExp|false>} LitExpKeyType
2829
+ */
2830
+ ```
2831
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2821
2832
 
2833
+ <h2 id="litexpresulttype">LitExpResultType</h2>
2822
2834
 
2823
- #### reference:`CreateImmutable`
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;
2835
+ - jsdoc types:
2827
2836
 
2828
2837
  ```js
2829
- /**
2830
- * @template {Object} PARENT
2831
- * @template {Object} OBJECT
2832
- * @param {string} keyName
2833
- * @param {PARENT} parent
2834
- * @param {(this:PARENT)=>OBJECT} object
2835
- * @param {Object} [options]
2836
- * @param {boolean} [options.lazy]
2837
- * @return {OBJECT}
2838
+ /**
2839
+ * @template {import('./src/types/LitExpKeyType.mjs').LitExpKeyType} KEYS
2840
+ * @typedef {{result:{whole:string[], named:Array<Record<keyof KEYS, string>>},
2841
+ * regexp: RegExp}} LitExpResultType
2838
2842
  */
2839
2843
  ```
2840
- - <i>example</i>:
2841
- ```js
2842
- import { CreateImmutable } from 'vivth';
2843
-
2844
- const mappedObject = new Map();
2845
-
2846
- CreateImmutable(window, 'mySharedObject', {
2847
- setMap(name_, value) => {
2848
- mappedObject.set(name_, value)
2849
- },
2850
- getMap(name_) => mappedObject.get(name_),
2851
- })
2852
-
2844
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2845
+
2846
+ <h2 id="mutationtype">MutationType</h2>
2847
+
2848
+ - jsdoc types:
2849
+
2850
+ ```js
2851
+ /**
2852
+ * - `ListSignal` mutation type;
2853
+ * @typedef {'push'|'unshift'|'splice'|'swap'|'modify'|'shift'|'remove'} MutationType
2854
+ * - instance method: serves as helper to mutate, and notify for `effects`;
2855
+ * > - `slice` uses `splice` in the background, you don't need to manually reindex when using it;
2856
+ */
2857
+ ```
2858
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2859
+
2860
+ <h2 id="qcbfiforeturn">QCBFIFOReturn</h2>
2861
+
2862
+ - jsdoc types:
2863
+
2864
+ ```js
2865
+ /**
2866
+ * - return type of Q callback fifo;
2867
+ * @typedef {Omit<import("./src/types/QCBReturn.mjs").QCBReturn, "isLastOnQ">} QCBFIFOReturn
2868
+ */
2869
+ ```
2870
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2871
+
2872
+ <h2 id="qcbreturn">QCBReturn</h2>
2873
+
2874
+ - jsdoc types:
2875
+
2876
+ ```js
2877
+ /**
2878
+ * - return type of Q callback;
2879
+ * @typedef {{resume:()=>void, isLastOnQ:()=>boolean}} QCBReturn
2880
+ */
2853
2881
  ```
2882
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2883
+
2884
+ <h2 id="runtime">Runtime</h2>
2885
+
2886
+ - jsdoc types:
2854
2887
 
2888
+ ```js
2889
+ /**
2890
+ * @description
2891
+ * - for popular runtimes check;
2892
+ * @typedef {'node' | 'bun' | 'deno' | 'browser' | 'unknown'} Runtime
2893
+ */
2894
+ ```
2855
2895
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2856
2896
 
2857
2897
  <h2 id="workerresult">WorkerResult</h2>
@@ -2930,7 +2970,7 @@ npm i vivth
2930
2970
 
2931
2971
  ```js
2932
2972
  /**
2933
- * @param {WorkerThread["handler"]} handler
2973
+ * @param {WorkerThread<RECEIVE, POST>["handler"]} handler
2934
2974
  */
2935
2975
  ```
2936
2976
  - <i>example</i>:
@@ -2959,24 +2999,6 @@ npm i vivth
2959
2999
  */
2960
3000
  ```
2961
3001
 
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
3002
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2981
3003
 
2982
3004
  <h2 id="tobundledjsplugin">ToBundledJSPlugin</h2>