@utiliread/primitives 1.0.0-102 → 1.0.0-104
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.
- package/dist/cjs/breakdown-rule.js +2 -3
- package/dist/cjs/breakdown-rule.js.map +1 -1
- package/dist/cjs/breakdown-rule.spec.js.map +1 -1
- package/dist/cjs/measures/energy.js +1 -0
- package/dist/cjs/measures/energy.js.map +1 -1
- package/dist/cjs/measures/pressure.js +5 -1
- package/dist/cjs/measures/pressure.js.map +1 -1
- package/dist/cjs/register-convention.js +2 -2
- package/dist/cjs/register-convention.js.map +1 -1
- package/dist/cjs/register-utils.js +1 -2
- package/dist/cjs/register-utils.js.map +1 -1
- package/dist/cjs/registers/kamstrup-multical-infocode.js +13 -1
- package/dist/cjs/registers/kamstrup-multical-infocode.js.map +1 -1
- package/dist/cjs/repository.js +1 -2
- package/dist/cjs/repository.js.map +1 -1
- package/dist/cjs/time-or-rule.js +1 -2
- package/dist/cjs/time-or-rule.js.map +1 -1
- package/dist/esm/breakdown-rule.js +1 -1
- package/dist/esm/breakdown-rule.js.map +1 -1
- package/dist/esm/breakdown-rule.spec.js.map +1 -1
- package/dist/esm/measures/energy.js +1 -0
- package/dist/esm/measures/energy.js.map +1 -1
- package/dist/esm/measures/pressure.js +5 -1
- package/dist/esm/measures/pressure.js.map +1 -1
- package/dist/esm/register-id.d.ts +1 -1
- package/dist/esm/registers/kamstrup-multical-infocode.d.ts +2 -0
- package/dist/esm/registers/kamstrup-multical-infocode.js +12 -0
- package/dist/esm/registers/kamstrup-multical-infocode.js.map +1 -1
- package/dist/esm/time-or-rule.js.map +1 -1
- package/dist/esm/unit-id.d.ts +1 -1
- package/locales/da/aggregates.json +1 -1
- package/locales/da/measures.json +1 -1
- package/locales/da/mediums.json +1 -1
- package/locales/da/registers.json +1 -1
- package/locales/da/units.json +4 -1
- package/locales/en/aggregates.json +1 -1
- package/locales/en/measures.json +1 -1
- package/locales/en/mediums.json +1 -1
- package/locales/en/registers.json +1 -1
- package/locales/en/units.json +4 -1
- package/package.json +2 -2
- package/src/breakdown-rule.spec.ts +61 -63
- package/src/breakdown-rule.ts +58 -60
- package/src/measures/energy.ts +1 -0
- package/src/measures/pressure.ts +5 -1
- package/src/number-formatter.spec.ts +549 -549
- package/src/precision-number.spec.ts +28 -28
- package/src/register-convention.spec.ts +52 -52
- package/src/register-id.ts +2 -0
- package/src/register-library.spec.ts +41 -41
- package/src/registers/kamstrup-multical-infocode.ts +14 -0
- package/src/repository.spec.ts +20 -20
- package/src/step.spec.ts +37 -37
- package/src/time-or-rule.ts +42 -44
- package/src/unit-id.ts +1 -0
package/src/breakdown-rule.ts
CHANGED
|
@@ -1,60 +1,58 @@
|
|
|
1
|
-
import { TimeOrRule } from "./time-or-rule";
|
|
2
|
-
|
|
3
|
-
export type BreakdownRule = string;
|
|
4
|
-
export type BreakdownPeriod = "hour" | "day" | "week" | "month" | "year";
|
|
5
|
-
|
|
6
|
-
interface BreakdownRuleInit {
|
|
7
|
-
origin: TimeOrRule;
|
|
8
|
-
count: number;
|
|
9
|
-
period: BreakdownPeriod;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function BreakdownRule(init: BreakdownRuleInit): BreakdownRule;
|
|
13
|
-
export function BreakdownRule(
|
|
14
|
-
origin: TimeOrRule,
|
|
15
|
-
count: number,
|
|
16
|
-
period: BreakdownPeriod,
|
|
17
|
-
): BreakdownRule;
|
|
18
|
-
export function BreakdownRule(...params: any[]): BreakdownRule {
|
|
19
|
-
let init: BreakdownRuleInit;
|
|
20
|
-
switch (params.length) {
|
|
21
|
-
case 1:
|
|
22
|
-
init = params[0];
|
|
23
|
-
break;
|
|
24
|
-
case 3:
|
|
25
|
-
init = {
|
|
26
|
-
origin: params[0],
|
|
27
|
-
count: params[1],
|
|
28
|
-
period: params[2],
|
|
29
|
-
};
|
|
30
|
-
break;
|
|
31
|
-
default:
|
|
32
|
-
throw new TypeError("Invalid breakdown rule format");
|
|
33
|
-
}
|
|
34
|
-
const periodName =
|
|
35
|
-
Math.abs(init.count) == 1 ? init.period :
|
|
36
|
-
return `${init.origin}/${init.count}${periodName}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export namespace BreakdownRule {
|
|
40
|
-
const regex = new RegExp(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
import { TimeOrRule } from "./time-or-rule";
|
|
2
|
+
|
|
3
|
+
export type BreakdownRule = string;
|
|
4
|
+
export type BreakdownPeriod = "hour" | "day" | "week" | "month" | "year";
|
|
5
|
+
|
|
6
|
+
interface BreakdownRuleInit {
|
|
7
|
+
origin: TimeOrRule;
|
|
8
|
+
count: number;
|
|
9
|
+
period: BreakdownPeriod;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function BreakdownRule(init: BreakdownRuleInit): BreakdownRule;
|
|
13
|
+
export function BreakdownRule(
|
|
14
|
+
origin: TimeOrRule,
|
|
15
|
+
count: number,
|
|
16
|
+
period: BreakdownPeriod,
|
|
17
|
+
): BreakdownRule;
|
|
18
|
+
export function BreakdownRule(...params: any[]): BreakdownRule {
|
|
19
|
+
let init: BreakdownRuleInit;
|
|
20
|
+
switch (params.length) {
|
|
21
|
+
case 1:
|
|
22
|
+
init = params[0];
|
|
23
|
+
break;
|
|
24
|
+
case 3:
|
|
25
|
+
init = {
|
|
26
|
+
origin: params[0],
|
|
27
|
+
count: params[1],
|
|
28
|
+
period: params[2],
|
|
29
|
+
};
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
throw new TypeError("Invalid breakdown rule format");
|
|
33
|
+
}
|
|
34
|
+
const periodName =
|
|
35
|
+
Math.abs(init.count) == 1 ? init.period : init.period + "s";
|
|
36
|
+
return `${init.origin}/${init.count}${periodName}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export namespace BreakdownRule {
|
|
40
|
+
const regex = new RegExp("(.*)/([-+]?[0-9]+)(hour|day|week|month|year)s?");
|
|
41
|
+
export function split(rule: BreakdownRule) {
|
|
42
|
+
const match = regex.exec(rule);
|
|
43
|
+
if (!match) {
|
|
44
|
+
throw new Error("Invalid breakdown rule format");
|
|
45
|
+
}
|
|
46
|
+
const origin = match[1];
|
|
47
|
+
const count = parseInt(match[2]);
|
|
48
|
+
let period = match[3];
|
|
49
|
+
if (period.endsWith("s")) {
|
|
50
|
+
period = period.substring(0, period.length - 1);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
origin: TimeOrRule.parse(origin),
|
|
54
|
+
count,
|
|
55
|
+
period: period as BreakdownPeriod,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/measures/energy.ts
CHANGED
package/src/measures/pressure.ts
CHANGED
|
@@ -2,4 +2,8 @@ import { UnitId } from "../unit-id";
|
|
|
2
2
|
|
|
3
3
|
export const units: ReadonlyArray<UnitId> = ["bar", "pascal", "kiloPascal"];
|
|
4
4
|
|
|
5
|
-
export const sqUnits: ReadonlyArray<UnitId> = [
|
|
5
|
+
export const sqUnits: ReadonlyArray<UnitId> = [
|
|
6
|
+
"bar2",
|
|
7
|
+
"pascal2",
|
|
8
|
+
"kiloPascal2",
|
|
9
|
+
];
|