@christianriedl/utils 1.0.69 → 1.0.70

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.
@@ -1,5 +1,5 @@
1
1
  import { ILocalStorage } from './iLocalStorage';
2
- declare type Dictionary<T> = {
2
+ type Dictionary<T> = {
3
3
  [key: string]: T;
4
4
  };
5
5
  export declare class LocalStorageDummy implements ILocalStorage {
@@ -0,0 +1,21 @@
1
+ import { ILogger, LogLevel } from './iLogger';
2
+ import { InjectionKey } from 'vue';
3
+ export declare const statisticsSymbol: InjectionKey<IStatistics>;
4
+ export interface IStatisticsValue {
5
+ key: string;
6
+ category: string;
7
+ name: string;
8
+ id: number;
9
+ currentValue: number;
10
+ maximumValue: number;
11
+ sumValue: number;
12
+ incremented?: boolean;
13
+ }
14
+ export interface IStatistics {
15
+ getValues(category?: string): IStatisticsValue[];
16
+ searchOrCreate(category: string, name: string): IStatisticsValue;
17
+ reset(resetSum?: boolean, resetMax?: boolean): void;
18
+ increment(value: IStatisticsValue, count?: number): void;
19
+ set(value: IStatisticsValue, num: number): void;
20
+ log(logger: ILogger, level: LogLevel, category?: string): void;
21
+ }
@@ -0,0 +1,2 @@
1
+ export const statisticsSymbol = Symbol('statistics');
2
+ //# sourceMappingURL=iStatistics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iStatistics.js","sourceRoot":"","sources":["../src/iStatistics.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,gBAAgB,GAA8B,MAAM,CAAC,YAAY,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './types';
2
2
  export * from './iLogger';
3
+ export * from './iStatistics';
3
4
  export * from './helper';
4
5
  export * from './localStorage';
5
6
  export * from './dummyStorage';
@@ -7,4 +8,5 @@ export * from './registerServiceWorker';
7
8
  export * from './reactiveStorage';
8
9
  export * from './appState';
9
10
  export * from './appConfig';
11
+ export * from './statistics';
10
12
  export { InjectionKey, Ref, ref, reactive, toRaw, isRef, watchEffect } from 'vue';
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './types';
2
2
  export * from './iLogger';
3
+ export * from './iStatistics';
3
4
  export * from './helper';
4
5
  export * from './localStorage';
5
6
  export * from './dummyStorage';
@@ -7,5 +8,6 @@ export * from './registerServiceWorker';
7
8
  export * from './reactiveStorage';
8
9
  export * from './appState';
9
10
  export * from './appConfig';
11
+ export * from './statistics';
10
12
  export { ref, reactive, toRaw, isRef, watchEffect } from 'vue';
11
13
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAqB,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAqB,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { ILocalStorage } from './iLocalStorage';
2
- declare type Dictionary<T> = {
2
+ type Dictionary<T> = {
3
3
  [key: string]: T;
4
4
  };
5
5
  export declare class ReactiveStorageItem {
@@ -0,0 +1,13 @@
1
+ import { IStatisticsValue, IStatistics } from './iStatistics';
2
+ import { Dictionary } from './types';
3
+ import { ILogger, LogLevel } from './iLogger';
4
+ export declare class Statistics implements IStatistics {
5
+ values: Dictionary<IStatisticsValue>;
6
+ valueCount: number;
7
+ getValues(category?: string): IStatisticsValue[];
8
+ searchOrCreate(category: string, name: string): IStatisticsValue;
9
+ reset(resetSum?: boolean, resetMax?: boolean): void;
10
+ increment(value: IStatisticsValue, count?: number): void;
11
+ set(value: IStatisticsValue, num: number): void;
12
+ log(logger: ILogger, level: LogLevel, category?: string): void;
13
+ }
@@ -0,0 +1,54 @@
1
+ export class Statistics {
2
+ values = {};
3
+ valueCount = 0;
4
+ getValues(category) {
5
+ const values = [];
6
+ for (const key in this.values) {
7
+ const value = this.values[key];
8
+ if (category && category != value.category)
9
+ continue;
10
+ values.push(value);
11
+ }
12
+ values.sort((a, b) => a.key.localeCompare(b.key));
13
+ return values;
14
+ }
15
+ searchOrCreate(category, name) {
16
+ const key = category + ';' + name;
17
+ let value = this.values[key];
18
+ if (!value) {
19
+ value = { key: key, category: category, name: name, id: this.valueCount++, currentValue: 0, maximumValue: 0, sumValue: 0 };
20
+ this.values[key] = value;
21
+ }
22
+ return value;
23
+ }
24
+ reset(resetSum, resetMax) {
25
+ for (const key in this.values) {
26
+ const value = this.values[key];
27
+ if (value.incremented)
28
+ value.currentValue = 0;
29
+ if (resetMax)
30
+ value.currentValue = value.maximumValue = 0;
31
+ if (resetSum)
32
+ value.currentValue = value.sumValue = 0;
33
+ }
34
+ }
35
+ increment(value, count) {
36
+ if (!count)
37
+ count = 1;
38
+ this.set(value, value.currentValue + count);
39
+ value.sumValue += count;
40
+ }
41
+ set(value, num) {
42
+ value.currentValue = num;
43
+ if (num > value.maximumValue)
44
+ value.maximumValue = num;
45
+ }
46
+ log(logger, level, category) {
47
+ const values = this.getValues(category);
48
+ for (let i = 0; i < values.length; i++) {
49
+ const value = values[i];
50
+ logger.log(level, `${value.category}.${value.name} : C:${value.currentValue} M:${value.maximumValue} S:${value.sumValue}`);
51
+ }
52
+ }
53
+ }
54
+ //# sourceMappingURL=statistics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statistics.js","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,UAAU;IACnB,MAAM,GAAsC,EAAE,CAAC;IAC/C,UAAU,GAAW,CAAC,CAAC;IAEvB,SAAS,CAAC,QAAiB;QACvB,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE;YAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC/B,IAAI,QAAQ,IAAI,QAAQ,IAAI,KAAK,CAAC,QAAQ;gBACtC,SAAS;YACb,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACtB;QACD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAClD,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,cAAc,CAAC,QAAgB,EAAE,IAAY;QACzC,MAAM,GAAG,GAAG,QAAQ,GAAG,GAAG,GAAG,IAAI,CAAC;QAClC,IAAI,KAAK,GAAqB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,CAAC,KAAK,EAAE;YACR,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,EA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C,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACxB,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,QAAQ,KAAK,CAAC,YAAY,MAAM,KAAK,CAAC,YAAY,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;SAC9H;IACL,CAAC;CACJ"}
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ILocalStorage } from './iLocalStorage';
2
2
  import { LogLevel, ILogger } from './iLogger';
3
3
  import { Ref, InjectionKey } from 'vue';
4
- export declare type Dictionary<T> = {
4
+ export type Dictionary<T> = {
5
5
  [key: string]: T;
6
6
  };
7
7
  export declare const appConfigSymbol: InjectionKey<IAppConfig>;
@@ -91,7 +91,7 @@ export interface IAppState extends IAppInfo {
91
91
  log(logger: ILogger, logLevel: LogLevel): void;
92
92
  watch(logger: ILogger, logLevel: LogLevel): void;
93
93
  }
94
- export declare type ItemType = string | number | boolean;
94
+ export type ItemType = string | number | boolean;
95
95
  export interface IConfigItem {
96
96
  name: string;
97
97
  description: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@christianriedl/utils",
3
- "version": "1.0.69",
3
+ "version": "1.0.70",
4
4
  "description": "Interfaces, local storage, service worker, configuration, application state",
5
5
 
6
6
  "main": "dist/index.js",
@@ -18,11 +18,11 @@
18
18
  "author": "Christian Riedl",
19
19
  "license": "ISC",
20
20
  "dependencies": {
21
- "vue": "^3.2.41"
21
+ "vue": "^3.2.45"
22
22
  },
23
23
  "devDependencies": {
24
- "@vue/cli-plugin-typescript": "^5.0.4",
25
- "typescript": "^4.6.3",
26
- "@types/node": "^17.0.25"
24
+ "@vue/cli-plugin-typescript": "^5.0.8",
25
+ "typescript": "^4.9.4",
26
+ "@types/node": "^18.11.18"
27
27
  }
28
28
  }