@leyyo/common 1.3.19 → 1.3.21

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 (127) 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/index.d.ts +1 -0
  66. package/dist/function/index.js +1 -0
  67. package/dist/function/is-class.d.ts +6 -0
  68. package/dist/function/is-class.js +18 -0
  69. package/dist/function/is-empty.d.ts +11 -0
  70. package/dist/function/is-empty.js +11 -0
  71. package/dist/function/is-filled-arr.d.ts +9 -0
  72. package/dist/function/is-filled-arr.js +9 -0
  73. package/dist/function/is-filled-obj.d.ts +9 -0
  74. package/dist/function/is-filled-obj.js +9 -0
  75. package/dist/function/is-obj.d.ts +8 -0
  76. package/dist/function/is-obj.js +8 -0
  77. package/dist/function/is-test.d.ts +8 -0
  78. package/dist/function/is-test.js +14 -0
  79. package/dist/function/is-text.d.ts +10 -0
  80. package/dist/function/is-text.js +10 -0
  81. package/dist/function/jitter-interval.d.ts +9 -0
  82. package/dist/function/jitter-interval.js +16 -0
  83. package/dist/function/load-config.d.ts +19 -0
  84. package/dist/function/load-config.js +52 -1
  85. package/dist/function/on-fqn-set.js +1 -0
  86. package/dist/function/one-or-more.d.ts +6 -0
  87. package/dist/function/one-or-more.js +7 -0
  88. package/dist/function/opt-add.d.ts +8 -0
  89. package/dist/function/opt-add.js +8 -0
  90. package/dist/function/opt-append.d.ts +7 -0
  91. package/dist/function/opt-append.js +7 -0
  92. package/dist/function/opt-check.d.ts +6 -0
  93. package/dist/function/opt-check.js +7 -0
  94. package/dist/function/opt-clone.d.ts +6 -0
  95. package/dist/function/opt-clone.js +7 -0
  96. package/dist/function/opt-field.d.ts +8 -0
  97. package/dist/function/opt-field.js +8 -0
  98. package/dist/function/opt-fn.d.ts +6 -0
  99. package/dist/function/opt-fn.js +7 -0
  100. package/dist/function/random-test-no.d.ts +5 -0
  101. package/dist/function/random-test-no.js +5 -0
  102. package/dist/function/remove-fqn.d.ts +8 -0
  103. package/dist/function/remove-fqn.js +11 -1
  104. package/dist/function/run-exporter.d.ts +5 -0
  105. package/dist/function/run-exporter.js +14 -0
  106. package/dist/function/secure-json.d.ts +35 -0
  107. package/dist/function/secure-json.js +44 -0
  108. package/dist/function/set-anonymous-fqn.js +2 -0
  109. package/dist/function/set-fqn.d.ts +7 -0
  110. package/dist/function/set-fqn.js +8 -0
  111. package/dist/function/set-prop.d.ts +24 -0
  112. package/dist/function/set-prop.js +24 -0
  113. package/dist/function/stamp-loader.d.ts +6 -0
  114. package/dist/function/stamp-loader.js +6 -0
  115. package/dist/function/test-case.d.ts +7 -0
  116. package/dist/function/test-case.js +7 -0
  117. package/dist/function/test-name.d.ts +7 -0
  118. package/dist/function/test-name.js +7 -0
  119. package/dist/function/times.d.ts +6 -0
  120. package/dist/function/times.js +12 -0
  121. package/dist/function/trigger-fqn.js +1 -0
  122. package/dist/index.foretell.js +3 -0
  123. package/dist/index.js +1 -0
  124. package/dist/index.loader.js +8 -1
  125. package/dist/sys/leyyo-storage.d.ts +7 -0
  126. package/dist/sys/leyyo-storage.js +23 -0
  127. package/package.json +1 -1
@@ -1,8 +1,21 @@
1
1
  import { LeyyoError } from "./leyyo.error.js";
2
2
  import { Opt } from "../function/index.js";
3
+ /**
4
+ * Http error
5
+ * */
3
6
  export declare class HttpError extends LeyyoError {
4
7
  status: number;
8
+ /**
9
+ * @param {string} message - error message
10
+ * */
5
11
  constructor(message: string);
12
+ /**
13
+ * @param {Opt} params - error parameters
14
+ * */
6
15
  constructor(params: Opt);
16
+ /**
17
+ * @param {string} message - error message
18
+ * @param {Opt} params - error parameters
19
+ * */
7
20
  constructor(message: string, params: Opt);
8
21
  }
@@ -1,7 +1,14 @@
1
1
  import { LeyyoError } from "./leyyo.error.js";
2
2
  import { KEY_ERROR_DEFAULT_MESSAGE, KEY_ERROR_HTTP_STATUS } from "../const/index.js";
3
+ /**
4
+ * Http error
5
+ * */
3
6
  export class HttpError extends LeyyoError {
4
7
  status;
8
+ /**
9
+ * @param {(string|Opt)} p1 - error message or error parameters
10
+ * @param {Opt?} p2 - error parameters
11
+ * */
5
12
  constructor(p1, p2) {
6
13
  super(p1, p2);
7
14
  const clazz = this.constructor;
@@ -1,46 +1,195 @@
1
1
  import { ClassLike, Obj, OneOrMore, ShiftMain, ShiftSecure } from "../base/index.js";
2
2
  import { Opt } from "../function/index.js";
3
3
  import { Logger } from "../common/index.js";
4
+ /**
5
+ * {@link LeyyoError}
6
+ * */
4
7
  export interface LeyyoErrorCtor {
8
+ /**
9
+ * Create without any parameter
10
+ * */
5
11
  new (): LeyyoErrorLike;
12
+ /**
13
+ * Create with only message
14
+ *
15
+ * @param {string} message - error message
16
+ * */
6
17
  new (message: string): LeyyoErrorLike;
18
+ /**
19
+ * Create with only params
20
+ *
21
+ * @param {Opt} params - error parameters
22
+ * */
7
23
  new (params: Opt): LeyyoErrorLike;
24
+ /**
25
+ * Create with message and params
26
+ *
27
+ * @param {string} message - error message
28
+ * @param {Opt} params - error parameters
29
+ * */
8
30
  new (message: string, params: Opt): LeyyoErrorLike;
9
31
  }
32
+ /**
33
+ * {@link DeveloperError}
34
+ * */
10
35
  export interface DeveloperErrorCtor {
36
+ /**
37
+ * Create developer error
38
+ *
39
+ * @param {string} message - error message
40
+ * @param {string} issue - test case
41
+ * @param {string} where - where
42
+ * */
11
43
  new (message: string, issue?: string, where?: string): DeveloperErrorLike;
12
44
  }
13
45
  export type LeyyoErrorTag = "printed" | "sent";
46
+ /**
47
+ * Stack line
48
+ * */
14
49
  export interface ErrorStackLine {
50
+ /**
51
+ * File of error
52
+ * */
15
53
  file: string;
54
+ /**
55
+ * Method of error
56
+ * */
16
57
  method?: string;
58
+ /**
59
+ * Position of error
60
+ * */
17
61
  pos?: string;
18
62
  }
19
63
  export interface DeveloperErrorLike extends Error {
64
+ /**
65
+ * Formatted stack trace
66
+ * */
20
67
  stackTrace?: Array<ErrorStackLine>;
68
+ /**
69
+ * Log error
70
+ *
71
+ * @param {Error?} err - optional caused error
72
+ * */
21
73
  log(err?: Error): void;
22
74
  }
23
75
  export interface LeyyoErrorLike extends Error, ShiftSecure<LeyyoErrorSecure> {
76
+ /**
77
+ * Parameters for error
78
+ * */
24
79
  params?: Opt;
80
+ /**
81
+ * Formatted stack trace
82
+ * */
25
83
  stackTrace?: Array<ErrorStackLine>;
84
+ /**
85
+ * Caused error
86
+ * */
26
87
  causedBy?: OneOrMore<Error>;
88
+ /**
89
+ * Bind caused error
90
+ *
91
+ * @param {Error} err
92
+ * @return {LeyyoErrorLike}
93
+ * */
27
94
  causes(err: Error): this;
95
+ /**
96
+ * Bind holder class name
97
+ *
98
+ * @param {string} name - name of class
99
+ * @param {string?} fqn - fqn
100
+ * @return {LeyyoErrorLike}
101
+ * */
28
102
  where(name: string, fqn?: string): this;
103
+ /**
104
+ * Bind holder instance
105
+ *
106
+ * @param {Obj} instance - this instance
107
+ * @return {LeyyoErrorLike}
108
+ * */
29
109
  where(instance: Obj): this;
110
+ /**
111
+ * Bind holder instance
112
+ *
113
+ * @param {function} clazz - class
114
+ * @return {LeyyoErrorLike}
115
+ * */
30
116
  where(clazz: ClassLike): this;
117
+ /**
118
+ * Alias for {@link logError}
119
+ *
120
+ * @param {Logger?} logger - optional bound logger
121
+ * */
31
122
  log(logger?: Logger): void;
123
+ /**
124
+ * Log as `fatal`
125
+ *
126
+ * @param {Logger?} logger - optional bound logger
127
+ * */
32
128
  logFatal(logger?: Logger): void;
129
+ /**
130
+ * Log as `error`
131
+ *
132
+ * @param {Logger?} logger - optional bound logger
133
+ * */
33
134
  logError(logger?: Logger): void;
135
+ /**
136
+ * Log as `warn`
137
+ *
138
+ * @param {Logger?} logger - optional bound logger
139
+ * */
34
140
  logWarn(logger?: Logger): void;
141
+ /**
142
+ * Log as `debug`
143
+ *
144
+ * @param {Logger?} logger - optional bound logger
145
+ * */
35
146
  logDebug(logger?: Logger): void;
147
+ /**
148
+ * Log as `info`
149
+ *
150
+ * @param {Logger?} logger - optional bound logger
151
+ * */
36
152
  logInfo(logger?: Logger): void;
153
+ /**
154
+ * Log as `trace`
155
+ *
156
+ * @param {Logger?} logger - optional bound logger
157
+ * */
37
158
  logTrace(logger?: Logger): void;
38
159
  }
39
160
  export interface LeyyoErrorSecure extends ShiftMain<LeyyoErrorLike> {
40
161
  get $where(): string;
162
+ /**
163
+ * List flags
164
+ *
165
+ * @return {Array<string>} - flags
166
+ * */
41
167
  $list<T extends LeyyoErrorTag | string = LeyyoErrorTag | string>(): Array<T>;
168
+ /**
169
+ * Append a flag
170
+ *
171
+ * @param {string} key - flag key
172
+ * @return {boolean} - is it appended?
173
+ * */
42
174
  $append<T extends LeyyoErrorTag | string = LeyyoErrorTag | string>(key: T): boolean;
175
+ /**
176
+ * Remove a flag
177
+ *
178
+ * @param {string} key - flag key
179
+ * @return {boolean} - is it removed?
180
+ * */
43
181
  $remove<T extends LeyyoErrorTag | string = LeyyoErrorTag | string>(key: T): boolean;
182
+ /**
183
+ * Has a flag?
184
+ *
185
+ * @param {string} key - flag key
186
+ * @return {boolean} - has it?
187
+ * */
44
188
  $has<T extends LeyyoErrorTag | string = LeyyoErrorTag | string>(key: T): boolean;
189
+ /**
190
+ * Copy source properties into target parameters
191
+ *
192
+ * @param {Error} source - source error
193
+ * */
45
194
  $copyProperties(source: Error): void;
46
195
  }
@@ -1,3 +1,6 @@
1
1
  import { LeyyoError } from "./leyyo.error.js";
2
+ /**
3
+ * Invalid value error
4
+ * */
2
5
  export declare class InvalidValueError extends LeyyoError {
3
6
  }
@@ -1,5 +1,8 @@
1
1
  import { LeyyoError } from "./leyyo.error.js";
2
2
  import { KEY_ERROR_DEFAULT_MESSAGE } from "../const/index.js";
3
+ /**
4
+ * Invalid value error
5
+ * */
3
6
  export class InvalidValueError extends LeyyoError {
4
7
  static {
5
8
  this[KEY_ERROR_DEFAULT_MESSAGE] = "Invalid value";
@@ -4,31 +4,64 @@ import { ClassLike, LeyyoLike, Obj, OneOrMore } from "../base/index.js";
4
4
  import { Opt } from "../function/index.js";
5
5
  import { KEY_ERROR_FLAGS, KEY_LEYYO_SECURE } from "../const/index.js";
6
6
  type T2 = LeyyoErrorTag;
7
+ /**
8
+ * Leyyo base error
9
+ * */
7
10
  export declare class LeyyoError extends Error implements LeyyoErrorLike, LeyyoErrorSecure {
11
+ /**
12
+ * Error flags
13
+ * */
8
14
  private [KEY_ERROR_FLAGS];
15
+ /**
16
+ * Error parameters
17
+ * */
9
18
  params?: Opt;
19
+ /**
20
+ * Caused by error
21
+ * */
10
22
  causedBy?: OneOrMore<Error>;
23
+ /**
24
+ * Stack trace
25
+ * */
11
26
  stackTrace?: Array<ErrorStackLine>;
27
+ /**
28
+ * */
12
29
  constructor();
30
+ /**
31
+ * @param {string} message - error message
32
+ * */
13
33
  constructor(message: string);
34
+ /**
35
+ * @param {Opt} params - error parameters
36
+ * */
14
37
  constructor(params: Opt);
38
+ /**
39
+ * @param {string} message - error message
40
+ * @param {Opt} params - error parameters
41
+ * */
15
42
  constructor(message: string, params: Opt);
16
43
  static [KEY_LEYYO_SECURE](leyyo: LeyyoLike): void;
17
44
  causes(err: Error): this;
18
45
  where(p1: ClassLike | Obj | string, fqn?: string): this;
19
46
  private _log;
47
+ /** @inheritDoc */
20
48
  log(logger?: Logger): void;
21
49
  logFatal(logger?: Logger): void;
22
50
  logError(logger?: Logger): void;
51
+ /** @inheritDoc */
23
52
  logWarn(logger?: Logger): void;
53
+ /** @inheritDoc */
24
54
  logDebug(logger?: Logger): void;
55
+ /** @inheritDoc */
25
56
  logInfo(logger?: Logger): void;
57
+ /** @inheritDoc */
26
58
  logTrace(logger?: Logger): void;
27
59
  get $where(): string;
28
60
  $list<T extends T2 | string = T2 | string>(): Array<T>;
29
61
  $append<T extends T2 | string = T2 | string>(key: T): boolean;
30
62
  $remove<T extends LeyyoErrorTag | string = LeyyoErrorTag | string>(key: T): boolean;
31
63
  $has<T extends LeyyoErrorTag | string = LeyyoErrorTag | string>(key: T): boolean;
64
+ /** @inheritDoc */
32
65
  $copyProperties(source: Error): void;
33
66
  get $back(): LeyyoErrorLike;
34
67
  get $secure(): LeyyoErrorSecure;
@@ -1,13 +1,34 @@
1
1
  import { getFqn, getSymbol, isFilledObj, isObj, optAdd, optAppend, setSymbol, } from "../function/index.js";
2
2
  import { KEY_ERROR_FLAGS, KEY_ERROR_WHERE, KEY_LEYYO_SECURE, VAL_ERROR_UNKNOWN_MESSAGE, } from "../const/index.js";
3
3
  let _leyyo;
4
+ // region property
4
5
  const _errorField = ["name", "message", "stack"];
5
6
  const _leyyoErrorFields = [..._errorField, "params", "causedBy", "stackTrace"];
7
+ // endregion property
8
+ /**
9
+ * Leyyo base error
10
+ * */
6
11
  export class LeyyoError extends Error {
12
+ /**
13
+ * Error flags
14
+ * */
7
15
  [KEY_ERROR_FLAGS];
16
+ /**
17
+ * Error parameters
18
+ * */
8
19
  params;
20
+ /**
21
+ * Caused by error
22
+ * */
9
23
  causedBy;
24
+ /**
25
+ * Stack trace
26
+ * */
10
27
  stackTrace;
28
+ /**
29
+ * @param {(string|Opt)?} p1 - error message or error parameters
30
+ * @param {Opt?} p2 - error parameters
31
+ * */
11
32
  constructor(p1, p2) {
12
33
  let message;
13
34
  let params;
@@ -38,6 +59,7 @@ export class LeyyoError extends Error {
38
59
  _leyyo = leyyo;
39
60
  }
40
61
  }
62
+ // region bind
41
63
  causes(err) {
42
64
  if (err instanceof Error) {
43
65
  if (!this.causedBy) {
@@ -74,6 +96,8 @@ export class LeyyoError extends Error {
74
96
  }
75
97
  return this;
76
98
  }
99
+ // endregion bind
100
+ // region log
77
101
  _log(level, logger) {
78
102
  if (logger) {
79
103
  logger[level](this);
@@ -82,6 +106,7 @@ export class LeyyoError extends Error {
82
106
  _leyyo.logCommon.emitLog(level, undefined, this, {});
83
107
  }
84
108
  }
109
+ /** @inheritDoc */
85
110
  log(logger) {
86
111
  this._log("error", logger);
87
112
  }
@@ -91,18 +116,24 @@ export class LeyyoError extends Error {
91
116
  logError(logger) {
92
117
  this._log("error", logger);
93
118
  }
119
+ /** @inheritDoc */
94
120
  logWarn(logger) {
95
121
  this._log("warn", logger);
96
122
  }
123
+ /** @inheritDoc */
97
124
  logDebug(logger) {
98
125
  this._log("debug", logger);
99
126
  }
127
+ /** @inheritDoc */
100
128
  logInfo(logger) {
101
129
  this._log("info", logger);
102
130
  }
131
+ /** @inheritDoc */
103
132
  logTrace(logger) {
104
133
  this._log("trace", logger);
105
134
  }
135
+ // endregion log
136
+ // region flags
106
137
  get $where() {
107
138
  return getSymbol(this, KEY_ERROR_WHERE);
108
139
  }
@@ -141,6 +172,9 @@ export class LeyyoError extends Error {
141
172
  }
142
173
  return this[KEY_ERROR_FLAGS].has(key);
143
174
  }
175
+ // endregion flags
176
+ // region methods
177
+ /** @inheritDoc */
144
178
  $copyProperties(source) {
145
179
  if (!(source instanceof Error)) {
146
180
  return;
@@ -170,6 +204,8 @@ export class LeyyoError extends Error {
170
204
  }
171
205
  }
172
206
  }
207
+ // endregion methods
208
+ // region modes
173
209
  get $back() {
174
210
  return this;
175
211
  }
@@ -1,7 +1,13 @@
1
1
  import { LeyyoErrorLike } from "./index.types.js";
2
2
  import { LeyyoError } from "./leyyo.error.js";
3
+ /**
4
+ * Multiple error which manages multiple errors
5
+ * */
3
6
  export declare class MultipleError extends LeyyoError {
4
7
  causedBy: Array<LeyyoErrorLike>;
8
+ /**
9
+ * @param {...Error[]} errors
10
+ * */
5
11
  constructor(...errors: Array<Error>);
6
12
  push(...errors: Array<Error>): this;
7
13
  }
@@ -1,6 +1,13 @@
1
1
  import { LeyyoError } from "./leyyo.error.js";
2
2
  import { CausedError } from "./caused.error.js";
3
+ // noinspection Annotator
4
+ /**
5
+ * Multiple error which manages multiple errors
6
+ * */
3
7
  export class MultipleError extends LeyyoError {
8
+ /**
9
+ * @param {...Error[]} errors
10
+ * */
4
11
  constructor(...errors) {
5
12
  const first = errors.length > 0 ? errors[0] : undefined;
6
13
  super(first?.message ?? "Multiple error", {});
@@ -1,2 +1,8 @@
1
1
  import { LoaderItem, LoaderLike } from "./index.types.js";
2
+ /**
3
+ * Set name of a loader
4
+ *
5
+ * @param {string} fqn - component name
6
+ * @param {...LoaderItem[]} items - items
7
+ * */
2
8
  export declare function defineLoader(fqn: string, ...items: Array<LoaderItem>): LoaderLike;
@@ -1,6 +1,12 @@
1
1
  import { isFilledArr } from "./is-filled-arr.js";
2
2
  import { isText } from "./is-text.js";
3
3
  import { KEY_LOADER_NAME } from "../const/index.js";
4
+ /**
5
+ * Set name of a loader
6
+ *
7
+ * @param {string} fqn - component name
8
+ * @param {...LoaderItem[]} items - items
9
+ * */
4
10
  export function defineLoader(fqn, ...items) {
5
11
  if (!isText(fqn)) {
6
12
  fqn = `leyyo/@${Date.now()}`;
@@ -1 +1,9 @@
1
+ /**
2
+ * Delay or sleep n msec
3
+ *
4
+ * @param {number} waiting - waiting as milliseconds
5
+ * @param {any} response - response value
6
+ * @return {any}
7
+ * @async
8
+ * */
1
9
  export declare function delay<R = undefined>(waiting?: number, response?: R): Promise<R>;
@@ -1,3 +1,12 @@
1
+ // noinspection JSUnusedGlobalSymbols
2
+ /**
3
+ * Delay or sleep n msec
4
+ *
5
+ * @param {number} waiting - waiting as milliseconds
6
+ * @param {any} response - response value
7
+ * @return {any}
8
+ * @async
9
+ * */
1
10
  export function delay(waiting, response) {
2
11
  if (typeof waiting !== "number" || waiting < 10) {
3
12
  waiting = Math.round(Math.random() * 1_000);
@@ -1,3 +1,24 @@
1
+ /**
2
+ * Delete target property
3
+ *
4
+ * @param {any} target - target
5
+ * @param {string} key - key
6
+ * @return {boolean} - is deleted?
7
+ * */
1
8
  export declare function deleteKey(target: unknown, key: string): boolean;
9
+ /**
10
+ * Delete target hidden property
11
+ *
12
+ * @param {any} target - target
13
+ * @param {symbol} key - hidden key
14
+ * @return {boolean} - is deleted?
15
+ * */
2
16
  export declare function deleteSymbol(target: unknown, key: symbol): boolean;
17
+ /**
18
+ * Delete target property
19
+ *
20
+ * @param {any} target - target
21
+ * @param {(symbol|string)} key - key
22
+ * @return {boolean} - is deleted?
23
+ * */
3
24
  export declare function deleteProp(target: unknown, key: symbol | string): boolean;
@@ -3,18 +3,39 @@ 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
+ * Delete target property
8
+ *
9
+ * @param {any} target - target
10
+ * @param {string} key - key
11
+ * @return {boolean} - is deleted?
12
+ * */
6
13
  export function deleteKey(target, key) {
7
14
  if (typeof key !== "string") {
8
15
  return false;
9
16
  }
10
17
  return deleteProp(target, key);
11
18
  }
19
+ /**
20
+ * Delete target hidden property
21
+ *
22
+ * @param {any} target - target
23
+ * @param {symbol} key - hidden key
24
+ * @return {boolean} - is deleted?
25
+ * */
12
26
  export function deleteSymbol(target, key) {
13
27
  if (typeof key !== "symbol") {
14
28
  return false;
15
29
  }
16
30
  return deleteProp(target, key);
17
31
  }
32
+ /**
33
+ * Delete target property
34
+ *
35
+ * @param {any} target - target
36
+ * @param {(symbol|string)} key - key
37
+ * @return {boolean} - is deleted?
38
+ * */
18
39
  export function deleteProp(target, key) {
19
40
  if (!["symbol", "string"].includes(typeof key)) {
20
41
  return false;
@@ -27,6 +48,7 @@ export function deleteProp(target, key) {
27
48
  return true;
28
49
  }
29
50
  catch (e) {
51
+ // nothing
30
52
  }
31
53
  try {
32
54
  Object.defineProperty(target, key, {
@@ -1 +1,7 @@
1
+ /**
2
+ * Empty function, it can be more useful sometimes
3
+ *
4
+ * @param {Arr} _args - insignificant parameters
5
+ * @return {any}
6
+ * */
1
7
  export declare function emptyFn<R = unknown>(..._args: Array<unknown>): R | void;
@@ -1 +1,8 @@
1
+ // noinspection JSUnusedGlobalSymbols
2
+ /**
3
+ * Empty function, it can be more useful sometimes
4
+ *
5
+ * @param {Arr} _args - insignificant parameters
6
+ * @return {any}
7
+ * */
1
8
  export function emptyFn(..._args) { }
@@ -1,2 +1,8 @@
1
1
  import { ExtendedType } from "../base/index.js";
2
+ /**
3
+ * Get extended type of value
4
+ *
5
+ * @param {any} value - given value
6
+ * @return {ExtendedType}
7
+ * */
2
8
  export declare function extendedType(value: unknown): ExtendedType;
@@ -1,6 +1,13 @@
1
1
  import { List } from "../class/list.js";
2
2
  import { KEY_ENUM_NAME, KEY_LITERAL_NAME } from "../const/index.js";
3
3
  import { isClass } from "./is-class.js";
4
+ // noinspection JSUnusedGlobalSymbols
5
+ /**
6
+ * Get extended type of value
7
+ *
8
+ * @param {any} value - given value
9
+ * @return {ExtendedType}
10
+ * */
4
11
  export function extendedType(value) {
5
12
  let trimmed;
6
13
  switch (typeof value) {
@@ -1,2 +1,8 @@
1
1
  import { FqnTarget } from "./index.types.js";
2
+ /**
3
+ * Get fqn name
4
+ *
5
+ * @param {FqnTarget} target - target (function, class, instance, enum, literal)
6
+ * @return {string} - fully qualified name
7
+ * */
2
8
  export declare function getFqn(target: FqnTarget): string;
@@ -1,9 +1,16 @@
1
1
  import { KEY_ENUM_NAME, KEY_FQN_NAME, KEY_LITERAL_NAME } from "../const/index.js";
2
+ /**
3
+ * Get fqn name
4
+ *
5
+ * @param {FqnTarget} target - target (function, class, instance, enum, literal)
6
+ * @return {string} - fully qualified name
7
+ * */
2
8
  export function getFqn(target) {
3
9
  if (!target) {
4
10
  return undefined;
5
11
  }
6
12
  if (typeof target === "function") {
13
+ // function, class
7
14
  return target[KEY_FQN_NAME] ?? target.name;
8
15
  }
9
16
  else if (typeof target === "object") {
@@ -1,3 +1,24 @@
1
+ /**
2
+ * Get target property
3
+ *
4
+ * @param {any} target - target
5
+ * @param {string} key - key
6
+ * @return {any}
7
+ * */
1
8
  export declare function getKey<T>(target: unknown, key: string): T;
9
+ /**
10
+ * Get target hidden property
11
+ *
12
+ * @param {any} target - target
13
+ * @param {symbol} key - hidden key
14
+ * @return {any}
15
+ * */
2
16
  export declare function getSymbol<T>(target: unknown, key: symbol): T;
17
+ /**
18
+ * Get target property
19
+ *
20
+ * @param {any} target - target
21
+ * @param {(symbol|string)} key - key
22
+ * @return {any}
23
+ * */
3
24
  export declare function getProp<T>(target: unknown, key: symbol | string): T;