vivth 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +225 -199
- package/README.src.md +5 -1
- package/bun.lock +6 -0
- package/index.mjs +5 -1
- package/package.json +3 -1
- package/src/bundler/CompileJS.mjs +21 -11
- package/src/bundler/EsBundler.mjs +4 -3
- package/src/bundler/FSInline.mjs +3 -0
- package/src/bundler/FSInlineAnalyzer.mjs +31 -9
- package/src/bundler/FSInlineBundled.mjs +5 -1
- package/src/bundler/adds/ToBundledJSPlugin.mjs +3 -4
- package/src/class/Console.mjs +12 -4
- package/src/class/Derived.mjs +5 -1
- package/src/class/Effect.mjs +6 -6
- package/src/class/EnvSignal.mjs +1 -8
- package/src/class/EventSignal.mjs +8 -7
- package/src/class/FileSafe.mjs +1 -1
- package/src/class/ListSignal.mjs +18 -10
- package/src/class/LitExp.mjs +241 -204
- package/src/class/Paths.mjs +10 -8
- package/src/class/QChannel.mjs +14 -7
- package/src/class/SafeExit.mjs +16 -7
- package/src/class/Signal.mjs +8 -7
- package/src/class/WorkerMainThread.mjs +45 -24
- package/src/class/WorkerMainThreadBundled.mjs +42 -24
- package/src/class/WorkerThread.mjs +21 -7
- package/src/common/Base64URL.mjs +2 -2
- package/src/common/Base64URLFromFile.mjs +1 -1
- package/src/doc/JSautoDOC.mjs +99 -62
- package/src/doc/correctBeforeParse.mjs +139 -0
- package/src/doc/parsedFile.mjs +127 -76
- package/src/function/CreateImmutable.mjs +12 -7
- package/src/function/GetRuntime.mjs +8 -3
- package/src/function/LazyFactory.mjs +10 -4
- package/src/function/Try.mjs +4 -1
- package/src/function/TryAsync.mjs +2 -1
- package/src/function/TrySync.mjs +3 -1
- package/src/function/TsToMjs.mjs +7 -4
- package/src/types/AnyButUndefined.mjs +1 -0
- package/src/types/LitExpResultType.mjs +7 -0
- package/src/types/Runtime.mjs +1 -1
- package/tsconfig.json +27 -5
- package/types/dev/workerThreadClass.d.mts +1 -1
- package/types/index.d.mts +2 -1
- package/types/src/bundler/CompileJS.d.mts +22 -11
- package/types/src/bundler/EsBundler.d.mts +1 -1
- package/types/src/class/Derived.d.mts +4 -64
- package/types/src/class/Effect.d.mts +8 -8
- package/types/src/class/EnvSignal.d.mts +0 -1
- package/types/src/class/EventSignal.d.mts +5 -5
- package/types/src/class/FileSafe.d.mts +2 -2
- package/types/src/class/ListSignal.d.mts +1 -1
- package/types/src/class/LitExp.d.mts +49 -53
- package/types/src/class/Paths.d.mts +4 -4
- package/types/src/class/QChannel.d.mts +1 -1
- package/types/src/class/SafeExit.d.mts +3 -3
- package/types/src/class/Signal.d.mts +3 -3
- package/types/src/class/WorkerMainThread.d.mts +13 -8
- package/types/src/class/WorkerMainThreadBundled.d.mts +13 -8
- package/types/src/class/WorkerThread.d.mts +4 -4
- package/types/src/common/Base64URL.d.mts +2 -2
- package/types/src/common/Base64URLFromFile.d.mts +2 -2
- package/types/src/doc/JSautoDOC.d.mts +33 -12
- package/types/src/doc/correctBeforeParse.d.mts +2 -0
- package/types/src/doc/parsedFile.d.mts +7 -10
- package/types/src/function/CreateImmutable.d.mts +2 -2
- package/types/src/function/Try.d.mts +2 -2
- package/types/src/function/TryAsync.d.mts +2 -2
- package/types/src/function/TrySync.d.mts +3 -2
- package/types/src/function/TsToMjs.d.mts +2 -2
- package/types/src/types/LitExpResultType.d.mts +7 -0
package/README.md
CHANGED
|
@@ -31,11 +31,15 @@ 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
|
|
|
@@ -62,6 +66,7 @@ npm i vivth
|
|
|
62
66
|
- [Base64URL](#base64url)
|
|
63
67
|
- [Base64URLFromFile](#base64urlfromfile)
|
|
64
68
|
- [EventNameSpace](#eventnamespace)
|
|
69
|
+
- [JSautoDOC](#jsautodoc)
|
|
65
70
|
- [CreateImmutable](#createimmutable)
|
|
66
71
|
- [EventCheck](#eventcheck)
|
|
67
72
|
- [EventObject](#eventobject)
|
|
@@ -73,12 +78,12 @@ npm i vivth
|
|
|
73
78
|
- [TryAsync](#tryasync)
|
|
74
79
|
- [TrySync](#trysync)
|
|
75
80
|
- [TsToMjs](#tstomjs)
|
|
76
|
-
- [JSautoDOC](#jsautodoc)
|
|
77
81
|
- [AnyButUndefined](#anybutundefined)
|
|
78
82
|
- [ExtnameType](#extnametype)
|
|
79
83
|
- [IsListSignal](#islistsignal)
|
|
80
84
|
- [ListArg](#listarg)
|
|
81
85
|
- [LitExpKeyType](#litexpkeytype)
|
|
86
|
+
- [LitExpResultType](#litexpresulttype)
|
|
82
87
|
- [MutationType](#mutationtype)
|
|
83
88
|
- [QCBFIFOReturn](#qcbfiforeturn)
|
|
84
89
|
- [QCBReturn](#qcbreturn)
|
|
@@ -128,10 +133,12 @@ npm i vivth
|
|
|
128
133
|
* - `key` are to used as `--keyName`;
|
|
129
134
|
* - value are the following value of the key;
|
|
130
135
|
* - no need to add the output/outdir, as it use the `options.outDir`;
|
|
131
|
-
* @
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
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
|
|
135
142
|
* }>>}
|
|
136
143
|
*/
|
|
137
144
|
```
|
|
@@ -149,7 +156,8 @@ npm i vivth
|
|
|
149
156
|
compiler: 'pkg',
|
|
150
157
|
compilerArguments: {
|
|
151
158
|
target: ['node18-win-x64'],
|
|
152
|
-
}
|
|
159
|
+
},
|
|
160
|
+
esBundlerPlugins: [],
|
|
153
161
|
}),
|
|
154
162
|
CompileJS({
|
|
155
163
|
entryPoint: join(Paths.root, '/dev'),
|
|
@@ -158,7 +166,8 @@ npm i vivth
|
|
|
158
166
|
compiler: 'bun',
|
|
159
167
|
compilerArguments: {
|
|
160
168
|
target: ['bun-win-x64'],
|
|
161
|
-
}
|
|
169
|
+
},
|
|
170
|
+
esBundlerPlugins: [],
|
|
162
171
|
}),
|
|
163
172
|
])
|
|
164
173
|
|
|
@@ -431,7 +440,7 @@ npm i vivth
|
|
|
431
440
|
```js
|
|
432
441
|
/**
|
|
433
442
|
* @param {(effectInstanceOptions:Omit<Effect["options"] &
|
|
434
|
-
* Derived["options"], unwrapLazy>) =>
|
|
443
|
+
* Derived<VALUE>["options"], unwrapLazy>) =>
|
|
435
444
|
* Promise<VALUE>} derivedFunction
|
|
436
445
|
*/
|
|
437
446
|
```
|
|
@@ -493,11 +502,13 @@ npm i vivth
|
|
|
493
502
|
|
|
494
503
|
#### reference:`Derived_instance.value:getter`
|
|
495
504
|
- the most recent value of the instance
|
|
496
|
-
- 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`);
|
|
497
507
|
|
|
498
508
|
```js
|
|
499
509
|
/**
|
|
500
|
-
* @returns {VALUE}
|
|
510
|
+
* @returns {VALUE}
|
|
511
|
+
* @override
|
|
501
512
|
*/
|
|
502
513
|
```
|
|
503
514
|
|
|
@@ -508,7 +519,8 @@ npm i vivth
|
|
|
508
519
|
```js
|
|
509
520
|
/**
|
|
510
521
|
* @private
|
|
511
|
-
* @type {VALUE}
|
|
522
|
+
* @type {VALUE}
|
|
523
|
+
* @override
|
|
512
524
|
*/
|
|
513
525
|
```
|
|
514
526
|
|
|
@@ -565,9 +577,9 @@ npm i vivth
|
|
|
565
577
|
|
|
566
578
|
```js
|
|
567
579
|
/**
|
|
568
|
-
* @template
|
|
569
|
-
* @param {
|
|
570
|
-
* @returns {
|
|
580
|
+
* @template V
|
|
581
|
+
* @param {Signal<V>} signal
|
|
582
|
+
* @returns {Signal<V>}
|
|
571
583
|
*/
|
|
572
584
|
```
|
|
573
585
|
- <i>example</i>:
|
|
@@ -655,7 +667,6 @@ npm i vivth
|
|
|
655
667
|
|
|
656
668
|
|
|
657
669
|
#### reference:`EnvSignal`
|
|
658
|
-
- non browser API;
|
|
659
670
|
- uses [Signal](#signal) and [Derived](#derived) under the hood;
|
|
660
671
|
|
|
661
672
|
```js
|
|
@@ -737,7 +748,7 @@ npm i vivth
|
|
|
737
748
|
|
|
738
749
|
```js
|
|
739
750
|
/**
|
|
740
|
-
* @type {Map<string, EventSignal
|
|
751
|
+
* @type {Map<string, EventSignal<any>>}
|
|
741
752
|
*/
|
|
742
753
|
```
|
|
743
754
|
|
|
@@ -750,7 +761,7 @@ npm i vivth
|
|
|
750
761
|
/**
|
|
751
762
|
* @param {string} stringName
|
|
752
763
|
* @param {IsListSignal} [isList_]
|
|
753
|
-
* @returns {Promise<EventSignal
|
|
764
|
+
* @returns {Promise<EventSignal<any>>}
|
|
754
765
|
*/
|
|
755
766
|
```
|
|
756
767
|
- <i>example</i>:
|
|
@@ -768,7 +779,7 @@ npm i vivth
|
|
|
768
779
|
|
|
769
780
|
```js
|
|
770
781
|
/**
|
|
771
|
-
* @type {Signal
|
|
782
|
+
* @type {Signal<any>|ListSignal<any>}
|
|
772
783
|
*/
|
|
773
784
|
```
|
|
774
785
|
- <i>example</i>:
|
|
@@ -793,7 +804,7 @@ npm i vivth
|
|
|
793
804
|
|
|
794
805
|
```js
|
|
795
806
|
/**
|
|
796
|
-
* @type {Derived
|
|
807
|
+
* @type {Derived<any>|ListDerived<any>}
|
|
797
808
|
*/
|
|
798
809
|
```
|
|
799
810
|
- <i>example</i>:
|
|
@@ -1040,7 +1051,7 @@ npm i vivth
|
|
|
1040
1051
|
/**
|
|
1041
1052
|
* @param {Parameters<mkdir>[0]} outDir
|
|
1042
1053
|
* - absolute path
|
|
1043
|
-
* @returns {ReturnType<typeof TryAsync<string>>}
|
|
1054
|
+
* @returns {ReturnType<typeof TryAsync<string|undefined>>}
|
|
1044
1055
|
*/
|
|
1045
1056
|
```
|
|
1046
1057
|
- <i>example</i>:
|
|
@@ -1148,7 +1159,8 @@ npm i vivth
|
|
|
1148
1159
|
|
|
1149
1160
|
```js
|
|
1150
1161
|
/**
|
|
1151
|
-
* @returns {LISTARG[]}
|
|
1162
|
+
* @returns {LISTARG[]}
|
|
1163
|
+
* @override
|
|
1152
1164
|
*/
|
|
1153
1165
|
```
|
|
1154
1166
|
|
|
@@ -1158,7 +1170,8 @@ npm i vivth
|
|
|
1158
1170
|
```js
|
|
1159
1171
|
/**
|
|
1160
1172
|
* @private
|
|
1161
|
-
* @type {LISTARG[]}
|
|
1173
|
+
* @type {LISTARG[]}
|
|
1174
|
+
* @override
|
|
1162
1175
|
*/
|
|
1163
1176
|
```
|
|
1164
1177
|
|
|
@@ -1315,6 +1328,25 @@ npm i vivth
|
|
|
1315
1328
|
*/
|
|
1316
1329
|
```
|
|
1317
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
|
+
|
|
1318
1350
|
#### reference:`LitExp.prepare`
|
|
1319
1351
|
- constructor helper;
|
|
1320
1352
|
- under the hood it is an abstraction of `RegExp`, with more template literal touch;
|
|
@@ -1371,25 +1403,25 @@ npm i vivth
|
|
|
1371
1403
|
|
|
1372
1404
|
```js
|
|
1373
1405
|
/**
|
|
1374
|
-
* @param {Partial<
|
|
1375
|
-
* @returns {string}
|
|
1406
|
+
* @param {Partial<{ [K in keyof KEYS]?: string }>} overrides
|
|
1407
|
+
* @returns {string|undefined}
|
|
1376
1408
|
*/
|
|
1377
1409
|
```
|
|
1378
1410
|
- <i>example</i>:
|
|
1379
|
-
```js
|
|
1380
|
-
import { LitExp } from 'vivth';
|
|
1381
|
-
|
|
1382
|
-
const [literal, errorPreparing] = LitExp.prepare({
|
|
1383
|
-
myKey: false,
|
|
1384
|
-
...keyCaptureLogicPair
|
|
1385
|
-
})
|
|
1386
|
-
|
|
1387
|
-
// asuming no error
|
|
1388
|
-
litExp_instance = `templateLiteral:${'myKey'};`;
|
|
1389
|
-
const [result, error] = litExp_instance.make.string({
|
|
1390
|
-
myKey: 'actualvalue',
|
|
1391
|
-
});
|
|
1392
|
-
|
|
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
|
+
|
|
1393
1425
|
console.log(result); // "templateLiteral:actualvalue;"
|
|
1394
1426
|
|
|
1395
1427
|
```
|
|
@@ -1403,48 +1435,48 @@ npm i vivth
|
|
|
1403
1435
|
|
|
1404
1436
|
```js
|
|
1405
1437
|
/**
|
|
1406
|
-
* @param {string} string
|
|
1407
|
-
* @param {Object} options
|
|
1408
|
-
* @param {ConstructorParameters<typeof RegExp>[1]} options.flags
|
|
1409
|
-
* @param {boolean} options.whiteSpaceSensitive
|
|
1410
|
-
* - true: leave any whitespace as is to be used as regex detection;
|
|
1411
|
-
* - false: convert all whitespace to `\s+`;
|
|
1412
|
-
* @param {boolean} options.absoluteLeadAndFollowing
|
|
1413
|
-
* - false: standard capture;
|
|
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;
|
|
1414
1446
|
* - true: add `^` and `<h2 id="litexp">LitExp</h2>
|
|
1415
1447
|
|
|
1416
|
-
to capture definition:
|
|
1417
|
-
* >- meaning string will have to match starting and end of line from capture definition;
|
|
1418
|
-
* @returns {ReturnType<typeof TrySync<{
|
|
1419
|
-
* result:{ whole:string, named: Record<keyof KEYS, string>},
|
|
1420
|
-
* regexp:RegExp}>>
|
|
1421
|
-
* }
|
|
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
|
+
* }
|
|
1422
1454
|
*/
|
|
1423
1455
|
```
|
|
1424
1456
|
- <i>example</i>:
|
|
1425
|
-
```js
|
|
1426
|
-
import { LitExp } from 'vivth';
|
|
1427
|
-
|
|
1428
|
-
const [literal, errorPreparing] = LitExp.prepare({
|
|
1429
|
-
myKey: false,
|
|
1430
|
-
...keyCaptureLogicPair
|
|
1431
|
-
})
|
|
1432
|
-
|
|
1433
|
-
// asuming no eror
|
|
1434
|
-
const litExp_instance = literal`templateLiteral:${'myKey'};`
|
|
1435
|
-
|
|
1436
|
-
const [{
|
|
1437
|
-
result:{ // asuming there's no error
|
|
1438
|
-
named: { myKey },
|
|
1439
|
-
whole,
|
|
1440
|
-
},
|
|
1441
|
-
regex, // for reference
|
|
1442
|
-
}, error] = litExp_instance.evaluate.execGroups(
|
|
1443
|
-
`templateLiteral:Something;`,
|
|
1444
|
-
{ ...options }
|
|
1445
|
-
)
|
|
1446
|
-
|
|
1447
|
-
console.log(whole); // "templateLiteral:Something;"
|
|
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;"
|
|
1448
1480
|
console.log(myKey); // "Something"
|
|
1449
1481
|
|
|
1450
1482
|
```
|
|
@@ -1454,50 +1486,45 @@ npm i vivth
|
|
|
1454
1486
|
|
|
1455
1487
|
```js
|
|
1456
1488
|
/**
|
|
1457
|
-
* @param {Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[0]} string
|
|
1458
|
-
* @param {Omit<Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[1], 'absoluteLeadAndFollowing'>} options
|
|
1459
|
-
* @returns {ReturnType<typeof TrySync<
|
|
1460
|
-
*
|
|
1461
|
-
* }
|
|
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
|
+
* }
|
|
1462
1493
|
*/
|
|
1463
1494
|
```
|
|
1464
1495
|
- <i>example</i>:
|
|
1465
|
-
```js
|
|
1466
|
-
import { LitExp, Console } from 'vivth';
|
|
1467
|
-
|
|
1468
|
-
const [literal, errorPreparing] = LitExp.prepare({
|
|
1469
|
-
myKey: false,
|
|
1470
|
-
...keyCaptureLogicPair
|
|
1471
|
-
})
|
|
1472
|
-
|
|
1473
|
-
// asuming no error;
|
|
1474
|
-
litExp_instance = literal`templateLiteral:${'myKey'};`
|
|
1475
|
-
|
|
1476
|
-
const [resultOfMatchedAllAndGrouped, error] = litExp_instance.evaluate.matchedAllAndGrouped(
|
|
1477
|
-
`templateLiteral:Something;
|
|
1478
|
-
templateLiteral:SomethingElse;`,
|
|
1479
|
-
{ ...options }
|
|
1480
|
-
)
|
|
1481
|
-
(()=>{
|
|
1482
|
-
if (error) {
|
|
1483
|
-
Console.error(error);
|
|
1484
|
-
return;
|
|
1485
|
-
}
|
|
1486
|
-
const {
|
|
1487
|
-
result: {
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
console.log(whole0); // "templateLiteral:Something;"
|
|
1498
|
-
console.log(whole1); // "templateLiteral:SomethingElse;"
|
|
1499
|
-
console.log(myKeyExec0); // "Something"
|
|
1500
|
-
console.log(myKeyExec1); // "SomethingElse"
|
|
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
|
+
})
|
|
1501
1528
|
})()
|
|
1502
1529
|
|
|
1503
1530
|
```
|
|
@@ -1557,7 +1584,7 @@ npm i vivth
|
|
|
1557
1584
|
|
|
1558
1585
|
```js
|
|
1559
1586
|
/**
|
|
1560
|
-
* @type {string}
|
|
1587
|
+
* @type {string|undefined}
|
|
1561
1588
|
*/
|
|
1562
1589
|
```
|
|
1563
1590
|
|
|
@@ -1761,7 +1788,7 @@ npm i vivth
|
|
|
1761
1788
|
|
|
1762
1789
|
```js
|
|
1763
1790
|
/**
|
|
1764
|
-
* @type {SafeExit}
|
|
1791
|
+
* @type {SafeExit|undefined}
|
|
1765
1792
|
*/
|
|
1766
1793
|
```
|
|
1767
1794
|
|
|
@@ -2053,7 +2080,7 @@ npm i vivth
|
|
|
2053
2080
|
|
|
2054
2081
|
```js
|
|
2055
2082
|
/**
|
|
2056
|
-
* @returns {VALUE}
|
|
2083
|
+
* @returns {VALUE|undefined}
|
|
2057
2084
|
*/
|
|
2058
2085
|
```
|
|
2059
2086
|
|
|
@@ -2111,7 +2138,7 @@ npm i vivth
|
|
|
2111
2138
|
|
|
2112
2139
|
```js
|
|
2113
2140
|
/**
|
|
2114
|
-
* @template {WorkerThread} WT
|
|
2141
|
+
* @template {WorkerThread<any, any>} WT
|
|
2115
2142
|
*/
|
|
2116
2143
|
```
|
|
2117
2144
|
|
|
@@ -2264,7 +2291,7 @@ npm i vivth
|
|
|
2264
2291
|
* (str, prevBufferEncoding) =>
|
|
2265
2292
|
* Buffer.from(str, prevBufferEncoding).toString('base64')
|
|
2266
2293
|
* ```
|
|
2267
|
-
* @returns {
|
|
2294
|
+
* @returns {string}
|
|
2268
2295
|
*/
|
|
2269
2296
|
```
|
|
2270
2297
|
- <i>example</i>:
|
|
@@ -2290,7 +2317,7 @@ npm i vivth
|
|
|
2290
2317
|
```js
|
|
2291
2318
|
/**
|
|
2292
2319
|
* @param {string} filePath
|
|
2293
|
-
* @returns {Promise<
|
|
2320
|
+
* @returns {Promise<string>}
|
|
2294
2321
|
*/
|
|
2295
2322
|
```
|
|
2296
2323
|
- <i>example</i>:
|
|
@@ -2319,6 +2346,63 @@ npm i vivth
|
|
|
2319
2346
|
|
|
2320
2347
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2321
2348
|
|
|
2349
|
+
<h2 id="jsautodoc">JSautoDOC</h2>
|
|
2350
|
+
|
|
2351
|
+
|
|
2352
|
+
#### reference:`JSautoDOC`
|
|
2353
|
+
- class for auto documenting mjs package/project, using jsdoc;
|
|
2354
|
+
- this autodocumenter uses [chokidar](https://npmjs.com/package/chokidar) under the hood;
|
|
2355
|
+
- this class also is used to generate this `README.md`;
|
|
2356
|
+
- behaviours:
|
|
2357
|
+
>1) add `"at"noautodoc` on self closing jsdoc comment to opt out from generating documentation on said file;
|
|
2358
|
+
>>- auto export must follows the following rules, and there's no way to override;
|
|
2359
|
+
>2) export all named exported 'const'|'function'|'async function'|'class', alphanumeric name, started with Capital letter, same name with fileName on `options.pahts.file`;
|
|
2360
|
+
>3) declare typedef of existing typedef with alphanumeric name, started with Capital letter, same name with fileName, and have no valid export like on point <sup>1</sup> on `options.pahts.file`;
|
|
2361
|
+
>4) create `README.md` based on, `options.paths.dir` and `README.src.md`;
|
|
2362
|
+
>5) extract `"at"description` jsdoc:
|
|
2363
|
+
>>- on static/prop that have depths, all of children should have `"at"static`/`"at"instance` `nameOfImmediateParent`, same block but before `"at"description` comment line;
|
|
2364
|
+
>>- `"at"description` are treated as plain `markdown`;
|
|
2365
|
+
>>- first `"at"${string}` after `"at"description` until `"at"example` will be treated as `javascript` comment block on the `markdown`;
|
|
2366
|
+
>>- `"at"example` are treated as `javascript` block on the `markdown` file, and should be placed last on the same comment block;
|
|
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
|
+
|
|
2372
|
+
|
|
2373
|
+
#### reference:`new JSautoDOC`
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
```js
|
|
2377
|
+
/**
|
|
2378
|
+
* @param {Object} [options]
|
|
2379
|
+
* @param {Object} [options.paths]
|
|
2380
|
+
* @param {string} options.paths.file
|
|
2381
|
+
* - entry point;
|
|
2382
|
+
* @param {string} options.paths.readMe
|
|
2383
|
+
* - readme target;
|
|
2384
|
+
* @param {string} options.paths.dir
|
|
2385
|
+
* - source directory;
|
|
2386
|
+
* @param {string} [options.copyright]
|
|
2387
|
+
* @param {string} [options.tableOfContentTitle]
|
|
2388
|
+
* @param {import('chokidar').ChokidarOptions} [options.option]
|
|
2389
|
+
* - ChokidarOptions;
|
|
2390
|
+
*/
|
|
2391
|
+
```
|
|
2392
|
+
- <i>example</i>:
|
|
2393
|
+
```js
|
|
2394
|
+
import { JSautoDOC } from 'vivth';
|
|
2395
|
+
|
|
2396
|
+
new JSautoDOC({
|
|
2397
|
+
paths: { dir: 'src', file: 'index.mjs', readMe: 'README.md' },
|
|
2398
|
+
copyright: 'this library is made and distributed under MIT license;',
|
|
2399
|
+
tableOfContentTitle: 'list of exported API and typehelpers',
|
|
2400
|
+
});
|
|
2401
|
+
|
|
2402
|
+
```
|
|
2403
|
+
|
|
2404
|
+
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2405
|
+
|
|
2322
2406
|
<h2 id="createimmutable">CreateImmutable</h2>
|
|
2323
2407
|
|
|
2324
2408
|
|
|
@@ -2555,7 +2639,7 @@ npm i vivth
|
|
|
2555
2639
|
* @param {RecordTryType} tryRecord
|
|
2556
2640
|
* @returns {Promise<
|
|
2557
2641
|
* [[keyof RecordTryType, RETURNTYPE], undefined]
|
|
2558
|
-
* | [[undefined, undefined], Error]
|
|
2642
|
+
* | [[undefined, undefined], Error|undefined]
|
|
2559
2643
|
* >}
|
|
2560
2644
|
*/
|
|
2561
2645
|
```
|
|
@@ -2606,7 +2690,7 @@ npm i vivth
|
|
|
2606
2690
|
/**
|
|
2607
2691
|
* @template RESULT
|
|
2608
2692
|
* @param {()=>Promise<RESULT>} asyncFunction_
|
|
2609
|
-
* @returns {Promise<[RESULT|undefined,
|
|
2693
|
+
* @returns {Promise<[RESULT,undefined]|[undefined,Error]>}
|
|
2610
2694
|
*/
|
|
2611
2695
|
```
|
|
2612
2696
|
- <i>example</i>:
|
|
@@ -2639,7 +2723,8 @@ npm i vivth
|
|
|
2639
2723
|
/**
|
|
2640
2724
|
* @template RESULT
|
|
2641
2725
|
* @param {()=>RESULT} function_
|
|
2642
|
-
* @returns {[RESULT
|
|
2726
|
+
* @returns {[RESULT,undefined]|
|
|
2727
|
+
* [undefined,Error]}
|
|
2643
2728
|
*/
|
|
2644
2729
|
```
|
|
2645
2730
|
- <i>example</i>:
|
|
@@ -2686,60 +2771,6 @@ npm i vivth
|
|
|
2686
2771
|
|
|
2687
2772
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2688
2773
|
|
|
2689
|
-
<h2 id="jsautodoc">JSautoDOC</h2>
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
#### reference:`JSautoDOC`
|
|
2693
|
-
- class for auto documenting mjs package/project, using jsdoc;
|
|
2694
|
-
- this autodocumenter uses [chokidar](https://npmjs.com/package/chokidar) under the hood;
|
|
2695
|
-
- this class also is used to generate this `README.md`;
|
|
2696
|
-
- behaviours:
|
|
2697
|
-
>1) add `"at"noautodoc` on self closing jsdoc comment to opt out from generating documentation on said file;
|
|
2698
|
-
>>- auto export must follows the following rules, and there's no way to override;
|
|
2699
|
-
>2) export all named exported 'const'|'function'|'async function'|'class', alphanumeric name, started with Capital letter, same name with fileName on `options.pahts.file`;
|
|
2700
|
-
>3) declare typedef of existing typedef with alphanumeric name, started with Capital letter, same name with fileName, and have no valid export like on point <sup>1</sup> on `options.pahts.file`;
|
|
2701
|
-
>4) create `README.md` based on, `options.paths.dir` and `README.src.md`;
|
|
2702
|
-
>5) extract `"at"description` jsdoc:
|
|
2703
|
-
>>- on static/prop that have depths, all of children should have `"at"static`/`"at"instance` `nameOfImmediateParent`, same block but before `"at"description` comment line;
|
|
2704
|
-
>>- `"at"description` are treated as plain `markdown`;
|
|
2705
|
-
>>- first `"at"${string}` after `"at"description` until `"at"example` will be treated as `javascript` comment block on the `markdown`;
|
|
2706
|
-
>>- `"at"example` are treated as `javascript` block on the `markdown` file, and should be placed last on the same comment block;
|
|
2707
|
-
>>- you can always look at `vivth/src` files to check how the source, and the `README.md` and `index.mjs` documentation/generation results;
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
#### reference:`new JSautoDOC`
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
```js
|
|
2714
|
-
/**
|
|
2715
|
-
* @param {Object} [options]
|
|
2716
|
-
* @param {Object} [options.paths]
|
|
2717
|
-
* @param {string} [options.paths.file]
|
|
2718
|
-
* - entry point;
|
|
2719
|
-
* @param {string} [options.paths.readMe]
|
|
2720
|
-
* - readme target;
|
|
2721
|
-
* @param {string} [options.paths.dir]
|
|
2722
|
-
* - source directory;
|
|
2723
|
-
* @param {string} [options.copyright]
|
|
2724
|
-
* @param {string} [options.tableOfContentTitle]
|
|
2725
|
-
* @param {import('chokidar').ChokidarOptions} [options.option]
|
|
2726
|
-
* - ChokidarOptions;
|
|
2727
|
-
*/
|
|
2728
|
-
```
|
|
2729
|
-
- <i>example</i>:
|
|
2730
|
-
```js
|
|
2731
|
-
import { JSautoDOC } from 'vivth';
|
|
2732
|
-
|
|
2733
|
-
new JSautoDOC({
|
|
2734
|
-
paths: { dir: 'src', file: 'index.mjs', readMe: 'README.md' },
|
|
2735
|
-
copyright: 'this library is made and distributed under MIT license;',
|
|
2736
|
-
tableOfContentTitle: 'list of exported API and typehelpers',
|
|
2737
|
-
});
|
|
2738
|
-
|
|
2739
|
-
```
|
|
2740
|
-
|
|
2741
|
-
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2742
|
-
|
|
2743
2774
|
<h2 id="anybutundefined">AnyButUndefined</h2>
|
|
2744
2775
|
|
|
2745
2776
|
- jsdoc types:
|
|
@@ -2799,6 +2830,19 @@ npm i vivth
|
|
|
2799
2830
|
```
|
|
2800
2831
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2801
2832
|
|
|
2833
|
+
<h2 id="litexpresulttype">LitExpResultType</h2>
|
|
2834
|
+
|
|
2835
|
+
- jsdoc types:
|
|
2836
|
+
|
|
2837
|
+
```js
|
|
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
|
|
2842
|
+
*/
|
|
2843
|
+
```
|
|
2844
|
+
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2845
|
+
|
|
2802
2846
|
<h2 id="mutationtype">MutationType</h2>
|
|
2803
2847
|
|
|
2804
2848
|
- jsdoc types:
|
|
@@ -2926,7 +2970,7 @@ npm i vivth
|
|
|
2926
2970
|
|
|
2927
2971
|
```js
|
|
2928
2972
|
/**
|
|
2929
|
-
* @param {WorkerThread["handler"]} handler
|
|
2973
|
+
* @param {WorkerThread<RECEIVE, POST>["handler"]} handler
|
|
2930
2974
|
*/
|
|
2931
2975
|
```
|
|
2932
2976
|
- <i>example</i>:
|
|
@@ -2955,24 +2999,6 @@ npm i vivth
|
|
|
2955
2999
|
*/
|
|
2956
3000
|
```
|
|
2957
3001
|
|
|
2958
|
-
#### reference:`WorkerThread_instance.RECEIVE`
|
|
2959
|
-
- helper type, hold no actual value;
|
|
2960
|
-
|
|
2961
|
-
```js
|
|
2962
|
-
/**
|
|
2963
|
-
* @type {RECEIVE}
|
|
2964
|
-
*/
|
|
2965
|
-
```
|
|
2966
|
-
|
|
2967
|
-
#### reference:`WorkerThread_instance.POST`
|
|
2968
|
-
- helper type, hold no actual value;
|
|
2969
|
-
|
|
2970
|
-
```js
|
|
2971
|
-
/**
|
|
2972
|
-
* @type {POST}
|
|
2973
|
-
*/
|
|
2974
|
-
```
|
|
2975
|
-
|
|
2976
3002
|
*) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
|
|
2977
3003
|
|
|
2978
3004
|
<h2 id="tobundledjsplugin">ToBundledJSPlugin</h2>
|