@leyyo/common 1.3.18 → 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 +8 -19
  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 +6 -11
  13. package/dist/class/logger.instance.js +11 -25
  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 +0 -7
  39. package/dist/const/index.js +28 -36
  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 +1 -10
  47. package/dist/error/developer.error.js +6 -25
  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 +0 -33
  56. package/dist/error/leyyo.error.js +25 -57
  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 @@
1
- /**
2
- * Is filled array?
3
- * Means
4
- * - `constructor === "Array"`
5
- * - `arr.length > 0`
6
- *
7
- * @param {any} arr - given value
8
- * @return {boolean} - is filled array?
9
- * */
10
1
  export declare function isFilledArr(arr: unknown): boolean;
@@ -1,12 +1,3 @@
1
- /**
2
- * Is filled array?
3
- * Means
4
- * - `constructor === "Array"`
5
- * - `arr.length > 0`
6
- *
7
- * @param {any} arr - given value
8
- * @return {boolean} - is filled array?
9
- * */
10
1
  export function isFilledArr(arr) {
11
2
  return Array.isArray(arr) && arr.length > 0;
12
3
  }
@@ -1,10 +1 @@
1
- /**
2
- * Is filled object?
3
- * Means:
4
- * - `constructor === "Object"`
5
- * - `obj.keys.length > 0`
6
- *
7
- * @param {any} obj - given value
8
- * @return {boolean} - is filled object?
9
- * */
10
1
  export declare function isFilledObj(obj: unknown): boolean;
@@ -1,13 +1,4 @@
1
1
  import { isObj } from "./is-obj.js";
2
- /**
3
- * Is filled object?
4
- * Means:
5
- * - `constructor === "Object"`
6
- * - `obj.keys.length > 0`
7
- *
8
- * @param {any} obj - given value
9
- * @return {boolean} - is filled object?
10
- * */
11
2
  export function isFilledObj(obj) {
12
3
  return isObj(obj) && Object.keys(obj).length > 0;
13
4
  }
@@ -1,9 +1 @@
1
- /**
2
- * Is bare object?
3
- * Means:
4
- * - `constructor === "Object"`
5
- *
6
- * @param {any} obj - given value
7
- * @return {boolean} - is bare object?
8
- * */
9
1
  export declare function isObj(obj: unknown): boolean;
@@ -1,11 +1,3 @@
1
- /**
2
- * Is bare object?
3
- * Means:
4
- * - `constructor === "Object"`
5
- *
6
- * @param {any} obj - given value
7
- * @return {boolean} - is bare object?
8
- * */
9
1
  export function isObj(obj) {
10
- return obj && typeof obj === 'object' && !Array.isArray(obj);
2
+ return obj && typeof obj === "object" && !Array.isArray(obj);
11
3
  }
@@ -1,10 +1,2 @@
1
- /**
2
- * Initialize test
3
- * */
4
1
  export declare function initTest(): void;
5
- /**
6
- * Is test?
7
- *
8
- * @return {boolean}
9
- * */
10
2
  export declare function isTest(): boolean;
@@ -1,32 +1,16 @@
1
- // noinspection JSUnusedGlobalSymbols
2
- // region properties
3
- /**
4
- * Is test?
5
- * */
6
1
  let _isTest;
7
- // endregion properties
8
- /**
9
- * Initialize test
10
- * */
11
2
  export function initTest() {
12
3
  _isTest = true;
13
4
  if (global) {
14
5
  if (!global.leyyo_is_testing) {
15
6
  global.leyyo_is_testing = true;
16
- ['log', 'warn', 'info', 'debug', 'trace', 'error', 'fatal'].forEach(name => {
17
- global.console[name] = () => {
18
- };
19
- console[name] = () => {
20
- };
7
+ ["log", "warn", "info", "debug", "trace", "error", "fatal"].forEach((name) => {
8
+ global.console[name] = () => { };
9
+ console[name] = () => { };
21
10
  });
22
11
  }
23
12
  }
24
13
  }
25
- /**
26
- * Is test?
27
- *
28
- * @return {boolean}
29
- * */
30
14
  export function isTest() {
31
15
  return _isTest;
32
16
  }
@@ -1,11 +1 @@
1
- /**
2
- * Is text?
3
- * Means:
4
- * - `typeof === "string"`
5
- * - `not empty string`
6
- * - `not starts/ends with space`
7
- *
8
- * @param {any} str - given value
9
- * @return {boolean} - is text?
10
- * */
11
1
  export declare function isText(str: unknown): boolean;
@@ -1,15 +1,5 @@
1
- /**
2
- * Is text?
3
- * Means:
4
- * - `typeof === "string"`
5
- * - `not empty string`
6
- * - `not starts/ends with space`
7
- *
8
- * @param {any} str - given value
9
- * @return {boolean} - is text?
10
- * */
11
1
  export function isText(str) {
12
- if (typeof str !== 'string') {
2
+ if (typeof str !== "string") {
13
3
  return false;
14
4
  }
15
5
  const val = str.trim();
@@ -1,10 +1 @@
1
- /**
2
- * Generate next delay time with exponential & randomized manner
3
- *
4
- * @param {number} tryCount - try count
5
- * @param {number} baseDelay - starting delay interval
6
- * @param {number} maxDelay - maximum delay interval
7
- * @param {number} maxTryCount - max try count, if `tryCount` excess it, it returns undefined
8
- * @return {number} - next interval time if (maxTryCount && `tryCount` >= `maxTryCount`)
9
- * */
10
1
  export declare function jitterInterval(tryCount: number, baseDelay: number, maxDelay: number, maxTryCount?: number): number;
@@ -1,15 +1,5 @@
1
- // noinspection JSUnusedGlobalSymbols
2
- /**
3
- * Generate next delay time with exponential & randomized manner
4
- *
5
- * @param {number} tryCount - try count
6
- * @param {number} baseDelay - starting delay interval
7
- * @param {number} maxDelay - maximum delay interval
8
- * @param {number} maxTryCount - max try count, if `tryCount` excess it, it returns undefined
9
- * @return {number} - next interval time if (maxTryCount && `tryCount` >= `maxTryCount`)
10
- * */
11
1
  export function jitterInterval(tryCount, baseDelay, maxDelay, maxTryCount) {
12
- if ([tryCount, baseDelay, maxDelay].some(v => !isValid(v))) {
2
+ if ([tryCount, baseDelay, maxDelay].some((v) => !isValid(v))) {
13
3
  return undefined;
14
4
  }
15
5
  if (isValid(maxTryCount) && tryCount >= maxTryCount) {
@@ -19,12 +9,6 @@ export function jitterInterval(tryCount, baseDelay, maxDelay, maxTryCount) {
19
9
  const result = Math.floor(exp / 2 + Math.random() * (exp / 2));
20
10
  return Number.isSafeInteger(result) ? result : undefined;
21
11
  }
22
- /**
23
- * Check value is expected interval value
24
- *
25
- * @param {any} value - given value, possible number
26
- * @return {boolean} - is it expected?
27
- * */
28
12
  function isValid(value) {
29
- return typeof value === 'number' && value > 0 && Number.isInteger(value) && Number.isSafeInteger(value);
13
+ return (typeof value === "number" && value > 0 && Number.isInteger(value) && Number.isSafeInteger(value));
30
14
  }
@@ -1,22 +1,3 @@
1
1
  import { LeyyoConfig } from "./index.types.js";
2
2
  export declare const leyyoConfig: LeyyoConfig;
3
- /**
4
- * Load config from `.leyyo.yaml` file
5
- *
6
- * `OBJECT` postfixes:
7
- * - !: only override (`don't merge`)
8
- * - ?: only merge (`don't override`)
9
- * - <empty>: only set if key is absent
10
- *
11
- * `ARRAY` postfixes:
12
- * - !: only override (`don't merge`)
13
- * - ?: only merge (`don't override`)
14
- * - <empty>: only set if key is absent
15
- *
16
- * Generics:
17
- * - `C`- config model
18
- *
19
- * @param {string} url
20
- * @return {LeyyoConfig}
21
- * */
22
3
  export declare function loadConfig(url: string): LeyyoConfig;
@@ -2,39 +2,20 @@ import * as fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { dirname } from "path";
4
4
  import { fileURLToPath } from "url";
5
- import * as yaml from 'js-yaml';
5
+ import * as yaml from "js-yaml";
6
6
  import { isObj } from "./is-obj.js";
7
7
  import { getRootStorage } from "../sys/index.js";
8
8
  import { isText } from "./is-text.js";
9
9
  import { isEmpty } from "./is-empty.js";
10
10
  import { secureJson, secureObject } from "./secure-json.js";
11
- const _NAME = '$$leyyo.config';
11
+ const _NAME = "$$leyyo.config";
12
12
  export const leyyoConfig = getRootStorage(_NAME, {});
13
- /**
14
- * Load config from `.leyyo.yaml` file
15
- *
16
- * `OBJECT` postfixes:
17
- * - !: only override (`don't merge`)
18
- * - ?: only merge (`don't override`)
19
- * - <empty>: only set if key is absent
20
- *
21
- * `ARRAY` postfixes:
22
- * - !: only override (`don't merge`)
23
- * - ?: only merge (`don't override`)
24
- * - <empty>: only set if key is absent
25
- *
26
- * Generics:
27
- * - `C`- config model
28
- *
29
- * @param {string} url
30
- * @return {LeyyoConfig}
31
- * */
32
13
  export function loadConfig(url) {
33
14
  try {
34
15
  const __dirname = dirname(dirname(fileURLToPath(url)));
35
- const yamlPath = path.normalize(__dirname + '/.leyyo.yaml');
16
+ const yamlPath = path.normalize(__dirname + "/.leyyo.yaml");
36
17
  if (fs.existsSync(yamlPath)) {
37
- const input = fs.readFileSync(yamlPath, 'utf8');
18
+ const input = fs.readFileSync(yamlPath, "utf8");
38
19
  const data = yaml.load(input);
39
20
  if (isObj(data)) {
40
21
  for (const [k, v] of Object.entries(data)) {
@@ -49,45 +30,33 @@ export function loadConfig(url) {
49
30
  return undefined;
50
31
  }
51
32
  }
52
- /**
53
- * Get key behaviour
54
- * @param {string} keyFull - key
55
- * @return {Array} - tuple as `[behaviour, key]`
56
- * */
57
33
  function _behaviour(keyFull) {
58
34
  if (!isText(keyFull)) {
59
35
  return [undefined, undefined];
60
36
  }
61
- if (keyFull.endsWith('!')) {
37
+ if (keyFull.endsWith("!")) {
62
38
  keyFull = keyFull.substring(keyFull.length - 1).trim();
63
39
  if (!isText(keyFull)) {
64
40
  return [undefined, undefined];
65
41
  }
66
- return ['override', keyFull];
42
+ return ["override", keyFull];
67
43
  }
68
- else if (keyFull.endsWith('?')) {
44
+ else if (keyFull.endsWith("?")) {
69
45
  keyFull = keyFull.substring(keyFull.length - 1).trim();
70
46
  if (!isText(keyFull)) {
71
47
  return [undefined, undefined];
72
48
  }
73
- return ['merge', keyFull];
49
+ return ["merge", keyFull];
74
50
  }
75
51
  return [undefined, keyFull];
76
52
  }
77
- /**
78
- * Merge array
79
- *
80
- * @param {Array} source
81
- * @param {string} key
82
- * @param {Array} value
83
- * */
84
53
  function _array(source, key, value) {
85
54
  value.forEach((item, index) => {
86
55
  if (isEmpty(item)) {
87
56
  console.warn(`[leyyoConfig] value empty at (${key}#${index})`);
88
57
  return;
89
58
  }
90
- const clonedSource = source.map(item => JSON.stringify(item));
59
+ const clonedSource = source.map((item) => JSON.stringify(item));
91
60
  switch (typeof item) {
92
61
  case "string":
93
62
  case "number":
@@ -110,13 +79,6 @@ function _array(source, key, value) {
110
79
  }
111
80
  });
112
81
  }
113
- /**
114
- * Merge object
115
- *
116
- * @param {object} source
117
- * @param {string} keyFull - key
118
- * @param {any} value
119
- * */
120
82
  function _object(source, keyFull, value) {
121
83
  if (isEmpty(value)) {
122
84
  return;
@@ -129,7 +91,6 @@ function _object(source, keyFull, value) {
129
91
  if (!source) {
130
92
  source = {};
131
93
  }
132
- // old is empty
133
94
  if (isEmpty(source[key])) {
134
95
  switch (typeof value) {
135
96
  case "string":
@@ -157,7 +118,7 @@ function _object(source, keyFull, value) {
157
118
  case "override":
158
119
  source[key] = value;
159
120
  break;
160
- default: // merge
121
+ default:
161
122
  if (isEmpty(source[key])) {
162
123
  source[key] = value;
163
124
  }
@@ -165,9 +126,7 @@ function _object(source, keyFull, value) {
165
126
  }
166
127
  break;
167
128
  case "object":
168
- // new is an array
169
129
  if (Array.isArray(value)) {
170
- // old is an array (BOTH)
171
130
  if (Array.isArray(source[key])) {
172
131
  switch (behaviour) {
173
132
  case "override":
@@ -177,44 +136,35 @@ function _object(source, keyFull, value) {
177
136
  _array(source[key], key, value);
178
137
  break;
179
138
  default:
180
- // old exists, ignore
181
139
  break;
182
140
  }
183
141
  }
184
- // CONFLICT: old is not array
185
142
  else {
186
143
  switch (behaviour) {
187
144
  case "override":
188
145
  source[key] = secureObject(value);
189
146
  break;
190
147
  case "merge":
191
- // old is different, conflict
192
148
  console.warn(`[leyyoConfig] type is conflicted at (${key})`);
193
149
  break;
194
150
  default:
195
- // old exists, ignore
196
151
  break;
197
152
  }
198
153
  }
199
154
  }
200
- // new is an object
201
155
  else {
202
- // CONFLICT: old is not object
203
156
  if (Array.isArray(source[key])) {
204
157
  switch (behaviour) {
205
158
  case "override":
206
159
  source[key] = value;
207
160
  break;
208
161
  case "merge":
209
- // old is different, conflict
210
162
  console.warn(`[leyyoConfig] type is conflicted at (${key})`);
211
163
  break;
212
164
  default:
213
- // old exists, ignore
214
165
  break;
215
166
  }
216
167
  }
217
- // old is an object (BOTH)
218
168
  else {
219
169
  switch (behaviour) {
220
170
  case "override":
@@ -226,7 +176,6 @@ function _object(source, keyFull, value) {
226
176
  }
227
177
  break;
228
178
  default:
229
- // old exists, ignore
230
179
  break;
231
180
  }
232
181
  }
@@ -3,13 +3,13 @@ export function onFqnSet(target, callback) {
3
3
  if (!target) {
4
4
  return false;
5
5
  }
6
- if (typeof callback !== 'function') {
6
+ if (typeof callback !== "function") {
7
7
  return false;
8
8
  }
9
- if (typeof target === 'function') { // function, class
9
+ if (typeof target === "function") {
10
10
  return _item(target, callback);
11
11
  }
12
- else if (typeof target === 'object') {
12
+ else if (typeof target === "object") {
13
13
  if (Array.isArray(target)) {
14
14
  if (target[KEY_LITERAL_NAME]) {
15
15
  return _item(target, callback);
@@ -1,8 +1,2 @@
1
1
  import { OneOrMore } from "../base/index.js";
2
- /**
3
- * Return array value from one or more type
4
- *
5
- * @param {OneOrMore} value - it can be one value or array value
6
- * @return {Array}
7
- * */
8
2
  export declare function oneOrMore<T = unknown>(value: OneOrMore<T>): Array<T> | undefined;
@@ -1,10 +1,3 @@
1
- // noinspection JSUnusedGlobalSymbols
2
- /**
3
- * Return array value from one or more type
4
- *
5
- * @param {OneOrMore} value - it can be one value or array value
6
- * @return {Array}
7
- * */
8
1
  export function oneOrMore(value) {
9
2
  if (Array.isArray(value)) {
10
3
  return value;
@@ -1,10 +1,2 @@
1
1
  import { Opt } from "./index.types.js";
2
- /**
3
- * Add key=value into options
4
- *
5
- * @param {Opt} options - source options
6
- * @param {string} key - key
7
- * @param {any} value - value
8
- * @return {Opt} - added options
9
- * */
10
2
  export declare function optAdd<O extends Opt = Opt>(options: O | Opt, key: keyof O | string, value: unknown): O;
@@ -1,19 +1,11 @@
1
1
  import { optField } from "./opt-field.js";
2
2
  import { isObj } from "./is-obj.js";
3
- /**
4
- * Add key=value into options
5
- *
6
- * @param {Opt} options - source options
7
- * @param {string} key - key
8
- * @param {any} value - value
9
- * @return {Opt} - added options
10
- * */
11
3
  export function optAdd(options, key, value) {
12
4
  const o = (isObj(options) ? options : {});
13
- if (value === undefined || typeof key !== 'string') {
5
+ if (value === undefined || typeof key !== "string") {
14
6
  return o;
15
7
  }
16
- if (key === 'field') {
8
+ if (key === "field") {
17
9
  return optField(o, value);
18
10
  }
19
11
  if (o[key] === undefined) {
@@ -1,9 +1,2 @@
1
1
  import { Opt } from "./index.types.js";
2
- /**
3
- * Merge two options
4
- *
5
- * @param {Opt} options - source options
6
- * @param {Opt} appended - appended options
7
- * @return {Opt} - merged options
8
- * */
9
2
  export declare function optAppend<O extends Opt = Opt>(options: O | Opt, appended: O | Opt): O;
@@ -1,12 +1,5 @@
1
1
  import { isObj } from "./is-obj.js";
2
2
  import { optAdd } from "./opt-add.js";
3
- /**
4
- * Merge two options
5
- *
6
- * @param {Opt} options - source options
7
- * @param {Opt} appended - appended options
8
- * @return {Opt} - merged options
9
- * */
10
3
  export function optAppend(options, appended) {
11
4
  const o = (isObj(options) ? options : {});
12
5
  if (!isObj(appended)) {
@@ -1,8 +1,2 @@
1
1
  import { Opt, OptFn } from "./index.types.js";
2
- /**
3
- * Check option, if it's invalid, create empty options
4
- *
5
- * @param {(Opt|OptFn)} options - options or options callback
6
- * @return {Opt} - checked options
7
- * */
8
2
  export declare function optCheck<O extends Opt = Opt>(options: O | OptFn<O> | Opt): O;
@@ -1,18 +1,11 @@
1
- // noinspection JSUnusedGlobalSymbols
2
1
  import { $$get_leyyo_fn } from "./leyyo-fn.js";
3
2
  import { isObj } from "./is-obj.js";
4
3
  import { FQN } from "../internal.js";
5
4
  let _leyyo;
6
5
  const where = `${FQN}.optCheck`;
7
- /**
8
- * Check option, if it's invalid, create empty options
9
- *
10
- * @param {(Opt|OptFn)} options - options or options callback
11
- * @return {Opt} - checked options
12
- * */
13
6
  export function optCheck(options) {
14
7
  let o = options;
15
- if (typeof options === 'function') {
8
+ if (typeof options === "function") {
16
9
  try {
17
10
  o = options();
18
11
  }
@@ -21,7 +14,7 @@ export function optCheck(options) {
21
14
  if (!_leyyo) {
22
15
  _leyyo = $$get_leyyo_fn();
23
16
  }
24
- new _leyyo.developerError('Raised callback run', 'optCheck#01', where).log(e);
17
+ new _leyyo.developerError("Raised callback run", "optCheck#01", where).log(e);
25
18
  }
26
19
  }
27
20
  else if (!isObj(options)) {
@@ -1,8 +1,2 @@
1
1
  import { Opt } from "./index.types.js";
2
- /**
3
- * Clone existing option
4
- *
5
- * @param {Opt} options - source options
6
- * @return {Opt} - cloned options
7
- * */
8
2
  export declare function optClone<O extends Opt = Opt>(options: O | Opt): O;
@@ -1,12 +1,5 @@
1
- // noinspection JSUnusedGlobalSymbols
2
1
  import { isObj } from "./is-obj.js";
3
2
  import { secureClone } from "./secure-clone.js";
4
- /**
5
- * Clone existing option
6
- *
7
- * @param {Opt} options - source options
8
- * @return {Opt} - cloned options
9
- * */
10
3
  export function optClone(options) {
11
4
  return (isObj(options) ? secureClone(options) : {});
12
5
  }
@@ -1,11 +1,3 @@
1
1
  import { Opt } from "./index.types.js";
2
2
  import { KeyValue } from "../base/index.js";
3
- /**
4
- * Add field into options
5
- * Note: field could not be multiple in option
6
- *
7
- * @param {Opt} options - source options
8
- * @param {KeyValue} field - value
9
- * @return {Opt} - added options
10
- * */
11
3
  export declare function optField<O extends Opt = Opt>(options: O | Opt, field: KeyValue): O;
@@ -1,31 +1,23 @@
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
- * */
10
2
  export function optField(options, field) {
11
3
  const o = (isObj(options) ? options : {});
12
4
  const t = typeof field;
13
- if (!['string', 'number'].includes(t)) {
5
+ if (!["string", "number"].includes(t)) {
14
6
  return o;
15
7
  }
16
8
  if (o.field !== undefined) {
17
- if (typeof o.field !== 'string') {
18
- o.field = '';
9
+ if (typeof o.field !== "string") {
10
+ o.field = "";
19
11
  }
20
12
  }
21
13
  else {
22
- o.field = '';
14
+ o.field = "";
23
15
  }
24
16
  if (!o.field) {
25
- o.field = (t === 'string') ? field : `$.[${field}]`;
17
+ o.field = t === "string" ? field : `$.[${field}]`;
26
18
  }
27
19
  else {
28
- o.field += (t === 'string') ? `.${field}` : `[${field}]`;
20
+ o.field += t === "string" ? `.${field}` : `[${field}]`;
29
21
  }
30
22
  return o;
31
23
  }
@@ -1,8 +1,2 @@
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
- * */
8
2
  export declare function optFn<O extends Opt = Opt>(options: O | Opt): O;
@@ -1,11 +1,4 @@
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
- * */
9
2
  export function optFn(options) {
10
3
  return (isObj(options) ? options : {});
11
4
  }
@@ -1,6 +1 @@
1
- /**
2
- * Generate random test no
3
- *
4
- * @return {string}
5
- * */
6
1
  export declare function randomTestNo(): string;
@@ -1,8 +1,3 @@
1
- /**
2
- * Generate random test no
3
- *
4
- * @return {string}
5
- * */
6
1
  export function randomTestNo() {
7
2
  return (Math.floor(Math.random() * 999) + 100).toString(10);
8
3
  }