@leyyo/common 1.3.17 → 1.3.19

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 (146) hide show
  1. package/dist/base/index.d.ts +3 -3
  2. package/dist/base/index.js +3 -3
  3. package/dist/base/index.types.d.ts +3 -70
  4. package/dist/base/index.types.js +0 -32
  5. package/dist/base/leyyo.d.ts +0 -3
  6. package/dist/base/leyyo.js +12 -23
  7. package/dist/class/index.d.ts +2 -2
  8. package/dist/class/index.js +2 -2
  9. package/dist/class/index.types.d.ts +0 -20
  10. package/dist/class/list.d.ts +0 -6
  11. package/dist/class/list.js +0 -6
  12. package/dist/class/logger.instance.d.ts +8 -13
  13. package/dist/class/logger.instance.js +13 -27
  14. package/dist/common/deploy.common.d.ts +0 -16
  15. package/dist/common/deploy.common.js +4 -21
  16. package/dist/common/enum.pool.d.ts +5 -13
  17. package/dist/common/enum.pool.js +16 -17
  18. package/dist/common/error.common.d.ts +0 -30
  19. package/dist/common/error.common.js +33 -69
  20. package/dist/common/error.pool.d.ts +1 -10
  21. package/dist/common/error.pool.js +2 -13
  22. package/dist/common/event.common.d.ts +0 -8
  23. package/dist/common/event.common.js +15 -25
  24. package/dist/common/index.d.ts +11 -11
  25. package/dist/common/index.js +11 -11
  26. package/dist/common/index.types.d.ts +12 -435
  27. package/dist/common/index.types.js +0 -1
  28. package/dist/common/inert.d.ts +1 -49
  29. package/dist/common/inert.js +35 -64
  30. package/dist/common/lifecycle.common.d.ts +0 -14
  31. package/dist/common/lifecycle.common.js +13 -29
  32. package/dist/common/literal.pool.d.ts +1 -12
  33. package/dist/common/literal.pool.js +3 -18
  34. package/dist/common/log.common.d.ts +0 -54
  35. package/dist/common/log.common.js +62 -147
  36. package/dist/common/repo.common.d.ts +0 -188
  37. package/dist/common/repo.common.js +23 -239
  38. package/dist/const/index.d.ts +8 -12
  39. package/dist/const/index.js +28 -33
  40. package/dist/enum/index.d.ts +1 -1
  41. package/dist/enum/index.js +1 -1
  42. package/dist/enum/log-level.d.ts +1 -4
  43. package/dist/enum/log-level.js +1 -1
  44. package/dist/error/caused.error.d.ts +0 -10
  45. package/dist/error/caused.error.js +0 -10
  46. package/dist/error/developer.error.d.ts +4 -17
  47. package/dist/error/developer.error.js +11 -33
  48. package/dist/error/http.error.d.ts +0 -13
  49. package/dist/error/http.error.js +1 -8
  50. package/dist/error/index.d.ts +7 -7
  51. package/dist/error/index.js +7 -7
  52. package/dist/error/index.types.d.ts +1 -150
  53. package/dist/error/invalid-value.error.d.ts +0 -3
  54. package/dist/error/invalid-value.error.js +1 -4
  55. package/dist/error/leyyo.error.d.ts +2 -35
  56. package/dist/error/leyyo.error.js +26 -58
  57. package/dist/error/multiple.error.d.ts +0 -6
  58. package/dist/error/multiple.error.js +2 -9
  59. package/dist/function/define-loader.d.ts +0 -6
  60. package/dist/function/define-loader.js +0 -6
  61. package/dist/function/delay.d.ts +0 -8
  62. package/dist/function/delay.js +0 -9
  63. package/dist/function/delete-prop.d.ts +0 -21
  64. package/dist/function/delete-prop.js +6 -28
  65. package/dist/function/empty-fn.d.ts +0 -6
  66. package/dist/function/empty-fn.js +1 -9
  67. package/dist/function/extended-type.d.ts +0 -6
  68. package/dist/function/extended-type.js +18 -24
  69. package/dist/function/get-fqn.d.ts +0 -6
  70. package/dist/function/get-fqn.js +2 -8
  71. package/dist/function/get-prop.d.ts +0 -21
  72. package/dist/function/get-prop.js +5 -26
  73. package/dist/function/get-stat.d.ts +0 -20
  74. package/dist/function/get-stat.js +7 -2
  75. package/dist/function/has-fqn.d.ts +0 -6
  76. package/dist/function/has-fqn.js +2 -8
  77. package/dist/function/index.d.ts +40 -40
  78. package/dist/function/index.js +40 -40
  79. package/dist/function/index.types.d.ts +1 -1
  80. package/dist/function/is-anonymous-name.js +1 -1
  81. package/dist/function/is-class.d.ts +0 -6
  82. package/dist/function/is-class.js +2 -20
  83. package/dist/function/is-empty.d.ts +0 -11
  84. package/dist/function/is-empty.js +1 -12
  85. package/dist/function/is-filled-arr.d.ts +0 -9
  86. package/dist/function/is-filled-arr.js +0 -9
  87. package/dist/function/is-filled-obj.d.ts +0 -9
  88. package/dist/function/is-filled-obj.js +0 -9
  89. package/dist/function/is-obj.d.ts +0 -8
  90. package/dist/function/is-obj.js +1 -9
  91. package/dist/function/is-test.d.ts +0 -8
  92. package/dist/function/is-test.js +3 -19
  93. package/dist/function/is-text.d.ts +0 -10
  94. package/dist/function/is-text.js +1 -11
  95. package/dist/function/jitter-interval.d.ts +0 -9
  96. package/dist/function/jitter-interval.js +2 -18
  97. package/dist/function/load-config.d.ts +0 -19
  98. package/dist/function/load-config.js +10 -61
  99. package/dist/function/on-fqn-set.js +3 -3
  100. package/dist/function/one-or-more.d.ts +0 -6
  101. package/dist/function/one-or-more.js +0 -7
  102. package/dist/function/opt-add.d.ts +0 -8
  103. package/dist/function/opt-add.js +2 -10
  104. package/dist/function/opt-append.d.ts +0 -7
  105. package/dist/function/opt-append.js +0 -7
  106. package/dist/function/opt-check.d.ts +0 -6
  107. package/dist/function/opt-check.js +2 -9
  108. package/dist/function/opt-clone.d.ts +0 -6
  109. package/dist/function/opt-clone.js +0 -7
  110. package/dist/function/opt-field.d.ts +0 -8
  111. package/dist/function/opt-field.js +6 -14
  112. package/dist/function/opt-fn.d.ts +0 -6
  113. package/dist/function/opt-fn.js +0 -7
  114. package/dist/function/random-test-no.d.ts +0 -5
  115. package/dist/function/random-test-no.js +0 -5
  116. package/dist/function/remove-fqn.d.ts +0 -8
  117. package/dist/function/remove-fqn.js +3 -12
  118. package/dist/function/run-exporter.d.ts +0 -5
  119. package/dist/function/run-exporter.js +3 -17
  120. package/dist/function/secure-clone.js +3 -3
  121. package/dist/function/secure-json.d.ts +0 -35
  122. package/dist/function/secure-json.js +12 -54
  123. package/dist/function/set-anonymous-fqn.js +4 -5
  124. package/dist/function/set-anonymous-name.js +14 -14
  125. package/dist/function/set-fqn.d.ts +0 -7
  126. package/dist/function/set-fqn.js +8 -15
  127. package/dist/function/set-prop.d.ts +0 -24
  128. package/dist/function/set-prop.js +6 -30
  129. package/dist/function/stamp-loader.d.ts +0 -6
  130. package/dist/function/stamp-loader.js +1 -7
  131. package/dist/function/test-case.d.ts +0 -7
  132. package/dist/function/test-case.js +3 -10
  133. package/dist/function/test-name.d.ts +0 -7
  134. package/dist/function/test-name.js +2 -9
  135. package/dist/function/trigger-fqn.js +2 -3
  136. package/dist/index.d.ts +10 -10
  137. package/dist/index.foretell.js +7 -10
  138. package/dist/index.js +10 -11
  139. package/dist/index.loader.js +1 -8
  140. package/dist/init/index.js +5 -7
  141. package/dist/sys/index.d.ts +2 -2
  142. package/dist/sys/index.js +2 -2
  143. package/dist/sys/leyyo-storage.d.ts +0 -7
  144. package/dist/sys/leyyo-storage.js +5 -28
  145. package/dist/sys/package-json.js +5 -5
  146. package/package.json +16 -31
@@ -1,10 +1,2 @@
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
- * */
10
2
  export declare function removeFqn(target: FqnTarget): boolean;
@@ -1,31 +1,22 @@
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
- * */
11
3
  export function removeFqn(target) {
12
4
  if (!target) {
13
5
  return false;
14
6
  }
15
- if (typeof target === 'function') { // function, class
7
+ if (typeof target === "function") {
16
8
  return _item(target, target.name);
17
9
  }
18
- else if (typeof target === 'object') {
10
+ else if (typeof target === "object") {
19
11
  if (Array.isArray(target)) {
20
12
  if (target[KEY_LITERAL_NAME]) {
21
13
  return _item(target, target[KEY_LITERAL_NAME]);
22
14
  }
23
- return false; // normal array
15
+ return false;
24
16
  }
25
17
  if (target[KEY_ENUM_NAME]) {
26
18
  return _item(target, target[KEY_ENUM_NAME]);
27
19
  }
28
- // instance
29
20
  return false;
30
21
  }
31
22
  return false;
@@ -1,7 +1,2 @@
1
1
  import { ExporterData } from "./index.types.js";
2
- /**
3
- * Run exporter
4
- *
5
- * @return {Promise<ExporterData>}
6
- * */
7
2
  export declare function runExporter(): Promise<ExporterData>;
@@ -1,34 +1,20 @@
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
- * */
9
3
  export async function runExporter() {
10
4
  const data = {};
11
5
  const depot = {
12
6
  add(name, value) {
13
7
  append(data, name, value, 0);
14
- }
8
+ },
15
9
  };
16
10
  if (!_leyyo) {
17
11
  _leyyo = $$get_leyyo_fn();
18
12
  }
19
- await _leyyo.lifecycleCommon.runStage('print', depot);
13
+ await _leyyo.lifecycleCommon.runStage("print", depot);
20
14
  return data;
21
15
  }
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
- * */
30
16
  const append = (data, name, value, duplicated) => {
31
- const postfix = (duplicated === 0) ? '' : '#' + duplicated;
17
+ const postfix = duplicated === 0 ? "" : "#" + duplicated;
32
18
  if (data[name + postfix] !== undefined) {
33
19
  data[name + postfix] = value;
34
20
  }
@@ -2,7 +2,7 @@ export function _secureClone(value, weakSet) {
2
2
  if (value === undefined || value === null) {
3
3
  return value;
4
4
  }
5
- if (typeof value !== 'object') {
5
+ if (typeof value !== "object") {
6
6
  return value;
7
7
  }
8
8
  if (weakSet.has(weakSet)) {
@@ -10,10 +10,10 @@ export function _secureClone(value, weakSet) {
10
10
  }
11
11
  weakSet.add(value);
12
12
  if (Array.isArray(value)) {
13
- return value.map(item => secureClone(item));
13
+ return value.map((item) => secureClone(item));
14
14
  }
15
15
  if (value instanceof Set) {
16
- return new Set(Array.from(value.values()).map(item => secureClone(item)));
16
+ return new Set(Array.from(value.values()).map((item) => secureClone(item)));
17
17
  }
18
18
  if (value instanceof Map) {
19
19
  const newMap = new Map();
@@ -1,37 +1,2 @@
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
- * */
17
1
  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
- * */
37
2
  export declare function secureJson(value: unknown): string;
@@ -1,16 +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
- * */
8
1
  function _secureObject(value, depth, set) {
9
2
  if ([null, undefined].includes(value)) {
10
3
  return value;
11
4
  }
5
+ let obj;
12
6
  switch (typeof value) {
13
- case 'object':
7
+ case "object":
14
8
  if (set.has(value)) {
15
9
  return `#circular <${value?.constructor?.name}>`;
16
10
  }
@@ -19,22 +13,22 @@ function _secureObject(value, depth, set) {
19
13
  }
20
14
  set.add(value);
21
15
  if (Array.isArray(value)) {
22
- return value.map(item => _secureObject(item, depth + 1, set));
16
+ return value.map((item) => _secureObject(item, depth + 1, set));
23
17
  }
24
18
  if (value instanceof Set) {
25
- return Array.from(value).map(item => _secureObject(item, depth + 1, set));
19
+ return Array.from(value).map((item) => _secureObject(item, depth + 1, set));
26
20
  }
27
- const obj = {};
21
+ obj = {};
28
22
  if (value instanceof Map) {
29
23
  for (const [k, v] of value.entries()) {
30
- if (typeof k === 'string') {
24
+ if (typeof k === "string") {
31
25
  obj[k] = _secureObject(v, depth + 1, set);
32
26
  }
33
27
  }
34
28
  }
35
29
  else if (value?.constructor === Object) {
36
30
  for (const [k, v] of Object.entries(value)) {
37
- if (typeof k === 'string') {
31
+ if (typeof k === "string") {
38
32
  obj[k] = _secureObject(v, depth + 1, set);
39
33
  }
40
34
  }
@@ -42,7 +36,8 @@ function _secureObject(value, depth, set) {
42
36
  else {
43
37
  let exists;
44
38
  for (const [k, v] of Object.entries(value)) {
45
- if (typeof k === 'string' && !['function', 'symbol', 'undefined'].includes(typeof value)) {
39
+ if (typeof k === "string" &&
40
+ !["function", "symbol", "undefined"].includes(typeof value)) {
46
41
  exists = true;
47
42
  obj[k] = _secureObject(v, depth + 1, set);
48
43
  }
@@ -57,30 +52,13 @@ function _secureObject(value, depth, set) {
57
52
  }
58
53
  }
59
54
  return obj;
60
- case 'function':
55
+ case "function":
61
56
  return `#function <${value.name}> (length: ${value.length})`;
62
- case 'symbol':
57
+ case "symbol":
63
58
  return `#symbol <${value.description}>`;
64
59
  }
65
60
  return value;
66
61
  }
67
- // noinspection JSUnusedGlobalSymbols
68
- /**
69
- * Converts an object to secure object
70
- *
71
- * - `secure` means:
72
- * - removes `circular` relations
73
- * - cuts after max depths, default: `10`
74
- * - converts `Set` to `array`
75
- * - converts `Map` to `object`
76
- * - cuts `methods` of an object
77
- * - cuts `symbol` properties of an object
78
- * - cuts `non-string keys` of an object
79
- * - cuts `undefined` properties of an object
80
- *
81
- * @param {any} value
82
- * @return {any}
83
- * */
84
62
  export function secureObject(value) {
85
63
  try {
86
64
  return _secureObject(value, 0, new WeakSet());
@@ -89,30 +67,10 @@ export function secureObject(value) {
89
67
  return `#error <${e.name}> (message: ${e.message})`;
90
68
  }
91
69
  }
92
- // noinspection JSUnusedGlobalSymbols
93
- /**
94
- * Converts an object to secure string
95
- *
96
- * - `secure` means:
97
- * - removes `circular` relations
98
- * - cuts after max depths, default: `10`
99
- * - converts `Set` to `array`
100
- * - converts `Map` to `object`
101
- * - cuts `methods` of an object
102
- * - cuts `symbol` properties of an object
103
- * - cuts `non-string keys` of an object
104
- * - cuts `undefined` properties of an object
105
- *
106
- * Note:
107
- * `JSON.stringify` can fail if there is a `dependency
108
- *
109
- * @param {any} value
110
- * @return {string}
111
- * */
112
70
  export function secureJson(value) {
113
71
  try {
114
72
  const json = _secureObject(value, 0, new WeakSet());
115
- return (typeof json === 'string') ? json : JSON.stringify(json);
73
+ return typeof json === "string" ? json : JSON.stringify(json);
116
74
  }
117
75
  catch (e) {
118
76
  return `#error <${e.name}> (message: ${e.message})`;
@@ -1,4 +1,4 @@
1
- import { KEY_ENUM_NAME, KEY_FQN_NAME, KEY_LITERAL_NAME, VAL_FQN_ANONYMOUS } from "../const/index.js";
1
+ import { KEY_ENUM_NAME, KEY_FQN_NAME, KEY_LITERAL_NAME, VAL_FQN_ANONYMOUS, } from "../const/index.js";
2
2
  import { triggerFqn } from "./trigger-fqn.js";
3
3
  import { setAnonymousName } from "./set-anonymous-name.js";
4
4
  import { isClass } from "./is-class.js";
@@ -7,13 +7,13 @@ export function setAnonymousFqn(target) {
7
7
  if (!target) {
8
8
  return undefined;
9
9
  }
10
- if (typeof target === 'function') { // function, class
10
+ if (typeof target === "function") {
11
11
  if (!target.name) {
12
- setAnonymousName(target, isClass(target) ? 'Class' : 'function');
12
+ setAnonymousName(target, isClass(target) ? "Class" : "function");
13
13
  }
14
14
  return _item(target, target.name);
15
15
  }
16
- else if (typeof target === 'object') {
16
+ else if (typeof target === "object") {
17
17
  if (Array.isArray(target)) {
18
18
  if (target[KEY_LITERAL_NAME]) {
19
19
  return _item(target, target[KEY_LITERAL_NAME]);
@@ -23,7 +23,6 @@ export function setAnonymousFqn(target) {
23
23
  if (target[KEY_ENUM_NAME]) {
24
24
  return _item(target, target[KEY_ENUM_NAME]);
25
25
  }
26
- // instance
27
26
  return undefined;
28
27
  }
29
28
  return undefined;
@@ -9,25 +9,25 @@ let _counter = 0;
9
9
  const where = `${FQN}.nameFn`;
10
10
  let _leyyo;
11
11
  export function setAnonymousName(target, prefix) {
12
- if (typeof target !== 'function') {
12
+ if (typeof target !== "function") {
13
13
  if (!_leyyo) {
14
14
  _leyyo = $$get_leyyo_fn();
15
15
  }
16
- throw new _leyyo.developerError(`Invalid target`, testCase(FQN, 'ZZZ'), where);
16
+ throw new _leyyo.developerError(`Invalid target`, testCase(FQN, "ZZZ"), where);
17
17
  }
18
18
  if (isText(prefix)) {
19
19
  if (!_pattern.test(prefix)) {
20
20
  if (!_leyyo) {
21
21
  _leyyo = $$get_leyyo_fn();
22
22
  }
23
- throw new _leyyo.developerError(`Invalid anonymous name part [${prefix}]`, testCase(FQN, 'ZZZ'), where);
23
+ throw new _leyyo.developerError(`Invalid anonymous name part [${prefix}]`, testCase(FQN, "ZZZ"), where);
24
24
  }
25
25
  }
26
26
  else {
27
- prefix = isClass(target) ? 'Class' : 'function';
27
+ prefix = isClass(target) ? "Class" : "function";
28
28
  }
29
29
  _counter++;
30
- const name = VAL_NAME_ANONYMOUS + [prefix, _counter].join('$');
30
+ const name = VAL_NAME_ANONYMOUS + [prefix, _counter].join("$");
31
31
  _setName(target, name, false);
32
32
  return name;
33
33
  }
@@ -36,27 +36,27 @@ function _setName(target, name, checkAnonymous) {
36
36
  _leyyo = $$get_leyyo_fn();
37
37
  }
38
38
  if (!isText(name)) {
39
- throw new _leyyo.developerError(`Invalid name`, testCase(FQN, 'ZZZ'), where);
39
+ throw new _leyyo.developerError(`Invalid name`, testCase(FQN, "ZZZ"), where);
40
40
  }
41
- if (name.includes('.')) {
42
- throw new _leyyo.developerError(`Invalid name with dot`, testCase(FQN, 'ZZZ'), where);
41
+ if (name.includes(".")) {
42
+ throw new _leyyo.developerError(`Invalid name with dot`, testCase(FQN, "ZZZ"), where);
43
43
  }
44
44
  if (checkAnonymous && name.startsWith(VAL_NAME_ANONYMOUS)) {
45
- throw new _leyyo.developerError(`Invalid name with anonymous`, testCase(FQN, 'ZZZ'), where);
45
+ throw new _leyyo.developerError(`Invalid name with anonymous`, testCase(FQN, "ZZZ"), where);
46
46
  }
47
- if (typeof target !== 'function') {
48
- throw new _leyyo.developerError(`Invalid name [${name}]`, testCase(FQN, 'ZZZ'), where);
47
+ if (typeof target !== "function") {
48
+ throw new _leyyo.developerError(`Invalid name [${name}]`, testCase(FQN, "ZZZ"), where);
49
49
  }
50
50
  try {
51
- Object.defineProperty(target, 'name', {
51
+ Object.defineProperty(target, "name", {
52
52
  value: name,
53
53
  configurable: true,
54
54
  writable: true,
55
- enumerable: true
55
+ enumerable: true,
56
56
  });
57
57
  }
58
58
  catch (e) {
59
- new _leyyo.developerError(`Unexpected error during set name [${name}]`, testCase(FQN, 'ZZZ'), where).log(e);
59
+ new _leyyo.developerError(`Unexpected error during set name [${name}]`, testCase(FQN, "ZZZ"), where).log(e);
60
60
  return false;
61
61
  }
62
62
  return true;
@@ -1,9 +1,2 @@
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
- * */
9
2
  export declare function setFqn(target: FqnTarget, fqn: string): string;
@@ -3,46 +3,39 @@ import { $$get_leyyo_fn } from "./leyyo-fn.js";
3
3
  import { isClass } from "./is-class.js";
4
4
  import { isText } from "./is-text.js";
5
5
  import { testCase } from "./test-case.js";
6
- import { KEY_ENUM_NAME, KEY_FQN_NAME, KEY_LITERAL_NAME, VAL_FQN_ANONYMOUS } from "../const/index.js";
6
+ import { KEY_ENUM_NAME, KEY_FQN_NAME, KEY_LITERAL_NAME, VAL_FQN_ANONYMOUS, } from "../const/index.js";
7
7
  import { triggerFqn } from "./trigger-fqn.js";
8
8
  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
- * */
19
12
  export function setFqn(target, fqn) {
20
13
  if (!_leyyo) {
21
14
  _leyyo = $$get_leyyo_fn();
22
15
  }
23
16
  if (!isText(fqn)) {
24
- new _leyyo.developerError('Invalid fqn name', testCase(FQN, 150), where).log();
17
+ new _leyyo.developerError("Invalid fqn name", testCase(FQN, 150), where).log();
25
18
  return undefined;
26
19
  }
27
- if (fqn.startsWith('.') || fqn.endsWith('.')) {
28
- new _leyyo.developerError('Invalid fqn name with dots', testCase(FQN, 'ZZZ'), where).log();
20
+ if (fqn.startsWith(".") || fqn.endsWith(".")) {
21
+ new _leyyo.developerError("Invalid fqn name with dots", testCase(FQN, "ZZZ"), where).log();
29
22
  return undefined;
30
23
  }
31
24
  if (fqn.startsWith(VAL_FQN_ANONYMOUS)) {
32
- new _leyyo.developerError('Anonymous fqn is used', testCase(FQN, 'ZZZ'), where).log();
25
+ new _leyyo.developerError("Anonymous fqn is used", testCase(FQN, "ZZZ"), where).log();
33
26
  return undefined;
34
27
  }
35
28
  if (!target) {
36
29
  new _leyyo.developerError(`Empty fqn target [${fqn}]`, testCase(FQN, 151), where).log();
37
30
  return undefined;
38
31
  }
39
- if (typeof target === 'function') { // function, class
32
+ if (typeof target === "function") {
40
33
  if (!target.name) {
41
- setAnonymousName(target, isClass(target) ? 'Class' : 'function');
34
+ setAnonymousName(target, isClass(target) ? "Class" : "function");
42
35
  }
43
36
  return _item(target, target.name, fqn);
44
37
  }
45
- else if (typeof target === 'object') {
38
+ else if (typeof target === "object") {
46
39
  if (Array.isArray(target)) {
47
40
  if (target[KEY_LITERAL_NAME]) {
48
41
  return _item(target, target[KEY_LITERAL_NAME], fqn);
@@ -1,27 +1,3 @@
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
- * */
9
1
  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
- * */
18
2
  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
- * */
27
3
  export declare function setProp(target: unknown, key: symbol | string, value: unknown): boolean;
@@ -3,47 +3,23 @@ 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
- * */
14
6
  export function setKey(target, key, value) {
15
- if (typeof key !== 'string') {
7
+ if (typeof key !== "string") {
16
8
  return false;
17
9
  }
18
10
  return setProp(target, key, value);
19
11
  }
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
- * */
28
12
  export function setSymbol(target, key, value) {
29
- if (typeof key !== 'symbol') {
13
+ if (typeof key !== "symbol") {
30
14
  return false;
31
15
  }
32
16
  return setProp(target, key, value);
33
17
  }
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
- * */
42
18
  export function setProp(target, key, value) {
43
- if (!['symbol', 'string'].includes(typeof key)) {
19
+ if (!["symbol", "string"].includes(typeof key)) {
44
20
  return false;
45
21
  }
46
- if (!target || !['object', 'function'].includes(typeof target)) {
22
+ if (!target || !["object", "function"].includes(typeof target)) {
47
23
  return false;
48
24
  }
49
25
  try {
@@ -51,7 +27,7 @@ export function setProp(target, key, value) {
51
27
  value,
52
28
  configurable: false,
53
29
  writable: false,
54
- enumerable: typeof key === 'string'
30
+ enumerable: typeof key === "string",
55
31
  });
56
32
  return true;
57
33
  }
@@ -59,7 +35,7 @@ export function setProp(target, key, value) {
59
35
  if (!_leyyo) {
60
36
  _leyyo = $$get_leyyo_fn();
61
37
  }
62
- new _leyyo.developerError(`Unexpected error during set name [${key.toString()}]`, testCase(FQN, 'ZZZ'), where).log(e);
38
+ new _leyyo.developerError(`Unexpected error during set name [${key.toString()}]`, testCase(FQN, "ZZZ"), where).log(e);
63
39
  return false;
64
40
  }
65
41
  }
@@ -1,8 +1,2 @@
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
- * */
8
2
  export declare function stampLoader(fn: LeyyoStampLambda): LeyyoStampLambda | LeyyoStampEmpty;
@@ -1,12 +1,6 @@
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
- * */
8
2
  export function stampLoader(fn) {
9
- if (typeof fn === 'function') {
3
+ if (typeof fn === "function") {
10
4
  fn[KEY_LOADER_STAMP] = true;
11
5
  return fn;
12
6
  }
@@ -1,8 +1 @@
1
- /**
2
- * Build test case
3
- *
4
- * @param {string} pck - Package or FQN name
5
- * @param {(string|number)} caseNo
6
- * @return {string}
7
- * */
8
1
  export declare function testCase(pck: string, caseNo: string | number): string;
@@ -1,19 +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
- * */
10
3
  export function testCase(pck, caseNo) {
11
- pck = (typeof pck === 'string') ? pck : FQN;
4
+ pck = typeof pck === "string" ? pck : FQN;
12
5
  let caseStr;
13
- if (typeof caseNo === 'string') {
6
+ if (typeof caseNo === "string") {
14
7
  caseStr = caseNo;
15
8
  }
16
- else if (typeof caseNo === 'number') {
9
+ else if (typeof caseNo === "number") {
17
10
  caseStr = caseNo.toString(10);
18
11
  }
19
12
  else {
@@ -1,8 +1 @@
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
- * */
8
1
  export declare function testName(testCase: string, title: string): string;
@@ -1,14 +1,7 @@
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
- * */
10
3
  export function testName(testCase, title) {
11
- testCase = (typeof testCase === 'string') ? testCase : `${FQN}@${randomTestNo()}`;
12
- title = (typeof title === 'string') ? title : '???';
4
+ testCase = typeof testCase === "string" ? testCase : `${FQN}@${randomTestNo()}`;
5
+ title = typeof title === "string" ? title : "???";
13
6
  return `[test:${testCase}] >> ${title}`;
14
7
  }
@@ -4,13 +4,12 @@ export function triggerFqn(target, full) {
4
4
  const arr = target[KEY_FQN_ON_SET];
5
5
  delete target[KEY_FQN_ON_SET];
6
6
  if (Array.isArray(arr)) {
7
- arr.forEach(callback => {
8
- if (typeof callback === 'function') {
7
+ arr.forEach((callback) => {
8
+ if (typeof callback === "function") {
9
9
  try {
10
10
  callback(full);
11
11
  }
12
12
  catch (_e) {
13
- // nothing
14
13
  }
15
14
  }
16
15
  });