@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.
Files changed (123) hide show
  1. package/dist/base/index.types.d.ts +67 -0
  2. package/dist/base/index.types.js +32 -0
  3. package/dist/base/leyyo.d.ts +3 -0
  4. package/dist/base/leyyo.js +18 -7
  5. package/dist/class/index.types.d.ts +20 -0
  6. package/dist/class/list.d.ts +6 -0
  7. package/dist/class/list.js +6 -0
  8. package/dist/class/logger.instance.d.ts +5 -0
  9. package/dist/class/logger.instance.js +13 -0
  10. package/dist/common/deploy.common.d.ts +16 -0
  11. package/dist/common/deploy.common.js +17 -0
  12. package/dist/common/enum.pool.d.ts +10 -0
  13. package/dist/common/enum.pool.js +14 -0
  14. package/dist/common/error.common.d.ts +30 -0
  15. package/dist/common/error.common.js +40 -0
  16. package/dist/common/error.pool.d.ts +9 -0
  17. package/dist/common/error.pool.js +10 -0
  18. package/dist/common/event.common.d.ts +8 -0
  19. package/dist/common/event.common.js +16 -3
  20. package/dist/common/index.types.d.ts +432 -0
  21. package/dist/common/index.types.js +1 -0
  22. package/dist/common/inert.d.ts +48 -0
  23. package/dist/common/inert.js +29 -0
  24. package/dist/common/lifecycle.common.d.ts +14 -0
  25. package/dist/common/lifecycle.common.js +16 -0
  26. package/dist/common/literal.pool.d.ts +11 -0
  27. package/dist/common/literal.pool.js +15 -0
  28. package/dist/common/log.common.d.ts +54 -0
  29. package/dist/common/log.common.js +96 -6
  30. package/dist/common/repo.common.d.ts +188 -0
  31. package/dist/common/repo.common.js +211 -0
  32. package/dist/const/index.d.ts +6 -0
  33. package/dist/const/index.js +7 -0
  34. package/dist/enum/log-level.d.ts +3 -0
  35. package/dist/error/caused.error.d.ts +10 -0
  36. package/dist/error/caused.error.js +10 -0
  37. package/dist/error/developer.error.d.ts +8 -0
  38. package/dist/error/developer.error.js +10 -0
  39. package/dist/error/http.error.d.ts +13 -0
  40. package/dist/error/http.error.js +7 -0
  41. package/dist/error/index.types.d.ts +149 -0
  42. package/dist/error/invalid-value.error.d.ts +3 -0
  43. package/dist/error/invalid-value.error.js +3 -0
  44. package/dist/error/leyyo.error.d.ts +33 -0
  45. package/dist/error/leyyo.error.js +36 -0
  46. package/dist/error/multiple.error.d.ts +6 -0
  47. package/dist/error/multiple.error.js +7 -0
  48. package/dist/function/define-loader.d.ts +6 -0
  49. package/dist/function/define-loader.js +6 -0
  50. package/dist/function/delay.d.ts +8 -0
  51. package/dist/function/delay.js +9 -0
  52. package/dist/function/delete-prop.d.ts +21 -0
  53. package/dist/function/delete-prop.js +22 -0
  54. package/dist/function/empty-fn.d.ts +6 -0
  55. package/dist/function/empty-fn.js +7 -0
  56. package/dist/function/extended-type.d.ts +6 -0
  57. package/dist/function/extended-type.js +7 -0
  58. package/dist/function/get-fqn.d.ts +6 -0
  59. package/dist/function/get-fqn.js +7 -0
  60. package/dist/function/get-prop.d.ts +21 -0
  61. package/dist/function/get-prop.js +21 -0
  62. package/dist/function/get-stat.d.ts +20 -0
  63. package/dist/function/has-fqn.d.ts +6 -0
  64. package/dist/function/has-fqn.js +7 -0
  65. package/dist/function/is-class.d.ts +6 -0
  66. package/dist/function/is-class.js +18 -0
  67. package/dist/function/is-empty.d.ts +11 -0
  68. package/dist/function/is-empty.js +11 -0
  69. package/dist/function/is-filled-arr.d.ts +9 -0
  70. package/dist/function/is-filled-arr.js +9 -0
  71. package/dist/function/is-filled-obj.d.ts +9 -0
  72. package/dist/function/is-filled-obj.js +9 -0
  73. package/dist/function/is-obj.d.ts +8 -0
  74. package/dist/function/is-obj.js +8 -0
  75. package/dist/function/is-test.d.ts +8 -0
  76. package/dist/function/is-test.js +14 -0
  77. package/dist/function/is-text.d.ts +10 -0
  78. package/dist/function/is-text.js +10 -0
  79. package/dist/function/jitter-interval.d.ts +9 -0
  80. package/dist/function/jitter-interval.js +16 -0
  81. package/dist/function/load-config.d.ts +19 -0
  82. package/dist/function/load-config.js +52 -1
  83. package/dist/function/on-fqn-set.js +1 -0
  84. package/dist/function/one-or-more.d.ts +6 -0
  85. package/dist/function/one-or-more.js +7 -0
  86. package/dist/function/opt-add.d.ts +8 -0
  87. package/dist/function/opt-add.js +8 -0
  88. package/dist/function/opt-append.d.ts +7 -0
  89. package/dist/function/opt-append.js +7 -0
  90. package/dist/function/opt-check.d.ts +6 -0
  91. package/dist/function/opt-check.js +7 -0
  92. package/dist/function/opt-clone.d.ts +6 -0
  93. package/dist/function/opt-clone.js +7 -0
  94. package/dist/function/opt-field.d.ts +8 -0
  95. package/dist/function/opt-field.js +8 -0
  96. package/dist/function/opt-fn.d.ts +6 -0
  97. package/dist/function/opt-fn.js +7 -0
  98. package/dist/function/random-test-no.d.ts +5 -0
  99. package/dist/function/random-test-no.js +5 -0
  100. package/dist/function/remove-fqn.d.ts +8 -0
  101. package/dist/function/remove-fqn.js +11 -1
  102. package/dist/function/run-exporter.d.ts +5 -0
  103. package/dist/function/run-exporter.js +14 -0
  104. package/dist/function/secure-json.d.ts +35 -0
  105. package/dist/function/secure-json.js +44 -0
  106. package/dist/function/set-anonymous-fqn.js +2 -0
  107. package/dist/function/set-fqn.d.ts +7 -0
  108. package/dist/function/set-fqn.js +8 -0
  109. package/dist/function/set-prop.d.ts +24 -0
  110. package/dist/function/set-prop.js +24 -0
  111. package/dist/function/stamp-loader.d.ts +6 -0
  112. package/dist/function/stamp-loader.js +6 -0
  113. package/dist/function/test-case.d.ts +7 -0
  114. package/dist/function/test-case.js +7 -0
  115. package/dist/function/test-name.d.ts +7 -0
  116. package/dist/function/test-name.js +7 -0
  117. package/dist/function/trigger-fqn.js +1 -0
  118. package/dist/index.foretell.js +3 -0
  119. package/dist/index.js +1 -0
  120. package/dist/index.loader.js +8 -1
  121. package/dist/sys/leyyo-storage.d.ts +7 -0
  122. package/dist/sys/leyyo-storage.js +23 -0
  123. 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;
@@ -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 +1,6 @@
1
+ /**
2
+ * Generate random test no
3
+ *
4
+ * @return {string}
5
+ * */
1
6
  export declare function randomTestNo(): string;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Generate random test no
3
+ *
4
+ * @return {string}
5
+ * */
1
6
  export function randomTestNo() {
2
7
  return (Math.floor(Math.random() * 999) + 100).toString(10);
3
8
  }
@@ -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,2 +1,7 @@
1
1
  import { ExporterData } from "./index.types.js";
2
+ /**
3
+ * Run exporter
4
+ *
5
+ * @return {Promise<ExporterData>}
6
+ * */
2
7
  export declare function runExporter(): Promise<ExporterData>;
@@ -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;
@@ -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 +1,8 @@
1
+ /**
2
+ * Build test case
3
+ *
4
+ * @param {string} pck - Package or FQN name
5
+ * @param {(string|number)} caseNo
6
+ * @return {string}
7
+ * */
1
8
  export declare function testCase(pck: string, caseNo: string | number): string;
@@ -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 +1,8 @@
1
+ /**
2
+ * Build test name
3
+ *
4
+ * @param {string} testCase - it would be built via {@link testCase}
5
+ * @param {string} title - test title
6
+ * @return {string}
7
+ * */
1
8
  export declare function testName(testCase: string, title: string): string;
@@ -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 : "???";
@@ -10,6 +10,7 @@ export function triggerFqn(target, full) {
10
10
  callback(full);
11
11
  }
12
12
  catch (_e) {
13
+ // nothing
13
14
  }
14
15
  }
15
16
  });
@@ -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
@@ -1,3 +1,4 @@
1
+ // noinspection JSUnusedGlobalSymbols
1
2
  import { init } from "./init/index.js";
2
3
  import { leyyo } from "./base/index.js";
3
4
  import { setFqn } from "./function/index.js";
@@ -1,3 +1,10 @@
1
1
  import { defineLoader } from "./function/index.js";
2
2
  import { FQN } from "./internal.js";
3
- export const loader_leyyoCommon = defineLoader(FQN, () => 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), () => import("./enum/log-level.js").then((m) => m.LogLevelItems), () => import("./class/list.js").then((m) => m.List), () => import("./class/logger.instance.js").then((m) => m.LoggerInstance));
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leyyo/common",
3
- "version": "1.3.19",
3
+ "version": "1.3.20",
4
4
  "description": "Leyyo common library",
5
5
  "keywords": [
6
6
  "common"