@leyyo/common 1.3.19 → 1.3.20
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/dist/base/index.types.d.ts +67 -0
- package/dist/base/index.types.js +32 -0
- package/dist/base/leyyo.d.ts +3 -0
- package/dist/base/leyyo.js +18 -7
- package/dist/class/index.types.d.ts +20 -0
- package/dist/class/list.d.ts +6 -0
- package/dist/class/list.js +6 -0
- package/dist/class/logger.instance.d.ts +5 -0
- package/dist/class/logger.instance.js +13 -0
- package/dist/common/deploy.common.d.ts +16 -0
- package/dist/common/deploy.common.js +17 -0
- package/dist/common/enum.pool.d.ts +10 -0
- package/dist/common/enum.pool.js +14 -0
- package/dist/common/error.common.d.ts +30 -0
- package/dist/common/error.common.js +40 -0
- package/dist/common/error.pool.d.ts +9 -0
- package/dist/common/error.pool.js +10 -0
- package/dist/common/event.common.d.ts +8 -0
- package/dist/common/event.common.js +16 -3
- package/dist/common/index.types.d.ts +432 -0
- package/dist/common/index.types.js +1 -0
- package/dist/common/inert.d.ts +48 -0
- package/dist/common/inert.js +29 -0
- package/dist/common/lifecycle.common.d.ts +14 -0
- package/dist/common/lifecycle.common.js +16 -0
- package/dist/common/literal.pool.d.ts +11 -0
- package/dist/common/literal.pool.js +15 -0
- package/dist/common/log.common.d.ts +54 -0
- package/dist/common/log.common.js +96 -6
- package/dist/common/repo.common.d.ts +188 -0
- package/dist/common/repo.common.js +211 -0
- package/dist/const/index.d.ts +6 -0
- package/dist/const/index.js +7 -0
- package/dist/enum/log-level.d.ts +3 -0
- package/dist/error/caused.error.d.ts +10 -0
- package/dist/error/caused.error.js +10 -0
- package/dist/error/developer.error.d.ts +8 -0
- package/dist/error/developer.error.js +10 -0
- package/dist/error/http.error.d.ts +13 -0
- package/dist/error/http.error.js +7 -0
- package/dist/error/index.types.d.ts +149 -0
- package/dist/error/invalid-value.error.d.ts +3 -0
- package/dist/error/invalid-value.error.js +3 -0
- package/dist/error/leyyo.error.d.ts +33 -0
- package/dist/error/leyyo.error.js +36 -0
- package/dist/error/multiple.error.d.ts +6 -0
- package/dist/error/multiple.error.js +7 -0
- package/dist/function/define-loader.d.ts +6 -0
- package/dist/function/define-loader.js +6 -0
- package/dist/function/delay.d.ts +8 -0
- package/dist/function/delay.js +9 -0
- package/dist/function/delete-prop.d.ts +21 -0
- package/dist/function/delete-prop.js +22 -0
- package/dist/function/empty-fn.d.ts +6 -0
- package/dist/function/empty-fn.js +7 -0
- package/dist/function/extended-type.d.ts +6 -0
- package/dist/function/extended-type.js +7 -0
- package/dist/function/get-fqn.d.ts +6 -0
- package/dist/function/get-fqn.js +7 -0
- package/dist/function/get-prop.d.ts +21 -0
- package/dist/function/get-prop.js +21 -0
- package/dist/function/get-stat.d.ts +20 -0
- package/dist/function/has-fqn.d.ts +6 -0
- package/dist/function/has-fqn.js +7 -0
- package/dist/function/is-class.d.ts +6 -0
- package/dist/function/is-class.js +18 -0
- package/dist/function/is-empty.d.ts +11 -0
- package/dist/function/is-empty.js +11 -0
- package/dist/function/is-filled-arr.d.ts +9 -0
- package/dist/function/is-filled-arr.js +9 -0
- package/dist/function/is-filled-obj.d.ts +9 -0
- package/dist/function/is-filled-obj.js +9 -0
- package/dist/function/is-obj.d.ts +8 -0
- package/dist/function/is-obj.js +8 -0
- package/dist/function/is-test.d.ts +8 -0
- package/dist/function/is-test.js +14 -0
- package/dist/function/is-text.d.ts +10 -0
- package/dist/function/is-text.js +10 -0
- package/dist/function/jitter-interval.d.ts +9 -0
- package/dist/function/jitter-interval.js +16 -0
- package/dist/function/load-config.d.ts +19 -0
- package/dist/function/load-config.js +52 -1
- package/dist/function/on-fqn-set.js +1 -0
- package/dist/function/one-or-more.d.ts +6 -0
- package/dist/function/one-or-more.js +7 -0
- package/dist/function/opt-add.d.ts +8 -0
- package/dist/function/opt-add.js +8 -0
- package/dist/function/opt-append.d.ts +7 -0
- package/dist/function/opt-append.js +7 -0
- package/dist/function/opt-check.d.ts +6 -0
- package/dist/function/opt-check.js +7 -0
- package/dist/function/opt-clone.d.ts +6 -0
- package/dist/function/opt-clone.js +7 -0
- package/dist/function/opt-field.d.ts +8 -0
- package/dist/function/opt-field.js +8 -0
- package/dist/function/opt-fn.d.ts +6 -0
- package/dist/function/opt-fn.js +7 -0
- package/dist/function/random-test-no.d.ts +5 -0
- package/dist/function/random-test-no.js +5 -0
- package/dist/function/remove-fqn.d.ts +8 -0
- package/dist/function/remove-fqn.js +11 -1
- package/dist/function/run-exporter.d.ts +5 -0
- package/dist/function/run-exporter.js +14 -0
- package/dist/function/secure-json.d.ts +35 -0
- package/dist/function/secure-json.js +44 -0
- package/dist/function/set-anonymous-fqn.js +2 -0
- package/dist/function/set-fqn.d.ts +7 -0
- package/dist/function/set-fqn.js +8 -0
- package/dist/function/set-prop.d.ts +24 -0
- package/dist/function/set-prop.js +24 -0
- package/dist/function/stamp-loader.d.ts +6 -0
- package/dist/function/stamp-loader.js +6 -0
- package/dist/function/test-case.d.ts +7 -0
- package/dist/function/test-case.js +7 -0
- package/dist/function/test-name.d.ts +7 -0
- package/dist/function/test-name.js +7 -0
- package/dist/function/trigger-fqn.js +1 -0
- package/dist/index.foretell.js +3 -0
- package/dist/index.js +1 -0
- package/dist/index.loader.js +8 -1
- package/dist/sys/leyyo-storage.d.ts +7 -0
- package/dist/sys/leyyo-storage.js +23 -0
- package/package.json +1 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { isObj } from "./is-obj.js";
|
|
2
|
+
/**
|
|
3
|
+
* Add field into options
|
|
4
|
+
* Note: field could not be multiple in option
|
|
5
|
+
*
|
|
6
|
+
* @param {Opt} options - source options
|
|
7
|
+
* @param {KeyValue} field - value
|
|
8
|
+
* @return {Opt} - added options
|
|
9
|
+
* */
|
|
2
10
|
export function optField(options, field) {
|
|
3
11
|
const o = (isObj(options) ? options : {});
|
|
4
12
|
const t = typeof field;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { Opt } from "./index.types.js";
|
|
2
|
+
/**
|
|
3
|
+
* It's used to easy arrow function usage for lazy evaluation of options
|
|
4
|
+
*
|
|
5
|
+
* @param {Opt} options - options
|
|
6
|
+
* @return {Opt} - options
|
|
7
|
+
* */
|
|
2
8
|
export declare function optFn<O extends Opt = Opt>(options: O | Opt): O;
|
package/dist/function/opt-fn.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { isObj } from "./is-obj.js";
|
|
2
|
+
// noinspection JSUnusedGlobalSymbols
|
|
3
|
+
/**
|
|
4
|
+
* It's used to easy arrow function usage for lazy evaluation of options
|
|
5
|
+
*
|
|
6
|
+
* @param {Opt} options - options
|
|
7
|
+
* @return {Opt} - options
|
|
8
|
+
* */
|
|
2
9
|
export function optFn(options) {
|
|
3
10
|
return (isObj(options) ? options : {});
|
|
4
11
|
}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { FqnTarget } from "./index.types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Remove fqn name
|
|
4
|
+
*
|
|
5
|
+
* @param {FqnTarget} target - target (function, class, instance, enum, literal)
|
|
6
|
+
* @return {boolean?} - is removed
|
|
7
|
+
*
|
|
8
|
+
* Note: if it returns `undefined`, means that it could not find valid target
|
|
9
|
+
* */
|
|
2
10
|
export declare function removeFqn(target: FqnTarget): boolean;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { KEY_ENUM_NAME, KEY_FQN_NAME, KEY_LITERAL_NAME } from "../const/index.js";
|
|
2
2
|
import { triggerFqn } from "./trigger-fqn.js";
|
|
3
|
+
/**
|
|
4
|
+
* Remove fqn name
|
|
5
|
+
*
|
|
6
|
+
* @param {FqnTarget} target - target (function, class, instance, enum, literal)
|
|
7
|
+
* @return {boolean?} - is removed
|
|
8
|
+
*
|
|
9
|
+
* Note: if it returns `undefined`, means that it could not find valid target
|
|
10
|
+
* */
|
|
3
11
|
export function removeFqn(target) {
|
|
4
12
|
if (!target) {
|
|
5
13
|
return false;
|
|
6
14
|
}
|
|
7
15
|
if (typeof target === "function") {
|
|
16
|
+
// function, class
|
|
8
17
|
return _item(target, target.name);
|
|
9
18
|
}
|
|
10
19
|
else if (typeof target === "object") {
|
|
@@ -12,11 +21,12 @@ export function removeFqn(target) {
|
|
|
12
21
|
if (target[KEY_LITERAL_NAME]) {
|
|
13
22
|
return _item(target, target[KEY_LITERAL_NAME]);
|
|
14
23
|
}
|
|
15
|
-
return false;
|
|
24
|
+
return false; // normal array
|
|
16
25
|
}
|
|
17
26
|
if (target[KEY_ENUM_NAME]) {
|
|
18
27
|
return _item(target, target[KEY_ENUM_NAME]);
|
|
19
28
|
}
|
|
29
|
+
// instance
|
|
20
30
|
return false;
|
|
21
31
|
}
|
|
22
32
|
return false;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { $$get_leyyo_fn } from "./leyyo-fn.js";
|
|
2
2
|
let _leyyo;
|
|
3
|
+
// noinspection JSUnusedGlobalSymbols
|
|
4
|
+
/**
|
|
5
|
+
* Run exporter
|
|
6
|
+
*
|
|
7
|
+
* @return {Promise<ExporterData>}
|
|
8
|
+
* */
|
|
3
9
|
export async function runExporter() {
|
|
4
10
|
const data = {};
|
|
5
11
|
const depot = {
|
|
@@ -13,6 +19,14 @@ export async function runExporter() {
|
|
|
13
19
|
await _leyyo.lifecycleCommon.runStage("print", depot);
|
|
14
20
|
return data;
|
|
15
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Append to exporter with preventing overridden keys
|
|
24
|
+
*
|
|
25
|
+
* @param {ExporterData} data
|
|
26
|
+
* @param {string} name
|
|
27
|
+
* @param {ExporterValue} value
|
|
28
|
+
* @param {number} duplicated
|
|
29
|
+
* */
|
|
16
30
|
const append = (data, name, value, duplicated) => {
|
|
17
31
|
const postfix = duplicated === 0 ? "" : "#" + duplicated;
|
|
18
32
|
if (data[name + postfix] !== undefined) {
|
|
@@ -1,2 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an object to secure object
|
|
3
|
+
*
|
|
4
|
+
* - `secure` means:
|
|
5
|
+
* - removes `circular` relations
|
|
6
|
+
* - cuts after max depths, default: `10`
|
|
7
|
+
* - converts `Set` to `array`
|
|
8
|
+
* - converts `Map` to `object`
|
|
9
|
+
* - cuts `methods` of an object
|
|
10
|
+
* - cuts `symbol` properties of an object
|
|
11
|
+
* - cuts `non-string keys` of an object
|
|
12
|
+
* - cuts `undefined` properties of an object
|
|
13
|
+
*
|
|
14
|
+
* @param {any} value
|
|
15
|
+
* @return {any}
|
|
16
|
+
* */
|
|
1
17
|
export declare function secureObject<E>(value: E): E;
|
|
18
|
+
/**
|
|
19
|
+
* Converts an object to secure string
|
|
20
|
+
*
|
|
21
|
+
* - `secure` means:
|
|
22
|
+
* - removes `circular` relations
|
|
23
|
+
* - cuts after max depths, default: `10`
|
|
24
|
+
* - converts `Set` to `array`
|
|
25
|
+
* - converts `Map` to `object`
|
|
26
|
+
* - cuts `methods` of an object
|
|
27
|
+
* - cuts `symbol` properties of an object
|
|
28
|
+
* - cuts `non-string keys` of an object
|
|
29
|
+
* - cuts `undefined` properties of an object
|
|
30
|
+
*
|
|
31
|
+
* Note:
|
|
32
|
+
* `JSON.stringify` can fail if there is a `dependency
|
|
33
|
+
*
|
|
34
|
+
* @param {any} value
|
|
35
|
+
* @return {string}
|
|
36
|
+
* */
|
|
2
37
|
export declare function secureJson(value: unknown): string;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inner secure json function, it will be used after creating weak set
|
|
3
|
+
*
|
|
4
|
+
* @param {any} value
|
|
5
|
+
* @param {number} depth
|
|
6
|
+
* @param {WeakSet} set
|
|
7
|
+
* */
|
|
1
8
|
function _secureObject(value, depth, set) {
|
|
2
9
|
if ([null, undefined].includes(value)) {
|
|
3
10
|
return value;
|
|
@@ -59,6 +66,23 @@ function _secureObject(value, depth, set) {
|
|
|
59
66
|
}
|
|
60
67
|
return value;
|
|
61
68
|
}
|
|
69
|
+
// noinspection JSUnusedGlobalSymbols
|
|
70
|
+
/**
|
|
71
|
+
* Converts an object to secure object
|
|
72
|
+
*
|
|
73
|
+
* - `secure` means:
|
|
74
|
+
* - removes `circular` relations
|
|
75
|
+
* - cuts after max depths, default: `10`
|
|
76
|
+
* - converts `Set` to `array`
|
|
77
|
+
* - converts `Map` to `object`
|
|
78
|
+
* - cuts `methods` of an object
|
|
79
|
+
* - cuts `symbol` properties of an object
|
|
80
|
+
* - cuts `non-string keys` of an object
|
|
81
|
+
* - cuts `undefined` properties of an object
|
|
82
|
+
*
|
|
83
|
+
* @param {any} value
|
|
84
|
+
* @return {any}
|
|
85
|
+
* */
|
|
62
86
|
export function secureObject(value) {
|
|
63
87
|
try {
|
|
64
88
|
return _secureObject(value, 0, new WeakSet());
|
|
@@ -67,6 +91,26 @@ export function secureObject(value) {
|
|
|
67
91
|
return `#error <${e.name}> (message: ${e.message})`;
|
|
68
92
|
}
|
|
69
93
|
}
|
|
94
|
+
// noinspection JSUnusedGlobalSymbols
|
|
95
|
+
/**
|
|
96
|
+
* Converts an object to secure string
|
|
97
|
+
*
|
|
98
|
+
* - `secure` means:
|
|
99
|
+
* - removes `circular` relations
|
|
100
|
+
* - cuts after max depths, default: `10`
|
|
101
|
+
* - converts `Set` to `array`
|
|
102
|
+
* - converts `Map` to `object`
|
|
103
|
+
* - cuts `methods` of an object
|
|
104
|
+
* - cuts `symbol` properties of an object
|
|
105
|
+
* - cuts `non-string keys` of an object
|
|
106
|
+
* - cuts `undefined` properties of an object
|
|
107
|
+
*
|
|
108
|
+
* Note:
|
|
109
|
+
* `JSON.stringify` can fail if there is a `dependency
|
|
110
|
+
*
|
|
111
|
+
* @param {any} value
|
|
112
|
+
* @return {string}
|
|
113
|
+
* */
|
|
70
114
|
export function secureJson(value) {
|
|
71
115
|
try {
|
|
72
116
|
const json = _secureObject(value, 0, new WeakSet());
|
|
@@ -8,6 +8,7 @@ export function setAnonymousFqn(target) {
|
|
|
8
8
|
return undefined;
|
|
9
9
|
}
|
|
10
10
|
if (typeof target === "function") {
|
|
11
|
+
// function, class
|
|
11
12
|
if (!target.name) {
|
|
12
13
|
setAnonymousName(target, isClass(target) ? "Class" : "function");
|
|
13
14
|
}
|
|
@@ -23,6 +24,7 @@ export function setAnonymousFqn(target) {
|
|
|
23
24
|
if (target[KEY_ENUM_NAME]) {
|
|
24
25
|
return _item(target, target[KEY_ENUM_NAME]);
|
|
25
26
|
}
|
|
27
|
+
// instance
|
|
26
28
|
return undefined;
|
|
27
29
|
}
|
|
28
30
|
return undefined;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { FqnTarget } from "./index.types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Set fqn name
|
|
4
|
+
*
|
|
5
|
+
* @param {FqnTarget} target - target (function, class, instance, enum, literal)
|
|
6
|
+
* @param {string} fqn - fully qualified name
|
|
7
|
+
* @return {string} - full name
|
|
8
|
+
* */
|
|
2
9
|
export declare function setFqn(target: FqnTarget, fqn: string): string;
|
package/dist/function/set-fqn.js
CHANGED
|
@@ -9,6 +9,13 @@ import { setAnonymousName } from "./set-anonymous-name.js";
|
|
|
9
9
|
import { getFqn } from "./get-fqn.js";
|
|
10
10
|
const where = `${FQN}.FqnFn`;
|
|
11
11
|
let _leyyo;
|
|
12
|
+
/**
|
|
13
|
+
* Set fqn name
|
|
14
|
+
*
|
|
15
|
+
* @param {FqnTarget} target - target (function, class, instance, enum, literal)
|
|
16
|
+
* @param {string} fqn - fully qualified name
|
|
17
|
+
* @return {string} - full name
|
|
18
|
+
* */
|
|
12
19
|
export function setFqn(target, fqn) {
|
|
13
20
|
if (!_leyyo) {
|
|
14
21
|
_leyyo = $$get_leyyo_fn();
|
|
@@ -30,6 +37,7 @@ export function setFqn(target, fqn) {
|
|
|
30
37
|
return undefined;
|
|
31
38
|
}
|
|
32
39
|
if (typeof target === "function") {
|
|
40
|
+
// function, class
|
|
33
41
|
if (!target.name) {
|
|
34
42
|
setAnonymousName(target, isClass(target) ? "Class" : "function");
|
|
35
43
|
}
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set target property
|
|
3
|
+
*
|
|
4
|
+
* @param {any} target - target
|
|
5
|
+
* @param {string} key - key
|
|
6
|
+
* @param {any} value
|
|
7
|
+
* @return {boolean} - is set?
|
|
8
|
+
* */
|
|
1
9
|
export declare function setKey(target: unknown, key: string, value: unknown): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Set target hidden property
|
|
12
|
+
*
|
|
13
|
+
* @param {any} target - target
|
|
14
|
+
* @param {symbol} key - hidden key
|
|
15
|
+
* @param {any} value
|
|
16
|
+
* @return {boolean} - is set?
|
|
17
|
+
* */
|
|
2
18
|
export declare function setSymbol(target: unknown, key: symbol, value: unknown): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Set target property
|
|
21
|
+
*
|
|
22
|
+
* @param {any} target - target
|
|
23
|
+
* @param {(symbol|string)} key - key
|
|
24
|
+
* @param {any} value
|
|
25
|
+
* @return {boolean} - is set?
|
|
26
|
+
* */
|
|
3
27
|
export declare function setProp(target: unknown, key: symbol | string, value: unknown): boolean;
|
|
@@ -3,18 +3,42 @@ import { testCase } from "./test-case.js";
|
|
|
3
3
|
import { $$get_leyyo_fn } from "./leyyo-fn.js";
|
|
4
4
|
const where = `${FQN}.DeleteProp`;
|
|
5
5
|
let _leyyo;
|
|
6
|
+
/**
|
|
7
|
+
* Set target property
|
|
8
|
+
*
|
|
9
|
+
* @param {any} target - target
|
|
10
|
+
* @param {string} key - key
|
|
11
|
+
* @param {any} value
|
|
12
|
+
* @return {boolean} - is set?
|
|
13
|
+
* */
|
|
6
14
|
export function setKey(target, key, value) {
|
|
7
15
|
if (typeof key !== "string") {
|
|
8
16
|
return false;
|
|
9
17
|
}
|
|
10
18
|
return setProp(target, key, value);
|
|
11
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Set target hidden property
|
|
22
|
+
*
|
|
23
|
+
* @param {any} target - target
|
|
24
|
+
* @param {symbol} key - hidden key
|
|
25
|
+
* @param {any} value
|
|
26
|
+
* @return {boolean} - is set?
|
|
27
|
+
* */
|
|
12
28
|
export function setSymbol(target, key, value) {
|
|
13
29
|
if (typeof key !== "symbol") {
|
|
14
30
|
return false;
|
|
15
31
|
}
|
|
16
32
|
return setProp(target, key, value);
|
|
17
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Set target property
|
|
36
|
+
*
|
|
37
|
+
* @param {any} target - target
|
|
38
|
+
* @param {(symbol|string)} key - key
|
|
39
|
+
* @param {any} value
|
|
40
|
+
* @return {boolean} - is set?
|
|
41
|
+
* */
|
|
18
42
|
export function setProp(target, key, value) {
|
|
19
43
|
if (!["symbol", "string"].includes(typeof key)) {
|
|
20
44
|
return false;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { LeyyoStampEmpty, LeyyoStampLambda } from "./index.types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Stamp an instance for loader
|
|
4
|
+
*
|
|
5
|
+
* @param {function} fn - callback function to save
|
|
6
|
+
* @return {(LeyyoStampLambda | LeyyoStampEmpty)} - stamped function
|
|
7
|
+
* */
|
|
2
8
|
export declare function stampLoader(fn: LeyyoStampLambda): LeyyoStampLambda | LeyyoStampEmpty;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { KEY_LOADER_EMPTY, KEY_LOADER_STAMP } from "../const/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Stamp an instance for loader
|
|
4
|
+
*
|
|
5
|
+
* @param {function} fn - callback function to save
|
|
6
|
+
* @return {(LeyyoStampLambda | LeyyoStampEmpty)} - stamped function
|
|
7
|
+
* */
|
|
2
8
|
export function stampLoader(fn) {
|
|
3
9
|
if (typeof fn === "function") {
|
|
4
10
|
fn[KEY_LOADER_STAMP] = true;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { randomTestNo } from "./random-test-no.js";
|
|
2
2
|
import { FQN } from "../internal.js";
|
|
3
|
+
/**
|
|
4
|
+
* Build test case
|
|
5
|
+
*
|
|
6
|
+
* @param {string} pck - Package or FQN name
|
|
7
|
+
* @param {(string|number)} caseNo
|
|
8
|
+
* @return {string}
|
|
9
|
+
* */
|
|
3
10
|
export function testCase(pck, caseNo) {
|
|
4
11
|
pck = typeof pck === "string" ? pck : FQN;
|
|
5
12
|
let caseStr;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { randomTestNo } from "./random-test-no.js";
|
|
2
2
|
import { FQN } from "../internal.js";
|
|
3
|
+
/**
|
|
4
|
+
* Build test name
|
|
5
|
+
*
|
|
6
|
+
* @param {string} testCase - it would be built via {@link testCase}
|
|
7
|
+
* @param {string} title - test title
|
|
8
|
+
* @return {string}
|
|
9
|
+
* */
|
|
3
10
|
export function testName(testCase, title) {
|
|
4
11
|
testCase = typeof testCase === "string" ? testCase : `${FQN}@${randomTestNo()}`;
|
|
5
12
|
title = typeof title === "string" ? title : "???";
|
package/dist/index.foretell.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { leyyo } from "./base/index.js";
|
|
2
2
|
import { FQN } from "./internal.js";
|
|
3
|
+
// noinspection JSUnusedGlobalSymbols
|
|
3
4
|
export const foretell_leyyoCommon = [
|
|
5
|
+
// errors
|
|
4
6
|
() => leyyo.errorPool.lazy(FQN, "CausedError", import("./error/caused.error.js").then((m) => m.CausedError), { i18n: true, emit: true }),
|
|
5
7
|
() => leyyo.errorPool.lazy(FQN, "DeveloperError", import("./error/developer.error.js").then((m) => m.DeveloperError), { i18n: true, emit: true }),
|
|
6
8
|
() => leyyo.errorPool.lazy(FQN, "HttpError", import("./error/http.error.js").then((m) => m.HttpError), { i18n: true, emit: true }),
|
|
7
9
|
() => leyyo.errorPool.lazy(FQN, "InvalidValueError", import("./error/invalid-value.error.js").then((m) => m.InvalidValueError), { i18n: true, emit: true }),
|
|
8
10
|
() => leyyo.errorPool.lazy(FQN, "LeyyoError", import("./error/leyyo.error.js").then((m) => m.LeyyoError), { i18n: true, emit: false }),
|
|
9
11
|
() => leyyo.errorPool.lazy(FQN, "MultipleError", import("./error/multiple.error.js").then((m) => m.MultipleError), { i18n: true, emit: true }),
|
|
12
|
+
// enums
|
|
10
13
|
() => leyyo.literalPool.lazy(FQN, "LogLevel", import("./enum/log-level.js").then((m) => m.LogLevelItems), { i18n: true }),
|
|
11
14
|
];
|
package/dist/index.js
CHANGED
package/dist/index.loader.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { defineLoader } from "./function/index.js";
|
|
2
2
|
import { FQN } from "./internal.js";
|
|
3
|
-
|
|
3
|
+
// noinspection JSUnusedGlobalSymbols
|
|
4
|
+
export const loader_leyyoCommon = defineLoader(FQN,
|
|
5
|
+
// errors
|
|
6
|
+
() => import("./error/caused.error.js").then((m) => m.CausedError), () => import("./error/developer.error.js").then((m) => m.DeveloperError), () => import("./error/http.error.js").then((m) => m.HttpError), () => import("./error/invalid-value.error.js").then((m) => m.InvalidValueError), () => import("./error/leyyo.error.js").then((m) => m.LeyyoError), () => import("./error/multiple.error.js").then((m) => m.MultipleError),
|
|
7
|
+
// enums
|
|
8
|
+
() => import("./enum/log-level.js").then((m) => m.LogLevelItems),
|
|
9
|
+
// classes
|
|
10
|
+
() => import("./class/list.js").then((m) => m.List), () => import("./class/logger.instance.js").then((m) => m.LoggerInstance));
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
type LeyyoStorage = Map<string, unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* Local storage for leyyo platform
|
|
4
|
+
* */
|
|
2
5
|
export declare const leyyoStorage: LeyyoStorage;
|
|
6
|
+
/**
|
|
7
|
+
* @param {string} name - name of storage
|
|
8
|
+
* @param {any} def - initial value
|
|
9
|
+
* */
|
|
3
10
|
export declare function getRootStorage<T>(name: string, def: T): T;
|
|
4
11
|
export {};
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
const _NAME = "$$leyyo.packages";
|
|
2
|
+
/**
|
|
3
|
+
* Create a standalone storage
|
|
4
|
+
*
|
|
5
|
+
* @return {LeyyoStorage}
|
|
6
|
+
* */
|
|
2
7
|
function _new() {
|
|
3
8
|
return new Map();
|
|
4
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Get a global storage
|
|
12
|
+
*
|
|
13
|
+
* @param {any} source - `global` or `globalThis`
|
|
14
|
+
* @return {LeyyoStorage}
|
|
15
|
+
* */
|
|
5
16
|
function _get(source) {
|
|
6
17
|
if (!source) {
|
|
7
18
|
return undefined;
|
|
@@ -12,6 +23,11 @@ function _get(source) {
|
|
|
12
23
|
source[_NAME] = _new();
|
|
13
24
|
return source[_NAME];
|
|
14
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Build storage
|
|
28
|
+
*
|
|
29
|
+
* @return {LeyyoStorage}
|
|
30
|
+
* */
|
|
15
31
|
function _build() {
|
|
16
32
|
try {
|
|
17
33
|
return _get(globalThis) ?? _get(global) ?? _new();
|
|
@@ -20,7 +36,14 @@ function _build() {
|
|
|
20
36
|
return _new();
|
|
21
37
|
}
|
|
22
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Local storage for leyyo platform
|
|
41
|
+
* */
|
|
23
42
|
export const leyyoStorage = _build();
|
|
43
|
+
/**
|
|
44
|
+
* @param {string} name - name of storage
|
|
45
|
+
* @param {any} def - initial value
|
|
46
|
+
* */
|
|
24
47
|
export function getRootStorage(name, def) {
|
|
25
48
|
if (typeof name !== "string") {
|
|
26
49
|
throw new Error("Invalid storage name", name);
|