@leyyo/common 1.3.13 → 1.3.14
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.
|
@@ -50,6 +50,8 @@ export declare class ErrorCommon implements ErrorCommonLike {
|
|
|
50
50
|
/** @inheritDoc */
|
|
51
51
|
addStat(p1: Error | ErrorCtor): number;
|
|
52
52
|
/** @inheritDoc */
|
|
53
|
+
getStat(p1: Error | ErrorCtor): number;
|
|
54
|
+
/** @inheritDoc */
|
|
53
55
|
clearStats(): void;
|
|
54
56
|
/** @inheritDoc */
|
|
55
57
|
listStats(): Record<string, number>;
|
|
@@ -324,6 +324,29 @@ export class ErrorCommon {
|
|
|
324
324
|
return num;
|
|
325
325
|
}
|
|
326
326
|
/** @inheritDoc */
|
|
327
|
+
getStat(p1) {
|
|
328
|
+
try {
|
|
329
|
+
let clazz;
|
|
330
|
+
if (isObj(p1)) {
|
|
331
|
+
clazz = p1.constructor;
|
|
332
|
+
}
|
|
333
|
+
else if (typeof p1 === 'function') {
|
|
334
|
+
clazz = p1;
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
return 0;
|
|
338
|
+
}
|
|
339
|
+
if (!this._stats) {
|
|
340
|
+
return 0;
|
|
341
|
+
}
|
|
342
|
+
return this._stats.get(clazz) ?? 0;
|
|
343
|
+
}
|
|
344
|
+
catch (e) {
|
|
345
|
+
// nothing
|
|
346
|
+
}
|
|
347
|
+
return 0;
|
|
348
|
+
}
|
|
349
|
+
/** @inheritDoc */
|
|
327
350
|
clearStats() {
|
|
328
351
|
if (!this._stats) {
|
|
329
352
|
return;
|
|
@@ -259,6 +259,20 @@ export interface ErrorCommonLike {
|
|
|
259
259
|
* @return {number} - total raised count
|
|
260
260
|
* */
|
|
261
261
|
addStat(clazz: ErrorCtor): number;
|
|
262
|
+
/**
|
|
263
|
+
* Get error statistics with instance
|
|
264
|
+
*
|
|
265
|
+
* @param {Error} error
|
|
266
|
+
* @return {number} - total raised count
|
|
267
|
+
* */
|
|
268
|
+
getStat(error: Error): number;
|
|
269
|
+
/**
|
|
270
|
+
* Get error statistics
|
|
271
|
+
*
|
|
272
|
+
* @param {ErrorCtor} clazz
|
|
273
|
+
* @return {number} - total raised count
|
|
274
|
+
* */
|
|
275
|
+
getStat(clazz: ErrorCtor): number;
|
|
262
276
|
/**
|
|
263
277
|
* Clear statistics
|
|
264
278
|
* */
|