vivth 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -39,12 +39,11 @@ npm i vivth
39
39
 
40
40
  <h2 id="list-of-exported-api-and-typehelpers">list of exported API and typehelpers</h2>
41
41
 
42
- - [CompileJS](#compilejs)
43
42
  - [CreateESPlugin](#createesplugin)
44
43
  - [EsBundler](#esbundler)
45
44
  - [FSInline](#fsinline)
46
45
  - [FSInlineAnalyzer](#fsinlineanalyzer)
47
- - [Console](#console)
46
+ - [CompileJS](#compilejs)
48
47
  - [Derived](#derived)
49
48
  - [Effect](#effect)
50
49
  - [EnvSignal](#envsignal)
@@ -52,120 +51,42 @@ npm i vivth
52
51
  - [FileSafe](#filesafe)
53
52
  - [ListDerived](#listderived)
54
53
  - [ListSignal](#listsignal)
55
- - [LitExp](#litexp)
56
54
  - [Paths](#paths)
57
55
  - [QChannel](#qchannel)
58
56
  - [SafeExit](#safeexit)
59
57
  - [Setup](#setup)
60
58
  - [Signal](#signal)
61
59
  - [WorkerMainThread](#workermainthread)
62
- - [Base64URL](#base64url)
60
+ - [Console](#console)
63
61
  - [Base64URLFromFile](#base64urlfromfile)
64
62
  - [EventNameSpace](#eventnamespace)
65
63
  - [JSautoDOC](#jsautodoc)
66
- - [CreateImmutable](#createimmutable)
67
- - [EventCheck](#eventcheck)
68
- - [EventObject](#eventobject)
69
- - [GetRuntime](#getruntime)
70
- - [IsAsync](#isasync)
71
- - [LazyFactory](#lazyfactory)
72
- - [Timeout](#timeout)
73
- - [Try](#try)
74
- - [TryAsync](#tryasync)
75
- - [TrySync](#trysync)
76
- - [TsToMjs](#tstomjs)
77
64
  - [AnyButUndefined](#anybutundefined)
78
65
  - [ExtnameType](#extnametype)
79
66
  - [IsListSignal](#islistsignal)
67
+ - [LitExp](#litexp)
80
68
  - [ListArg](#listarg)
81
69
  - [LitExpKeyType](#litexpkeytype)
82
70
  - [MutationType](#mutationtype)
83
71
  - [QCBFIFOReturn](#qcbfiforeturn)
84
72
  - [QCBReturn](#qcbreturn)
85
73
  - [Runtime](#runtime)
74
+ - [EventCheck](#eventcheck)
75
+ - [EventObject](#eventobject)
76
+ - [IsAsync](#isasync)
77
+ - [GetRuntime](#getruntime)
78
+ - [LazyFactory](#lazyfactory)
79
+ - [Timeout](#timeout)
80
+ - [Try](#try)
81
+ - [TryAsync](#tryasync)
82
+ - [TrySync](#trysync)
83
+ - [TsToMjs](#tstomjs)
84
+ - [Base64URL](#base64url)
85
+ - [CreateImmutable](#createimmutable)
86
86
  - [WorkerResult](#workerresult)
87
87
  - [WorkerThread](#workerthread)
88
88
  - [ToBundledJSPlugin](#tobundledjsplugin)
89
89
 
90
- <h2 id="compilejs">CompileJS</h2>
91
-
92
-
93
- #### reference:`CompileJS`
94
- - function to compile `.ts`|`.mts`|`.mjs` file, into a single executable;
95
- - also generate js representation;
96
- - 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;
97
- >- they are used only as packaging agent, and doesn't necessarily supports their advanced feature, such as, assets bundling(use [FSInline](#fsinline) instead);
98
- >- `WorkerThread` will be converted to inline using `FSInline` too;
99
-
100
- !!!WARNING!!!
101
- !!!WARNING!!!
102
- !!!WARNING!!!
103
-
104
- - This function does not obfuscate and will not prevent decompilation. Do not embed environment variables or sensitive information inside `options.entryPoint`;
105
- - It is designed for quick binarization, allowing execution on machines without `Node.js`, `Bun`, or `Deno` installed;
106
- - 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);
107
-
108
- !!!WARNING!!!
109
- !!!WARNING!!!
110
- !!!WARNING!!!
111
-
112
- ```js
113
- /**
114
- * @param {Object} options
115
- * @param {string} options.entryPoint
116
- * - need to be manually prefixed;
117
- * @param {BufferEncoding} [options.encoding]
118
- * - write and read encoding for the sources;
119
- * - default: `utf-8`;
120
- * @param {boolean} options.minifyFirst
121
- * - minify the bundle before compilation;
122
- * @param {string} options.outDir
123
- * - need manual prefix;
124
- * @param {'pkg'|'bun'|'deno'} [options.compiler]
125
- * - default: no comilation, just bundling;
126
- * - `bun` and `pkg` is checked, if there's bug on `deno`, please report on github for issues;
127
- * @param {Record<string, string>} [options.compilerArguments]
128
- * - `key` are to used as `--keyName`;
129
- * - value are the following value of the key;
130
- * - no need to add the output/outdir, as it use the `options.outDir`;
131
- * @return {ReturnType<TryAsync<{compileResult:Promise<any>,
132
- * commandCalled: string;
133
- * compiledBinFile: string;
134
- * bundledJSFile:string
135
- * }>>}
136
- */
137
- ```
138
- - <i>example</i>:
139
- ```js
140
- import { join } from 'node:path';
141
-
142
- import { CompileJS, Paths } from 'vivth';
143
-
144
- const [[resultPkg, errorPkg], [resultBun, errorBun]] = await Promise.all([
145
- CompileJS({
146
- entryPoint: join(Paths.root, '/dev'),
147
- minifyFirst: true,
148
- outDir: join(Paths.root, '/dev-pkg'),
149
- compiler: 'pkg',
150
- compilerArguments: {
151
- target: ['node18-win-x64'],
152
- }
153
- }),
154
- CompileJS({
155
- entryPoint: join(Paths.root, '/dev'),
156
- minifyFirst: true,
157
- outDir: join(Paths.root, '/dev-pkg'),
158
- compiler: 'bun',
159
- compilerArguments: {
160
- target: ['bun-win-x64'],
161
- }
162
- }),
163
- ])
164
-
165
- ```
166
-
167
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
168
-
169
90
  <h2 id="createesplugin">CreateESPlugin</h2>
170
91
 
171
92
 
@@ -327,86 +248,84 @@ npm i vivth
327
248
 
328
249
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
329
250
 
330
- <h2 id="console">Console</h2>
331
-
332
-
333
- #### reference:`Console`
334
- - class with static methods to print to standard console with bare minimum ANSI styles;
335
-
336
-
337
- #### reference:`Console.log`
251
+ <h2 id="compilejs">CompileJS</h2>
338
252
 
339
253
 
340
- ```js
341
- /**
342
- * @param {any} data
343
- * @returns {void}
344
- */
345
- ```
346
- - <i>example</i>:
347
- ```js
348
- import { Console } from 'vivth';
349
-
350
- Console.log({
351
- hello: 'world!!',
352
- });
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;
353
260
 
354
- ```
355
-
356
- #### reference:`Console.info`
357
-
358
-
359
- ```js
360
- /**
361
- * @param {any} data
362
- * @returns {void}
363
- */
364
- ```
365
- - <i>example</i>:
366
- ```js
367
- import { Console } from 'vivth';
368
-
369
- Console.info({
370
- hello: 'world!!',
371
- });
261
+ !!!WARNING!!!
262
+ !!!WARNING!!!
263
+ !!!WARNING!!!
372
264
 
373
- ```
374
-
375
- #### reference:`Console.warn`
376
-
377
-
378
- ```js
379
- /**
380
- * @param {any} data
381
- * @returns {void}
382
- */
383
- ```
384
- - <i>example</i>:
385
- ```js
386
- import { Console } from 'vivth';
387
-
388
- Console.warn({
389
- hello: 'world!!',
390
- });
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);
391
268
 
392
- ```
393
-
394
- #### reference:`Console.error`
395
-
269
+ !!!WARNING!!!
270
+ !!!WARNING!!!
271
+ !!!WARNING!!!
396
272
 
397
273
  ```js
398
274
  /**
399
- * @param {any} data
400
- * @returns {void}
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
+ * }>>}
401
299
  */
402
300
  ```
403
301
  - <i>example</i>:
404
- ```js
405
- import { Console } from 'vivth';
406
-
407
- Console.error({
408
- hello: 'world!!',
409
- });
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
+ ])
410
329
 
411
330
  ```
412
331
 
@@ -1297,224 +1216,17 @@ npm i vivth
1297
1216
 
1298
1217
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
1299
1218
 
1300
- <h2 id="litexp">LitExp</h2>
1219
+ <h2 id="paths">Paths</h2>
1301
1220
 
1302
1221
 
1303
- #### reference:`LitExp`
1304
- - class helper to created opionated regex helper;
1305
- - named capture uses `es6+` feature, you might need to add polyfill to target extremely old browser;
1306
- - class name refer to `Literal Expression`;
1307
- - please be patient when using this class;
1308
- >- destructuring is meant for extensive typehelper;
1309
- >- and destructuring can lead to unhandled error here and there;
1310
- >- therefore error as value is introduced to help to prevent error on runtime;
1311
-
1312
- ```js
1313
- /**
1314
- * @template {LitExpKeyType} KEYS
1315
- */
1316
- ```
1317
-
1318
- #### reference:`LitExp.prepare`
1319
- - constructor helper;
1320
- - under the hood it is an abstraction of `RegExp`, with more template literal touch;
1321
- >- you can apply inline `RegExp` features on the string template literal(as constructor RegExp arg0);
1322
- >>- by doing so you are opting in to make:
1323
- >>>- your regex detection more robust; but
1324
- >>>- `litExp_instance.make.string` to be `unusable`;
1325
- >>- also mind the needs of escape for special characters;
1326
-
1327
- ```js
1328
- /**
1329
- * @template {LitExpKeyType} KEYS
1330
- * @param {KEYS} keysAndDefaultValuePair
1331
- * - keys and whether to override regex detection;
1332
- * >- example:
1333
- * ```js
1334
- * myKey: /myCustomCapture/ // all flags will be stripped;
1335
- * ```
1336
- * - default value === `false` is "[\\s\\S]
1337
- *?", as in whiteSpace and nonWhiteSpace 0 to more occurence;
1338
- * @returns {ReturnType<typeof TrySync<(templateStringArray:TemplateStringsArray,
1339
- * ...values:(keyof KEYS)[]
1340
- * )=>LitExp<KEYS>>>}
1341
- * - placement of `key` will determine the named capture group will be placed in the template literal;
1342
- * - 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;
1343
- */
1344
- ```
1345
- - <i>example</i>:
1346
- ```js
1347
- import { LitExp } from 'vivth';
1348
-
1349
- (()=>{
1350
- const [liteal, errorPrep] = LitExp.prepare({
1351
- myKey: /myCustomCapture/, // is placed on (?<myKey>myCustomCapture)
1352
- // use false to place "[\\s\\S]*?" instead;
1353
- ...keyCaptureLogicPair
1354
- })
1355
- if (errorPrep) {
1356
- console.error(error);
1357
- return;
1358
- }
1359
- const litExp_instance = liteal`templateLiteral:${'myKey'};`
1360
- // recommended to end the template literal with any string but `key`;
1361
- })()
1362
-
1363
- ```
1364
-
1365
- #### reference:`LitExp_instance.make`
1366
- - instance methods for generating things;
1367
-
1368
-
1369
- #### reference:`LitExp_instance.make.string`
1370
- - to make string based on the template literal;
1371
-
1372
- ```js
1373
- /**
1374
- * @param {Partial<ReturnType<LitExp<KEYS>["evaluate"]["execGroups"]>>[0]["result"]} overrides
1375
- * @returns {string}
1376
- */
1377
- ```
1378
- - <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
-
1393
- console.log(result); // "templateLiteral:actualvalue;"
1394
-
1395
- ```
1396
-
1397
- #### reference:`LitExp_instance.evaluate`
1398
- - methods collections to evaluate string with `Literal Expression`;
1399
-
1400
-
1401
- #### reference:`LitExp_instance.evaluate.execGroups`
1402
- - to exec and grouped based on `key`;
1403
-
1404
- ```js
1405
- /**
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;
1414
- * - true: add `^` and `<h2 id="litexp">LitExp</h2>
1415
-
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
- * }
1422
- */
1423
- ```
1424
- - <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;"
1448
- console.log(myKey); // "Something"
1449
-
1450
- ```
1451
-
1452
- #### reference:`LitExp_instance.evaluate.matchedAllAndGrouped`
1453
- - to match all and grouped based on `key`;
1454
-
1455
- ```js
1456
- /**
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<{result:{whole:string[], named:Array<Record<keyof KEYS, string>>},
1460
- * regexp: RegExp}>>
1461
- * }
1462
- */
1463
- ```
1464
- - <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
- whole: [whole0, whole1],
1489
- named: [
1490
- { myKey: myKeyExec0, },
1491
- { myKey: myKeyExec1, },
1492
- ],
1493
- },
1494
- regexp
1495
- } = resultOfMatchedAllAndGrouped;
1496
-
1497
- console.log(whole0); // "templateLiteral:Something;"
1498
- console.log(whole1); // "templateLiteral:SomethingElse;"
1499
- console.log(myKeyExec0); // "Something"
1500
- console.log(myKeyExec1); // "SomethingElse"
1501
- })()
1502
-
1503
- ```
1504
-
1505
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
1506
-
1507
- <h2 id="paths">Paths</h2>
1508
-
1509
-
1510
- #### reference:`Paths`
1511
- - class helpers to define pathReference;
1512
- - is a singleton;
1513
- - most of functionality need to access `Paths.root`, if you get warning, you can instantiate `Paths` before running anything;
1514
-
1515
-
1516
- #### reference:`new Paths`
1517
-
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
+
1227
+
1228
+ #### reference:`new Paths`
1229
+
1518
1230
 
1519
1231
  ```js
1520
1232
  /**
@@ -2129,16 +1841,13 @@ npm i vivth
2129
1841
  * @param {typeof WorkerMainThread["pathValidator"]} param0.pathValidator
2130
1842
  * - example:
2131
1843
  * ```js
2132
- * async (workerPath, root, base) => {
1844
+ * async (workerPath, root) => {
2133
1845
  * const truePathCheck = `${root}/${base}/${workerPath}`;
2134
1846
  * const res = await fetch(truePathCheck);
2135
1847
  * // might also check wheter it need base or not
2136
1848
  * return await res.ok;
2137
1849
  * }
2138
1850
  * ```
2139
- * @param {typeof WorkerMainThread["basePath"]} [param0.basePath]
2140
- * - additonal realtivePath from rootPath;
2141
- * - default: '';
2142
1851
  */
2143
1852
  ```
2144
1853
  - <i>example</i>:
@@ -2148,11 +1857,15 @@ npm i vivth
2148
1857
 
2149
1858
  WorkerMainThread.setup({
2150
1859
  workerClass: Worker,
2151
- basePath: 'public/assets/js/workers',
2152
- pathValidator: async (workerPath, root, base) => {
2153
- const res = await fetch(`${root}/${base}/${workerPath}`);
2154
- // might also check wheter it need base or not
2155
- return await res.ok;
1860
+ pathValidator: async ({worker, root}) => {
1861
+ const res = await fetch(`${root}/${worker}`);
1862
+ if (res.ok) {
1863
+ return res
1864
+ }
1865
+ const res2 = await fetch(`${root}/someAdditionalPath/${worker}`);
1866
+ if (res2.ok) {
1867
+ return res2
1868
+ }
2156
1869
  },
2157
1870
  });
2158
1871
 
@@ -2168,23 +1881,13 @@ npm i vivth
2168
1881
  */
2169
1882
  ```
2170
1883
 
2171
- #### reference:`WorkerMainThread.basePath`
2172
- - reference for worker file `basePath`;
2173
- - edit via `setup`;
2174
-
2175
- ```js
2176
- /**
2177
- * @type {string}
2178
- */
2179
- ```
2180
-
2181
1884
  #### reference:`WorkerMainThread.pathValidator`
2182
1885
  - reference for validating path;
2183
1886
  - edit via `setup`;
2184
1887
 
2185
1888
  ```js
2186
1889
  /**
2187
- * @type {(paths:{worker: string, root:string, base: string})=>Promise<string>}
1890
+ * @type {(paths:{worker: string, root:string})=>Promise<string>}
2188
1891
  */
2189
1892
  ```
2190
1893
 
@@ -2254,38 +1957,90 @@ npm i vivth
2254
1957
 
2255
1958
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2256
1959
 
2257
- <h2 id="base64url">Base64URL</h2>
1960
+ <h2 id="console">Console</h2>
2258
1961
 
2259
1962
 
2260
- #### reference:`Base64URL`
2261
- - create inline base64 url;
2262
- - usage:
2263
- >- can be extremely usefull to display file on desktop app webview, without exposing http server;
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
+
2264
1969
 
2265
1970
  ```js
2266
1971
  /**
2267
- * @param {string} fileString
2268
- * @param {string} mimeType
2269
- * @param {(string:string)=>string} btoaFunction
2270
- * - check your js runtime `btoa`;
2271
- * - node compatible:
2272
- * ```js
2273
- * (str, prevBufferEncoding) =>
2274
- * Buffer.from(str, prevBufferEncoding).toString('base64')
2275
- * ```
2276
- * @returns {Base64URLString}
1972
+ * @param {any} data
1973
+ * @returns {void}
2277
1974
  */
2278
1975
  ```
2279
1976
  - <i>example</i>:
2280
- ```js
2281
- import { Base64URL } from 'vivth'
2282
- import fileString from './fileString.mjs';
2283
-
2284
- Base64URL(fileString, 'application/javascript', btoa);
1977
+ ```js
1978
+ import { Console } from 'vivth';
1979
+
1980
+ Console.log({
1981
+ hello: 'world!!',
1982
+ });
2285
1983
 
2286
1984
  ```
2287
1985
 
2288
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
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
+ ```
2023
+
2024
+ #### reference:`Console.error`
2025
+
2026
+
2027
+ ```js
2028
+ /**
2029
+ * @param {any} data
2030
+ * @returns {void}
2031
+ */
2032
+ ```
2033
+ - <i>example</i>:
2034
+ ```js
2035
+ import { Console } from 'vivth';
2036
+
2037
+ Console.error({
2038
+ hello: 'world!!',
2039
+ });
2040
+
2041
+ ```
2042
+
2043
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2289
2044
 
2290
2045
  <h2 id="base64urlfromfile">Base64URLFromFile</h2>
2291
2046
 
@@ -2349,74 +2104,354 @@ npm i vivth
2349
2104
  >>- you can always look at `vivth/src` files to check how the source, and the `README.md` and `index.mjs` documentation/generation results;
2350
2105
 
2351
2106
 
2352
- #### reference:`new JSautoDOC`
2107
+ #### reference:`new JSautoDOC`
2108
+
2109
+
2110
+ ```js
2111
+ /**
2112
+ * @param {Object} [options]
2113
+ * @param {Object} [options.paths]
2114
+ * @param {string} [options.paths.file]
2115
+ * - entry point;
2116
+ * @param {string} [options.paths.readMe]
2117
+ * - readme target;
2118
+ * @param {string} [options.paths.dir]
2119
+ * - source directory;
2120
+ * @param {string} [options.copyright]
2121
+ * @param {string} [options.tableOfContentTitle]
2122
+ * @param {import('chokidar').ChokidarOptions} [options.option]
2123
+ * - ChokidarOptions;
2124
+ */
2125
+ ```
2126
+ - <i>example</i>:
2127
+ ```js
2128
+ import { JSautoDOC } from 'vivth';
2129
+
2130
+ new JSautoDOC({
2131
+ paths: { dir: 'src', file: 'index.mjs', readMe: 'README.md' },
2132
+ copyright: 'this library is made and distributed under MIT license;',
2133
+ tableOfContentTitle: 'list of exported API and typehelpers',
2134
+ });
2135
+
2136
+ ```
2137
+
2138
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2139
+
2140
+ <h2 id="anybutundefined">AnyButUndefined</h2>
2141
+
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;
2187
+
2188
+ ```js
2189
+ /**
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
+ * }
2338
+ */
2339
+ ```
2340
+ - <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
+ })()
2378
+
2379
+ ```
2380
+
2381
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2382
+
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>
2353
2433
 
2434
+ - jsdoc types:
2354
2435
 
2355
2436
  ```js
2356
- /**
2357
- * @param {Object} [options]
2358
- * @param {Object} [options.paths]
2359
- * @param {string} [options.paths.file]
2360
- * - entry point;
2361
- * @param {string} [options.paths.readMe]
2362
- * - readme target;
2363
- * @param {string} [options.paths.dir]
2364
- * - source directory;
2365
- * @param {string} [options.copyright]
2366
- * @param {string} [options.tableOfContentTitle]
2367
- * @param {import('chokidar').ChokidarOptions} [options.option]
2368
- * - ChokidarOptions;
2437
+ /**
2438
+ * - return type of Q callback;
2439
+ * @typedef {{resume:()=>void, isLastOnQ:()=>boolean}} QCBReturn
2369
2440
  */
2370
2441
  ```
2371
- - <i>example</i>:
2372
- ```js
2373
- import { JSautoDOC } from 'vivth';
2374
-
2375
- new JSautoDOC({
2376
- paths: { dir: 'src', file: 'index.mjs', readMe: 'README.md' },
2377
- copyright: 'this library is made and distributed under MIT license;',
2378
- tableOfContentTitle: 'list of exported API and typehelpers',
2379
- });
2380
-
2381
- ```
2382
-
2383
2442
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2384
2443
 
2385
- <h2 id="createimmutable">CreateImmutable</h2>
2386
-
2444
+ <h2 id="runtime">Runtime</h2>
2387
2445
 
2388
- #### reference:`CreateImmutable`
2389
- - function for create immutable object;
2390
- - usefull for binding immutable object to global for shared object:
2391
- >- e.g. to window object in browser;
2446
+ - jsdoc types:
2392
2447
 
2393
2448
  ```js
2394
- /**
2395
- * @template {Object} PARENT
2396
- * @template {Object} OBJECT
2397
- * @param {string} keyName
2398
- * @param {PARENT} parent
2399
- * @param {(this:PARENT)=>OBJECT} object
2400
- * @param {Object} [options]
2401
- * @param {boolean} [options.lazy]
2402
- * @return {OBJECT}
2449
+ /**
2450
+ * @description
2451
+ * - for popular runtimes check;
2452
+ * @typedef {'node' | 'bun' | 'deno' | 'browser' | 'unknown'} Runtime
2403
2453
  */
2404
2454
  ```
2405
- - <i>example</i>:
2406
- ```js
2407
- import { CreateImmutable } from 'vivth';
2408
-
2409
- const mappedObject = new Map();
2410
-
2411
- CreateImmutable(window, 'mySharedObject', {
2412
- setMap(name_, value) => {
2413
- mappedObject.set(name_, value)
2414
- },
2415
- getMap(name_) => mappedObject.get(name_),
2416
- })
2417
-
2418
- ```
2419
-
2420
2455
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2421
2456
 
2422
2457
  <h2 id="eventcheck">EventCheck</h2>
@@ -2473,27 +2508,6 @@ npm i vivth
2473
2508
 
2474
2509
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2475
2510
 
2476
- <h2 id="getruntime">GetRuntime</h2>
2477
-
2478
-
2479
- #### reference:`GetRuntime`
2480
- - detects the current JavaScript runtime;
2481
-
2482
- ```js
2483
- /**
2484
- * @type {()=>Runtime}
2485
- */
2486
- ```
2487
- - <i>example</i>:
2488
- ```js
2489
- import { GetRuntime } form 'vivth';
2490
-
2491
- const runtime = GetRuntime();
2492
-
2493
- ```
2494
-
2495
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2496
-
2497
2511
  <h2 id="isasync">IsAsync</h2>
2498
2512
 
2499
2513
 
@@ -2524,6 +2538,27 @@ npm i vivth
2524
2538
 
2525
2539
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2526
2540
 
2541
+ <h2 id="getruntime">GetRuntime</h2>
2542
+
2543
+
2544
+ #### reference:`GetRuntime`
2545
+ - detects the current JavaScript runtime;
2546
+
2547
+ ```js
2548
+ /**
2549
+ * @type {()=>Runtime}
2550
+ */
2551
+ ```
2552
+ - <i>example</i>:
2553
+ ```js
2554
+ import { GetRuntime } form 'vivth';
2555
+
2556
+ const runtime = GetRuntime();
2557
+
2558
+ ```
2559
+
2560
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2561
+
2527
2562
  <h2 id="lazyfactory">LazyFactory</h2>
2528
2563
 
2529
2564
 
@@ -2749,114 +2784,74 @@ npm i vivth
2749
2784
 
2750
2785
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2751
2786
 
2752
- <h2 id="anybutundefined">AnyButUndefined</h2>
2753
-
2754
- - jsdoc types:
2755
-
2756
- ```js
2757
- /**
2758
- * - type helper for ID or objects;
2759
- * @typedef {{}|null|number|string|boolean|symbol|bigint|function} AnyButUndefined
2760
- */
2761
- ```
2762
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2763
-
2764
- <h2 id="extnametype">ExtnameType</h2>
2765
-
2766
- - jsdoc types:
2767
-
2768
- ```js
2769
- /**
2770
- * - jsRuntime extention naming convention;
2771
- * @typedef {`.${string}`} ExtnameType
2772
- */
2773
- ```
2774
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2787
+ <h2 id="base64url">Base64URL</h2>
2775
2788
 
2776
- <h2 id="islistsignal">IsListSignal</h2>
2777
2789
 
2778
- - jsdoc types:
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;
2779
2794
 
2780
2795
  ```js
2781
- /**
2782
- * - `EnvSignal.get` argument whether signal need to be a list or not;
2783
- * @typedef {boolean} IsListSignal
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}
2784
2807
  */
2785
2808
  ```
2786
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2787
-
2788
- <h2 id="listarg">ListArg</h2>
2789
-
2790
- - jsdoc types:
2791
-
2792
- ```js
2793
- /**
2794
- * - ListSignal argument type;
2795
- * @typedef {Record<string, string>} ListArg
2796
- */
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
+
2797
2816
  ```
2798
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2799
-
2800
- <h2 id="litexpkeytype">LitExpKeyType</h2>
2801
-
2802
- - jsdoc types:
2803
2817
 
2804
- ```js
2805
- /**
2806
- * @typedef {Record<string, RegExp|false>} LitExpKeyType
2807
- */
2808
- ```
2809
2818
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2810
2819
 
2811
- <h2 id="mutationtype">MutationType</h2>
2812
-
2813
- - jsdoc types:
2814
-
2815
- ```js
2816
- /**
2817
- * - `ListSignal` mutation type;
2818
- * @typedef {'push'|'unshift'|'splice'|'swap'|'modify'|'shift'|'remove'} MutationType
2819
- * - instance method: serves as helper to mutate, and notify for `effects`;
2820
- * > - `slice` uses `splice` in the background, you don't need to manually reindex when using it;
2821
- */
2822
- ```
2823
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2820
+ <h2 id="createimmutable">CreateImmutable</h2>
2824
2821
 
2825
- <h2 id="qcbfiforeturn">QCBFIFOReturn</h2>
2826
2822
 
2827
- - jsdoc types:
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;
2828
2827
 
2829
2828
  ```js
2830
- /**
2831
- * - return type of Q callback fifo;
2832
- * @typedef {Omit<import("./src/types/QCBReturn.mjs").QCBReturn, "isLastOnQ">} QCBFIFOReturn
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}
2833
2838
  */
2834
2839
  ```
2835
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2836
-
2837
- <h2 id="qcbreturn">QCBReturn</h2>
2838
-
2839
- - jsdoc types:
2840
-
2841
- ```js
2842
- /**
2843
- * - return type of Q callback;
2844
- * @typedef {{resume:()=>void, isLastOnQ:()=>boolean}} QCBReturn
2845
- */
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
+
2846
2853
  ```
2847
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2848
-
2849
- <h2 id="runtime">Runtime</h2>
2850
-
2851
- - jsdoc types:
2852
2854
 
2853
- ```js
2854
- /**
2855
- * @description
2856
- * - for popular runtimes check;
2857
- * @typedef {'node' | 'bun' | 'deno' | 'browser' | 'unknown'} Runtime
2858
- */
2859
- ```
2860
2855
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2861
2856
 
2862
2857
  <h2 id="workerresult">WorkerResult</h2>