vivth 1.2.2 → 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
- - [CreateImmutable](#createimmutable)
66
- - [EventCheck](#eventcheck)
67
- - [EventObject](#eventobject)
68
- - [GetRuntime](#getruntime)
69
- - [IsAsync](#isasync)
70
- - [LazyFactory](#lazyfactory)
71
- - [Timeout](#timeout)
72
- - [Try](#try)
73
- - [TryAsync](#tryasync)
74
- - [TrySync](#trysync)
75
- - [TsToMjs](#tstomjs)
76
63
  - [JSautoDOC](#jsautodoc)
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
  /**
@@ -2245,56 +1957,108 @@ npm i vivth
2245
1957
 
2246
1958
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2247
1959
 
2248
- <h2 id="base64url">Base64URL</h2>
1960
+ <h2 id="console">Console</h2>
2249
1961
 
2250
1962
 
2251
- #### reference:`Base64URL`
2252
- - create inline base64 url;
2253
- - usage:
2254
- >- 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
+
2255
1969
 
2256
1970
  ```js
2257
1971
  /**
2258
- * @param {string} fileString
2259
- * @param {string} mimeType
2260
- * @param {(string:string)=>string} btoaFunction
2261
- * - check your js runtime `btoa`;
2262
- * - node compatible:
2263
- * ```js
2264
- * (str, prevBufferEncoding) =>
2265
- * Buffer.from(str, prevBufferEncoding).toString('base64')
2266
- * ```
2267
- * @returns {Base64URLString}
1972
+ * @param {any} data
1973
+ * @returns {void}
2268
1974
  */
2269
1975
  ```
2270
1976
  - <i>example</i>:
2271
- ```js
2272
- import { Base64URL } from 'vivth'
2273
- import fileString from './fileString.mjs';
2274
-
2275
- Base64URL(fileString, 'application/javascript', btoa);
1977
+ ```js
1978
+ import { Console } from 'vivth';
1979
+
1980
+ Console.log({
1981
+ hello: 'world!!',
1982
+ });
2276
1983
 
2277
1984
  ```
2278
1985
 
2279
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2280
-
2281
- <h2 id="base64urlfromfile">Base64URLFromFile</h2>
2282
-
1986
+ #### reference:`Console.info`
2283
1987
 
2284
- #### reference:`Base64URLFromFile`
2285
- - create inline base64 url;
2286
- - usage:
2287
- >- can be extremely usefull to display file on desktop app webview, without exposing http server;
2288
- >- when using `FSInline`, use [Base64URL](#base64url) instead;
2289
1988
 
2290
1989
  ```js
2291
1990
  /**
2292
- * @param {string} filePath
2293
- * @returns {Promise<Base64URLString>}
1991
+ * @param {any} data
1992
+ * @returns {void}
2294
1993
  */
2295
1994
  ```
2296
1995
  - <i>example</i>:
2297
- ```js
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>
2044
+
2045
+ <h2 id="base64urlfromfile">Base64URLFromFile</h2>
2046
+
2047
+
2048
+ #### reference:`Base64URLFromFile`
2049
+ - create inline base64 url;
2050
+ - usage:
2051
+ >- can be extremely usefull to display file on desktop app webview, without exposing http server;
2052
+ >- when using `FSInline`, use [Base64URL](#base64url) instead;
2053
+
2054
+ ```js
2055
+ /**
2056
+ * @param {string} filePath
2057
+ * @returns {Promise<Base64URLString>}
2058
+ */
2059
+ ```
2060
+ - <i>example</i>:
2061
+ ```js
2298
2062
  import { join } from 'node:path'
2299
2063
 
2300
2064
  import { Base64URLFromFile, Paths } from 'vivth'
@@ -2319,41 +2083,375 @@ npm i vivth
2319
2083
 
2320
2084
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2321
2085
 
2322
- <h2 id="createimmutable">CreateImmutable</h2>
2086
+ <h2 id="jsautodoc">JSautoDOC</h2>
2323
2087
 
2324
2088
 
2325
- #### reference:`CreateImmutable`
2326
- - function for create immutable object;
2327
- - usefull for binding immutable object to global for shared object:
2328
- >- e.g. to window object in browser;
2089
+ #### reference:`JSautoDOC`
2090
+ - class for auto documenting mjs package/project, using jsdoc;
2091
+ - this autodocumenter uses [chokidar](https://npmjs.com/package/chokidar) under the hood;
2092
+ - this class also is used to generate this `README.md`;
2093
+ - behaviours:
2094
+ >1) add `"at"noautodoc` on self closing jsdoc comment to opt out from generating documentation on said file;
2095
+ >>- auto export must follows the following rules, and there's no way to override;
2096
+ >2) export all named exported 'const'|'function'|'async function'|'class', alphanumeric name, started with Capital letter, same name with fileName on `options.pahts.file`;
2097
+ >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`;
2098
+ >4) create `README.md` based on, `options.paths.dir` and `README.src.md`;
2099
+ >5) extract `"at"description` jsdoc:
2100
+ >>- on static/prop that have depths, all of children should have `"at"static`/`"at"instance` `nameOfImmediateParent`, same block but before `"at"description` comment line;
2101
+ >>- `"at"description` are treated as plain `markdown`;
2102
+ >>- first `"at"${string}` after `"at"description` until `"at"example` will be treated as `javascript` comment block on the `markdown`;
2103
+ >>- `"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;
2105
+
2106
+
2107
+ #### reference:`new JSautoDOC`
2108
+
2329
2109
 
2330
2110
  ```js
2331
2111
  /**
2332
- * @template {Object} PARENT
2333
- * @template {Object} OBJECT
2334
- * @param {string} keyName
2335
- * @param {PARENT} parent
2336
- * @param {(this:PARENT)=>OBJECT} object
2337
- * @param {Object} [options]
2338
- * @param {boolean} [options.lazy]
2339
- * @return {OBJECT}
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>
2433
+
2434
+ - jsdoc types:
2435
+
2436
+ ```js
2437
+ /**
2438
+ * - return type of Q callback;
2439
+ * @typedef {{resume:()=>void, isLastOnQ:()=>boolean}} QCBReturn
2340
2440
  */
2341
2441
  ```
2342
- - <i>example</i>:
2343
- ```js
2344
- import { CreateImmutable } from 'vivth';
2345
-
2346
- const mappedObject = new Map();
2347
-
2348
- CreateImmutable(window, 'mySharedObject', {
2349
- setMap(name_, value) => {
2350
- mappedObject.set(name_, value)
2351
- },
2352
- getMap(name_) => mappedObject.get(name_),
2353
- })
2354
-
2355
- ```
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:
2356
2447
 
2448
+ ```js
2449
+ /**
2450
+ * @description
2451
+ * - for popular runtimes check;
2452
+ * @typedef {'node' | 'bun' | 'deno' | 'browser' | 'unknown'} Runtime
2453
+ */
2454
+ ```
2357
2455
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2358
2456
 
2359
2457
  <h2 id="eventcheck">EventCheck</h2>
@@ -2410,27 +2508,6 @@ npm i vivth
2410
2508
 
2411
2509
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2412
2510
 
2413
- <h2 id="getruntime">GetRuntime</h2>
2414
-
2415
-
2416
- #### reference:`GetRuntime`
2417
- - detects the current JavaScript runtime;
2418
-
2419
- ```js
2420
- /**
2421
- * @type {()=>Runtime}
2422
- */
2423
- ```
2424
- - <i>example</i>:
2425
- ```js
2426
- import { GetRuntime } form 'vivth';
2427
-
2428
- const runtime = GetRuntime();
2429
-
2430
- ```
2431
-
2432
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2433
-
2434
2511
  <h2 id="isasync">IsAsync</h2>
2435
2512
 
2436
2513
 
@@ -2461,6 +2538,27 @@ npm i vivth
2461
2538
 
2462
2539
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2463
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
+
2464
2562
  <h2 id="lazyfactory">LazyFactory</h2>
2465
2563
 
2466
2564
 
@@ -2686,168 +2784,74 @@ npm i vivth
2686
2784
 
2687
2785
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2688
2786
 
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
-
2787
+ <h2 id="base64url">Base64URL</h2>
2709
2788
 
2710
- #### reference:`new JSautoDOC`
2711
2789
 
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;
2712
2794
 
2713
2795
  ```js
2714
2796
  /**
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;
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}
2727
2807
  */
2728
2808
  ```
2729
2809
  - <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
- });
2810
+ ```js
2811
+ import { Base64URL } from 'vivth'
2812
+ import fileString from './fileString.mjs';
2738
2813
 
2814
+ Base64URL(fileString, 'application/javascript', btoa);
2815
+
2739
2816
  ```
2740
2817
 
2741
2818
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2742
2819
 
2743
- <h2 id="anybutundefined">AnyButUndefined</h2>
2744
-
2745
- - jsdoc types:
2746
-
2747
- ```js
2748
- /**
2749
- * - type helper for ID or objects;
2750
- * @typedef {{}|null|number|string|boolean|symbol|bigint|function} AnyButUndefined
2751
- */
2752
- ```
2753
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2754
-
2755
- <h2 id="extnametype">ExtnameType</h2>
2756
-
2757
- - jsdoc types:
2758
-
2759
- ```js
2760
- /**
2761
- * - jsRuntime extention naming convention;
2762
- * @typedef {`.${string}`} ExtnameType
2763
- */
2764
- ```
2765
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2766
-
2767
- <h2 id="islistsignal">IsListSignal</h2>
2768
-
2769
- - jsdoc types:
2770
-
2771
- ```js
2772
- /**
2773
- * - `EnvSignal.get` argument whether signal need to be a list or not;
2774
- * @typedef {boolean} IsListSignal
2775
- */
2776
- ```
2777
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2778
-
2779
- <h2 id="listarg">ListArg</h2>
2780
-
2781
- - jsdoc types:
2782
-
2783
- ```js
2784
- /**
2785
- * - ListSignal argument type;
2786
- * @typedef {Record<string, string>} ListArg
2787
- */
2788
- ```
2789
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2790
-
2791
- <h2 id="litexpkeytype">LitExpKeyType</h2>
2792
-
2793
- - jsdoc types:
2794
-
2795
- ```js
2796
- /**
2797
- * @typedef {Record<string, RegExp|false>} LitExpKeyType
2798
- */
2799
- ```
2800
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2801
-
2802
- <h2 id="mutationtype">MutationType</h2>
2803
-
2804
- - jsdoc types:
2805
-
2806
- ```js
2807
- /**
2808
- * - `ListSignal` mutation type;
2809
- * @typedef {'push'|'unshift'|'splice'|'swap'|'modify'|'shift'|'remove'} MutationType
2810
- * - instance method: serves as helper to mutate, and notify for `effects`;
2811
- * > - `slice` uses `splice` in the background, you don't need to manually reindex when using it;
2812
- */
2813
- ```
2814
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2820
+ <h2 id="createimmutable">CreateImmutable</h2>
2815
2821
 
2816
- <h2 id="qcbfiforeturn">QCBFIFOReturn</h2>
2817
2822
 
2818
- - 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;
2819
2827
 
2820
2828
  ```js
2821
- /**
2822
- * - return type of Q callback fifo;
2823
- * @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}
2824
2838
  */
2825
2839
  ```
2826
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2827
-
2828
- <h2 id="qcbreturn">QCBReturn</h2>
2829
-
2830
- - jsdoc types:
2831
-
2832
- ```js
2833
- /**
2834
- * - return type of Q callback;
2835
- * @typedef {{resume:()=>void, isLastOnQ:()=>boolean}} QCBReturn
2836
- */
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
+
2837
2853
  ```
2838
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2839
-
2840
- <h2 id="runtime">Runtime</h2>
2841
-
2842
- - jsdoc types:
2843
2854
 
2844
- ```js
2845
- /**
2846
- * @description
2847
- * - for popular runtimes check;
2848
- * @typedef {'node' | 'bun' | 'deno' | 'browser' | 'unknown'} Runtime
2849
- */
2850
- ```
2851
2855
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2852
2856
 
2853
2857
  <h2 id="workerresult">WorkerResult</h2>