@utiliread/primitives 1.0.0-70 → 1.0.0-71
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/aggregate-id.js +2 -2
- package/dist/cjs/consumption-type-id.js +2 -2
- package/dist/cjs/index.js +21 -21
- package/dist/cjs/measure-id.js +2 -2
- package/dist/cjs/number-formatter.js +81 -81
- package/dist/cjs/number-formatter.spec.js +97 -97
- package/dist/cjs/optional.js +2 -2
- package/dist/cjs/precision-number.js +35 -35
- package/dist/cjs/precision-number.spec.js +26 -26
- package/dist/cjs/register-convention.js +55 -55
- package/dist/cjs/register-convention.spec.js +38 -38
- package/dist/cjs/register-definition.js +2 -2
- package/dist/cjs/register-id.js +2 -2
- package/dist/cjs/register-library.js +50 -50
- package/dist/cjs/register-library.spec.js +36 -36
- package/dist/cjs/register-pack.js +2 -2
- package/dist/cjs/register-utils.js +7 -7
- package/dist/cjs/repository.js +25 -25
- package/dist/cjs/repository.js.map +1 -1
- package/dist/cjs/repository.spec.js +20 -20
- package/dist/cjs/step.js +40 -40
- package/dist/cjs/step.js.map +1 -1
- package/dist/cjs/step.spec.js +28 -28
- package/dist/cjs/time-or-rule.js +18 -18
- package/dist/cjs/time-or-rule.js.map +1 -1
- package/dist/cjs/unit-id.js +13 -13
- package/dist/esm/aggregate-id.d.ts +1 -1
- package/dist/esm/aggregate-id.js +1 -1
- package/dist/esm/consumption-type-id.d.ts +1 -1
- package/dist/esm/consumption-type-id.js +1 -1
- package/dist/esm/index.d.ts +16 -16
- package/dist/esm/index.js +9 -9
- package/dist/esm/measure-id.d.ts +1 -1
- package/dist/esm/measure-id.js +1 -1
- package/dist/esm/number-formatter.d.ts +17 -17
- package/dist/esm/number-formatter.js +78 -78
- package/dist/esm/number-formatter.spec.d.ts +1 -1
- package/dist/esm/number-formatter.spec.js +95 -95
- package/dist/esm/optional.d.ts +1 -1
- package/dist/esm/optional.js +1 -1
- package/dist/esm/precision-number.d.ts +11 -11
- package/dist/esm/precision-number.js +31 -31
- package/dist/esm/precision-number.spec.d.ts +1 -1
- package/dist/esm/precision-number.spec.js +24 -24
- package/dist/esm/register-convention.d.ts +14 -14
- package/dist/esm/register-convention.js +51 -51
- package/dist/esm/register-convention.spec.d.ts +1 -1
- package/dist/esm/register-convention.spec.js +36 -36
- package/dist/esm/register-definition.d.ts +13 -13
- package/dist/esm/register-definition.js +1 -1
- package/dist/esm/register-id.d.ts +1 -1
- package/dist/esm/register-id.js +1 -1
- package/dist/esm/register-library.d.ts +15 -15
- package/dist/esm/register-library.js +47 -47
- package/dist/esm/register-library.spec.d.ts +1 -1
- package/dist/esm/register-library.spec.js +34 -34
- package/dist/esm/register-pack.d.ts +4 -4
- package/dist/esm/register-pack.js +1 -1
- package/dist/esm/register-utils.d.ts +3 -3
- package/dist/esm/register-utils.js +3 -3
- package/dist/esm/repository.d.ts +9 -9
- package/dist/esm/repository.js +21 -21
- package/dist/esm/repository.spec.d.ts +1 -1
- package/dist/esm/repository.spec.js +18 -18
- package/dist/esm/step.d.ts +15 -15
- package/dist/esm/step.js +37 -37
- package/dist/esm/step.spec.d.ts +1 -1
- package/dist/esm/step.spec.js +26 -26
- package/dist/esm/time-or-rule.d.ts +7 -7
- package/dist/esm/time-or-rule.js +15 -15
- package/dist/esm/unit-id.d.ts +2 -2
- package/dist/esm/unit-id.js +10 -10
- package/locales/da/registers.json +1 -1
- package/locales/en/registers.json +1 -1
- package/package.json +3 -3
- package/src/register-id.ts +303 -303
package/dist/esm/optional.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
1
|
+
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
package/dist/esm/optional.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=optional.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export declare class PrecisionNumber {
|
|
2
|
-
value: number;
|
|
3
|
-
precision: number;
|
|
4
|
-
constructor(value: number, precision: number);
|
|
5
|
-
static parse(input: string): PrecisionNumber;
|
|
6
|
-
toString(): string;
|
|
7
|
-
toFixed(): string;
|
|
8
|
-
toPrecision(): string;
|
|
9
|
-
toLocaleFixed(): string;
|
|
10
|
-
toLocalePrecision(): string;
|
|
11
|
-
}
|
|
1
|
+
export declare class PrecisionNumber {
|
|
2
|
+
value: number;
|
|
3
|
+
precision: number;
|
|
4
|
+
constructor(value: number, precision: number);
|
|
5
|
+
static parse(input: string): PrecisionNumber;
|
|
6
|
+
toString(): string;
|
|
7
|
+
toFixed(): string;
|
|
8
|
+
toPrecision(): string;
|
|
9
|
+
toLocaleFixed(): string;
|
|
10
|
+
toLocalePrecision(): string;
|
|
11
|
+
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { invariantDecimalSeparator } from ".";
|
|
2
|
-
import { localeDecimalSeparator, NumberFormatter } from "./number-formatter";
|
|
3
|
-
export class PrecisionNumber {
|
|
4
|
-
constructor(value, precision) {
|
|
5
|
-
this.value = value;
|
|
6
|
-
this.precision = precision;
|
|
7
|
-
}
|
|
8
|
-
static parse(input) {
|
|
9
|
-
let normalized = input.trim().replace(",", ".").replace(localeDecimalSeparator, invariantDecimalSeparator);
|
|
10
|
-
if (normalized.endsWith(invariantDecimalSeparator)) {
|
|
11
|
-
normalized += "0";
|
|
12
|
-
}
|
|
13
|
-
const precision = normalized.replace(".", "").replace("+", "").replace("-", "").length;
|
|
14
|
-
return new PrecisionNumber(parseFloat(normalized), precision);
|
|
15
|
-
}
|
|
16
|
-
toString() {
|
|
17
|
-
return this.value.toString();
|
|
18
|
-
}
|
|
19
|
-
toFixed() {
|
|
20
|
-
return NumberFormatter.toFixed(this.value, this.precision);
|
|
21
|
-
}
|
|
22
|
-
toPrecision() {
|
|
23
|
-
return NumberFormatter.toPrecision(this.value, this.precision);
|
|
24
|
-
}
|
|
25
|
-
toLocaleFixed() {
|
|
26
|
-
return NumberFormatter.toLocaleFixed(this.value, this.precision);
|
|
27
|
-
}
|
|
28
|
-
toLocalePrecision() {
|
|
29
|
-
return NumberFormatter.toLocalePrecision(this.value, this.precision);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
import { invariantDecimalSeparator } from ".";
|
|
2
|
+
import { localeDecimalSeparator, NumberFormatter } from "./number-formatter";
|
|
3
|
+
export class PrecisionNumber {
|
|
4
|
+
constructor(value, precision) {
|
|
5
|
+
this.value = value;
|
|
6
|
+
this.precision = precision;
|
|
7
|
+
}
|
|
8
|
+
static parse(input) {
|
|
9
|
+
let normalized = input.trim().replace(",", ".").replace(localeDecimalSeparator, invariantDecimalSeparator);
|
|
10
|
+
if (normalized.endsWith(invariantDecimalSeparator)) {
|
|
11
|
+
normalized += "0";
|
|
12
|
+
}
|
|
13
|
+
const precision = normalized.replace(".", "").replace("+", "").replace("-", "").length;
|
|
14
|
+
return new PrecisionNumber(parseFloat(normalized), precision);
|
|
15
|
+
}
|
|
16
|
+
toString() {
|
|
17
|
+
return this.value.toString();
|
|
18
|
+
}
|
|
19
|
+
toFixed() {
|
|
20
|
+
return NumberFormatter.toFixed(this.value, this.precision);
|
|
21
|
+
}
|
|
22
|
+
toPrecision() {
|
|
23
|
+
return NumberFormatter.toPrecision(this.value, this.precision);
|
|
24
|
+
}
|
|
25
|
+
toLocaleFixed() {
|
|
26
|
+
return NumberFormatter.toLocaleFixed(this.value, this.precision);
|
|
27
|
+
}
|
|
28
|
+
toLocalePrecision() {
|
|
29
|
+
return NumberFormatter.toLocalePrecision(this.value, this.precision);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
32
|
//# sourceMappingURL=precision-number.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { PrecisionNumber } from "./precision-number";
|
|
3
|
-
describe("precision-number", () => {
|
|
4
|
-
it("should not parse ''", () => {
|
|
5
|
-
const number = PrecisionNumber.parse("");
|
|
6
|
-
expect(Number.isNaN(number.value)).to.equal(true);
|
|
7
|
-
expect(number.precision).to.equal(0);
|
|
8
|
-
});
|
|
9
|
-
it("should parse '1'", () => {
|
|
10
|
-
const number = PrecisionNumber.parse("1");
|
|
11
|
-
expect(number.value).to.equal(1);
|
|
12
|
-
expect(number.precision).to.equal(1);
|
|
13
|
-
});
|
|
14
|
-
it("should parse '1.'", () => {
|
|
15
|
-
const number = PrecisionNumber.parse("1.");
|
|
16
|
-
expect(number.value).to.equal(1);
|
|
17
|
-
expect(number.precision).to.equal(2);
|
|
18
|
-
});
|
|
19
|
-
it("should parse '1.0'", () => {
|
|
20
|
-
const number = PrecisionNumber.parse("1.0");
|
|
21
|
-
expect(number.value).to.equal(1);
|
|
22
|
-
expect(number.precision).to.equal(2);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { PrecisionNumber } from "./precision-number";
|
|
3
|
+
describe("precision-number", () => {
|
|
4
|
+
it("should not parse ''", () => {
|
|
5
|
+
const number = PrecisionNumber.parse("");
|
|
6
|
+
expect(Number.isNaN(number.value)).to.equal(true);
|
|
7
|
+
expect(number.precision).to.equal(0);
|
|
8
|
+
});
|
|
9
|
+
it("should parse '1'", () => {
|
|
10
|
+
const number = PrecisionNumber.parse("1");
|
|
11
|
+
expect(number.value).to.equal(1);
|
|
12
|
+
expect(number.precision).to.equal(1);
|
|
13
|
+
});
|
|
14
|
+
it("should parse '1.'", () => {
|
|
15
|
+
const number = PrecisionNumber.parse("1.");
|
|
16
|
+
expect(number.value).to.equal(1);
|
|
17
|
+
expect(number.precision).to.equal(2);
|
|
18
|
+
});
|
|
19
|
+
it("should parse '1.0'", () => {
|
|
20
|
+
const number = PrecisionNumber.parse("1.0");
|
|
21
|
+
expect(number.value).to.equal(1);
|
|
22
|
+
expect(number.precision).to.equal(2);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
25
|
//# sourceMappingURL=precision-number.spec.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { RegisterDefinition } from ".";
|
|
2
|
-
import { AggregateId } from "./aggregate-id";
|
|
3
|
-
import { RegisterId } from "./register-id";
|
|
4
|
-
export declare const aggregatePrefixes: {
|
|
5
|
-
[aggregateId in AggregateId]: string;
|
|
6
|
-
};
|
|
7
|
-
declare class Convention {
|
|
8
|
-
getAggregate(register: RegisterId | RegisterDefinition): AggregateId;
|
|
9
|
-
toInstant(register: RegisterId | RegisterDefinition): RegisterId;
|
|
10
|
-
toAggregate(register: RegisterId | RegisterDefinition, aggregate: AggregateId): RegisterId;
|
|
11
|
-
}
|
|
12
|
-
export declare function isPrefix(registerId: RegisterId, prefix: string): boolean;
|
|
13
|
-
export declare const RegisterConvention: Convention;
|
|
14
|
-
export {};
|
|
1
|
+
import { RegisterDefinition } from ".";
|
|
2
|
+
import { AggregateId } from "./aggregate-id";
|
|
3
|
+
import { RegisterId } from "./register-id";
|
|
4
|
+
export declare const aggregatePrefixes: {
|
|
5
|
+
[aggregateId in AggregateId]: string;
|
|
6
|
+
};
|
|
7
|
+
declare class Convention {
|
|
8
|
+
getAggregate(register: RegisterId | RegisterDefinition): AggregateId;
|
|
9
|
+
toInstant(register: RegisterId | RegisterDefinition): RegisterId;
|
|
10
|
+
toAggregate(register: RegisterId | RegisterDefinition, aggregate: AggregateId): RegisterId;
|
|
11
|
+
}
|
|
12
|
+
export declare function isPrefix(registerId: RegisterId, prefix: string): boolean;
|
|
13
|
+
export declare const RegisterConvention: Convention;
|
|
14
|
+
export {};
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { getRegisterId } from "./register-utils";
|
|
2
|
-
export const aggregatePrefixes = {
|
|
3
|
-
instant: "",
|
|
4
|
-
diff: "diff",
|
|
5
|
-
min: "min",
|
|
6
|
-
max: "max",
|
|
7
|
-
avg: "avg",
|
|
8
|
-
sum: "sum",
|
|
9
|
-
cnt: "cnt",
|
|
10
|
-
ssq: "ssq",
|
|
11
|
-
};
|
|
12
|
-
class Convention {
|
|
13
|
-
getAggregate(register) {
|
|
14
|
-
const registerId = getRegisterId(register);
|
|
15
|
-
// Brute force all prefixes - if none of them, then it must be instant.
|
|
16
|
-
for (const aggregateString of Object.keys(aggregatePrefixes)) {
|
|
17
|
-
const aggregate = aggregateString;
|
|
18
|
-
const prefix = aggregatePrefixes[aggregate];
|
|
19
|
-
if (prefix.length && isPrefix(registerId, prefix)) {
|
|
20
|
-
// Not instant - it was any of the others.
|
|
21
|
-
return aggregate;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return "instant";
|
|
25
|
-
}
|
|
26
|
-
toInstant(register) {
|
|
27
|
-
const registerId = getRegisterId(register);
|
|
28
|
-
for (const prefix of Object.values(aggregatePrefixes)) {
|
|
29
|
-
if (prefix.length && isPrefix(registerId, prefix)) {
|
|
30
|
-
const tail = registerId.substr(prefix.length);
|
|
31
|
-
return (tail[0].toLowerCase() + tail.substr(1));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return registerId;
|
|
35
|
-
}
|
|
36
|
-
toAggregate(register, aggregate) {
|
|
37
|
-
const instantRegisterId = this.toInstant(register);
|
|
38
|
-
if (aggregate === "instant") {
|
|
39
|
-
return instantRegisterId;
|
|
40
|
-
}
|
|
41
|
-
const prefix = aggregatePrefixes[aggregate];
|
|
42
|
-
return (prefix + instantRegisterId[0].toUpperCase() + instantRegisterId.substr(1));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export function isPrefix(registerId, prefix) {
|
|
46
|
-
return registerId.startsWith(prefix) && isUppercase(registerId[prefix.length]);
|
|
47
|
-
}
|
|
48
|
-
function isUppercase(input) {
|
|
49
|
-
return input.toUpperCase() === input;
|
|
50
|
-
}
|
|
51
|
-
export const RegisterConvention = new Convention();
|
|
1
|
+
import { getRegisterId } from "./register-utils";
|
|
2
|
+
export const aggregatePrefixes = {
|
|
3
|
+
instant: "",
|
|
4
|
+
diff: "diff",
|
|
5
|
+
min: "min",
|
|
6
|
+
max: "max",
|
|
7
|
+
avg: "avg",
|
|
8
|
+
sum: "sum",
|
|
9
|
+
cnt: "cnt",
|
|
10
|
+
ssq: "ssq",
|
|
11
|
+
};
|
|
12
|
+
class Convention {
|
|
13
|
+
getAggregate(register) {
|
|
14
|
+
const registerId = getRegisterId(register);
|
|
15
|
+
// Brute force all prefixes - if none of them, then it must be instant.
|
|
16
|
+
for (const aggregateString of Object.keys(aggregatePrefixes)) {
|
|
17
|
+
const aggregate = aggregateString;
|
|
18
|
+
const prefix = aggregatePrefixes[aggregate];
|
|
19
|
+
if (prefix.length && isPrefix(registerId, prefix)) {
|
|
20
|
+
// Not instant - it was any of the others.
|
|
21
|
+
return aggregate;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return "instant";
|
|
25
|
+
}
|
|
26
|
+
toInstant(register) {
|
|
27
|
+
const registerId = getRegisterId(register);
|
|
28
|
+
for (const prefix of Object.values(aggregatePrefixes)) {
|
|
29
|
+
if (prefix.length && isPrefix(registerId, prefix)) {
|
|
30
|
+
const tail = registerId.substr(prefix.length);
|
|
31
|
+
return (tail[0].toLowerCase() + tail.substr(1));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return registerId;
|
|
35
|
+
}
|
|
36
|
+
toAggregate(register, aggregate) {
|
|
37
|
+
const instantRegisterId = this.toInstant(register);
|
|
38
|
+
if (aggregate === "instant") {
|
|
39
|
+
return instantRegisterId;
|
|
40
|
+
}
|
|
41
|
+
const prefix = aggregatePrefixes[aggregate];
|
|
42
|
+
return (prefix + instantRegisterId[0].toUpperCase() + instantRegisterId.substr(1));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function isPrefix(registerId, prefix) {
|
|
46
|
+
return registerId.startsWith(prefix) && isUppercase(registerId[prefix.length]);
|
|
47
|
+
}
|
|
48
|
+
function isUppercase(input) {
|
|
49
|
+
return input.toUpperCase() === input;
|
|
50
|
+
}
|
|
51
|
+
export const RegisterConvention = new Convention();
|
|
52
52
|
//# sourceMappingURL=register-convention.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { RegisterConvention } from "./register-convention";
|
|
3
|
-
describe("getAggregate", () => {
|
|
4
|
-
it("instant register is instant", () => {
|
|
5
|
-
const result = RegisterConvention.getAggregate("flowTemperature");
|
|
6
|
-
expect(result).to.equal("instant");
|
|
7
|
-
});
|
|
8
|
-
it("avg register is avg", () => {
|
|
9
|
-
const result = RegisterConvention.getAggregate("avgFlowTemperature");
|
|
10
|
-
expect(result).to.equal("avg");
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
describe("toInstant", () => {
|
|
14
|
-
it("should convert instant", () => {
|
|
15
|
-
const registerId = RegisterConvention.toInstant("flowTemperature");
|
|
16
|
-
expect(registerId).to.equal("flowTemperature");
|
|
17
|
-
});
|
|
18
|
-
it("should convert aggregate", () => {
|
|
19
|
-
const registerId = RegisterConvention.toInstant("avgFlowTemperature");
|
|
20
|
-
expect(registerId).to.equal("flowTemperature");
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
describe("toAggregate", () => {
|
|
24
|
-
it("should convert instant to aggregate", () => {
|
|
25
|
-
const registerId = RegisterConvention.toAggregate("flowTemperature", "avg");
|
|
26
|
-
expect(registerId).to.equal("avgFlowTemperature");
|
|
27
|
-
});
|
|
28
|
-
it("should convert aggregate to same aggregate", () => {
|
|
29
|
-
const registerId = RegisterConvention.toAggregate("avgFlowTemperature", "avg");
|
|
30
|
-
expect(registerId).to.equal("avgFlowTemperature");
|
|
31
|
-
});
|
|
32
|
-
it("should convert aggregate to other aggregate", () => {
|
|
33
|
-
const registerId = RegisterConvention.toAggregate("avgFlowTemperature", "min");
|
|
34
|
-
expect(registerId).to.equal("minFlowTemperature");
|
|
35
|
-
});
|
|
36
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { RegisterConvention } from "./register-convention";
|
|
3
|
+
describe("getAggregate", () => {
|
|
4
|
+
it("instant register is instant", () => {
|
|
5
|
+
const result = RegisterConvention.getAggregate("flowTemperature");
|
|
6
|
+
expect(result).to.equal("instant");
|
|
7
|
+
});
|
|
8
|
+
it("avg register is avg", () => {
|
|
9
|
+
const result = RegisterConvention.getAggregate("avgFlowTemperature");
|
|
10
|
+
expect(result).to.equal("avg");
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
describe("toInstant", () => {
|
|
14
|
+
it("should convert instant", () => {
|
|
15
|
+
const registerId = RegisterConvention.toInstant("flowTemperature");
|
|
16
|
+
expect(registerId).to.equal("flowTemperature");
|
|
17
|
+
});
|
|
18
|
+
it("should convert aggregate", () => {
|
|
19
|
+
const registerId = RegisterConvention.toInstant("avgFlowTemperature");
|
|
20
|
+
expect(registerId).to.equal("flowTemperature");
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe("toAggregate", () => {
|
|
24
|
+
it("should convert instant to aggregate", () => {
|
|
25
|
+
const registerId = RegisterConvention.toAggregate("flowTemperature", "avg");
|
|
26
|
+
expect(registerId).to.equal("avgFlowTemperature");
|
|
27
|
+
});
|
|
28
|
+
it("should convert aggregate to same aggregate", () => {
|
|
29
|
+
const registerId = RegisterConvention.toAggregate("avgFlowTemperature", "avg");
|
|
30
|
+
expect(registerId).to.equal("avgFlowTemperature");
|
|
31
|
+
});
|
|
32
|
+
it("should convert aggregate to other aggregate", () => {
|
|
33
|
+
const registerId = RegisterConvention.toAggregate("avgFlowTemperature", "min");
|
|
34
|
+
expect(registerId).to.equal("minFlowTemperature");
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
37
|
//# sourceMappingURL=register-convention.spec.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { UnitId } from ".";
|
|
2
|
-
import { AggregateId } from "./aggregate-id";
|
|
3
|
-
import { MeasureId } from "./measure-id";
|
|
4
|
-
import { RegisterId } from "./register-id";
|
|
5
|
-
export interface RegisterDefinition {
|
|
6
|
-
id: RegisterId;
|
|
7
|
-
measure: MeasureId;
|
|
8
|
-
aggregate: AggregateId;
|
|
9
|
-
units: ReadonlyArray<UnitId>;
|
|
10
|
-
immediate?: true;
|
|
11
|
-
name?: string;
|
|
12
|
-
description?: string;
|
|
13
|
-
}
|
|
1
|
+
import { UnitId } from ".";
|
|
2
|
+
import { AggregateId } from "./aggregate-id";
|
|
3
|
+
import { MeasureId } from "./measure-id";
|
|
4
|
+
import { RegisterId } from "./register-id";
|
|
5
|
+
export interface RegisterDefinition {
|
|
6
|
+
id: RegisterId;
|
|
7
|
+
measure: MeasureId;
|
|
8
|
+
aggregate: AggregateId;
|
|
9
|
+
units: ReadonlyArray<UnitId>;
|
|
10
|
+
immediate?: true;
|
|
11
|
+
name?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=register-definition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type RegisterId = "none" | "heatEnergy" | "diffHeatEnergy" | "cntHeatEnergy" | "heatEnergyVolumeInInlet" | "diffHeatEnergyVolumeInInlet" | "cntHeatEnergyVolumeInInlet" | "heatEnergyVolumeInOutlet" | "diffHeatEnergyVolumeInOutlet" | "cntHeatEnergyVolumeInOutlet" | "coolingEnergy" | "diffCoolingEnergy" | "cntCoolingEnergy" | "coolingEnergyVolumeInInlet" | "diffCoolingEnergyVolumeInInlet" | "cntCoolingEnergyVolumeInInlet" | "coolingEnergyVolumeInOutlet" | "diffCoolingEnergyVolumeInOutlet" | "cntCoolingEnergyVolumeInOutlet" | "electricalEnergy" | "diffElectricalEnergy" | "cntElectricalEnergy" | "reactiveEnergy" | "diffReactiveEnergy" | "cntReactiveEnergy" | "volume" | "diffVolume" | "cntVolume" | "inletVolume" | "diffInletVolume" | "cntInletVolume" | "outletVolume" | "diffOutletVolume" | "cntOutletVolume" | "pulseInputAVolume" | "diffPulseInputAVolume" | "cntPulseInputAVolume" | "pulseInputBVolume" | "diffPulseInputBVolume" | "cntPulseInputBVolume" | "mass" | "diffMass" | "cntMass" | "inletMass" | "diffInletMass" | "cntInletMass" | "outletMass" | "diffOutletMass" | "cntOutletMass" | "pressure" | "maxPressure" | "minPressure" | "avgPressure" | "sumPressure" | "cntPressure" | "ssqPressure" | "inletPressure" | "maxInletPressure" | "minInletPressure" | "avgInletPressure" | "sumInletPressure" | "cntInletPressure" | "ssqInletPressure" | "outletPressure" | "maxOutletPressure" | "minOutletPressure" | "avgOutletPressure" | "sumOutletPressure" | "cntOutletPressure" | "ssqOutletPressure" | "power" | "maxPower" | "minPower" | "avgPower" | "sumPower" | "cntPower" | "ssqPower" | "inletPower" | "maxInletPower" | "minInletPower" | "avgInletPower" | "sumInletPower" | "cntInletPower" | "ssqInletPower" | "outletPower" | "maxOutletPower" | "minOutletPower" | "avgOutletPower" | "sumOutletPower" | "cntOutletPower" | "ssqOutletPower" | "volumeFlow" | "maxVolumeFlow" | "minVolumeFlow" | "avgVolumeFlow" | "sumVolumeFlow" | "cntVolumeFlow" | "ssqVolumeFlow" | "inletVolumeFlow" | "maxInletVolumeFlow" | "minInletVolumeFlow" | "avgInletVolumeFlow" | "sumInletVolumeFlow" | "cntInletVolumeFlow" | "ssqInletVolumeFlow" | "outletVolumeFlow" | "maxOutletVolumeFlow" | "minOutletVolumeFlow" | "avgOutletVolumeFlow" | "sumOutletVolumeFlow" | "cntOutletVolumeFlow" | "ssqOutletVolumeFlow" | "massFlow" | "maxMassFlow" | "minMassFlow" | "avgMassFlow" | "sumMassFlow" | "cntMassFlow" | "ssqMassFlow" | "inletMassFlow" | "maxInletMassFlow" | "minInletMassFlow" | "avgInletMassFlow" | "sumInletMassFlow" | "cntInletMassFlow" | "ssqInletMassFlow" | "outletMassFlow" | "maxOutletMassFlow" | "minOutletMassFlow" | "avgOutletMassFlow" | "sumOutletMassFlow" | "cntOutletMassFlow" | "ssqOutletMassFlow" | "flowTemperature" | "maxFlowTemperature" | "minFlowTemperature" | "avgFlowTemperature" | "sumFlowTemperature" | "cntFlowTemperature" | "ssqFlowTemperature" | "inletFlowTemperature" | "maxInletFlowTemperature" | "minInletFlowTemperature" | "avgInletFlowTemperature" | "sumInletFlowTemperature" | "cntInletFlowTemperature" | "ssqInletFlowTemperature" | "outletFlowTemperature" | "maxOutletFlowTemperature" | "minOutletFlowTemperature" | "avgOutletFlowTemperature" | "sumOutletFlowTemperature" | "cntOutletFlowTemperature" | "ssqOutletFlowTemperature" | "inletMinusOutletFlowTemperatureDifference" | "maxInletMinusOutletFlowTemperatureDifference" | "minInletMinusOutletFlowTemperatureDifference" | "avgInletMinusOutletFlowTemperatureDifference" | "sumInletMinusOutletFlowTemperatureDifference" | "cntInletMinusOutletFlowTemperatureDifference" | "ssqInletMinusOutletFlowTemperatureDifference" | "outletMinusInletFlowTemperatureDifference" | "maxOutletMinusInletFlowTemperatureDifference" | "minOutletMinusInletFlowTemperatureDifference" | "avgOutletMinusInletFlowTemperatureDifference" | "sumOutletMinusInletFlowTemperatureDifference" | "cntOutletMinusInletFlowTemperatureDifference" | "ssqOutletMinusInletFlowTemperatureDifference" | "ambientTemperature" | "maxAmbientTemperature" | "minAmbientTemperature" | "avgAmbientTemperature" | "sumAmbientTemperature" | "cntAmbientTemperature" | "ssqAmbientTemperature" | "radiatorTemperature" | "maxRadiatorTemperature" | "minRadiatorTemperature" | "avgRadiatorTemperature" | "sumRadiatorTemperature" | "cntRadiatorTemperature" | "ssqRadiatorTemperature" | "auxFlowTemperature" | "maxAuxFlowTemperature" | "minAuxFlowTemperature" | "avgAuxFlowTemperature" | "sumAuxFlowTemperature" | "cntAuxFlowTemperature" | "ssqAuxFlowTemperature" | "relativeHumidity" | "kamstrupE8Inlet" | "diffKamstrupE8Inlet" | "cntKamstrupE8Inlet" | "kamstrupE9Outlet" | "diffKamstrupE9Outlet" | "cntKamstrupE9Outlet" | "operatingTime" | "diffOperatingTime" | "cntOperatingTime" | "errorOperatingTime" | "diffErrorOperatingTime" | "cntErrorOperatingTime" | "remainingBatteryTime" | "diffRemainingBatteryTime" | "cntRemainingBatteryTime" | "deviceDate" | "deviceTime" | "deviceDateTime" | "timeSinceLastExactOverhearingArrived" | "timeAtLastExactOverhearingArrived" | "timeSinceLastPossibleCandidateOverhearingArrived" | "timeAtLastPossibleCandidateOverhearingArrived" | "timeSinceLastSampled" | "timeAtLastSampled" | "timeSinceLastInstallationMounted" | "timeAtLastInstallationMounted" | "basetime" | "instantTime" | "periodStartTime" | "periodEndTime" | "instantOrPeriodStartTime" | "instantOrPeriodEndTime" | "device" | "wMBusDeviceAddresses" | "kamdraftDeviceAddresses" | "tchlrDeviceAddresses" | "kamdaDeviceAddresses" | "msisdnDeviceAddresses" | "deviceRegisters" | "
|
|
1
|
+
export type RegisterId = "none" | "heatEnergy" | "diffHeatEnergy" | "cntHeatEnergy" | "heatEnergyVolumeInInlet" | "diffHeatEnergyVolumeInInlet" | "cntHeatEnergyVolumeInInlet" | "heatEnergyVolumeInOutlet" | "diffHeatEnergyVolumeInOutlet" | "cntHeatEnergyVolumeInOutlet" | "coolingEnergy" | "diffCoolingEnergy" | "cntCoolingEnergy" | "coolingEnergyVolumeInInlet" | "diffCoolingEnergyVolumeInInlet" | "cntCoolingEnergyVolumeInInlet" | "coolingEnergyVolumeInOutlet" | "diffCoolingEnergyVolumeInOutlet" | "cntCoolingEnergyVolumeInOutlet" | "electricalEnergy" | "diffElectricalEnergy" | "cntElectricalEnergy" | "reactiveEnergy" | "diffReactiveEnergy" | "cntReactiveEnergy" | "volume" | "diffVolume" | "cntVolume" | "inletVolume" | "diffInletVolume" | "cntInletVolume" | "outletVolume" | "diffOutletVolume" | "cntOutletVolume" | "pulseInputAVolume" | "diffPulseInputAVolume" | "cntPulseInputAVolume" | "pulseInputBVolume" | "diffPulseInputBVolume" | "cntPulseInputBVolume" | "mass" | "diffMass" | "cntMass" | "inletMass" | "diffInletMass" | "cntInletMass" | "outletMass" | "diffOutletMass" | "cntOutletMass" | "pressure" | "maxPressure" | "minPressure" | "avgPressure" | "sumPressure" | "cntPressure" | "ssqPressure" | "inletPressure" | "maxInletPressure" | "minInletPressure" | "avgInletPressure" | "sumInletPressure" | "cntInletPressure" | "ssqInletPressure" | "outletPressure" | "maxOutletPressure" | "minOutletPressure" | "avgOutletPressure" | "sumOutletPressure" | "cntOutletPressure" | "ssqOutletPressure" | "power" | "maxPower" | "minPower" | "avgPower" | "sumPower" | "cntPower" | "ssqPower" | "inletPower" | "maxInletPower" | "minInletPower" | "avgInletPower" | "sumInletPower" | "cntInletPower" | "ssqInletPower" | "outletPower" | "maxOutletPower" | "minOutletPower" | "avgOutletPower" | "sumOutletPower" | "cntOutletPower" | "ssqOutletPower" | "volumeFlow" | "maxVolumeFlow" | "minVolumeFlow" | "avgVolumeFlow" | "sumVolumeFlow" | "cntVolumeFlow" | "ssqVolumeFlow" | "inletVolumeFlow" | "maxInletVolumeFlow" | "minInletVolumeFlow" | "avgInletVolumeFlow" | "sumInletVolumeFlow" | "cntInletVolumeFlow" | "ssqInletVolumeFlow" | "outletVolumeFlow" | "maxOutletVolumeFlow" | "minOutletVolumeFlow" | "avgOutletVolumeFlow" | "sumOutletVolumeFlow" | "cntOutletVolumeFlow" | "ssqOutletVolumeFlow" | "massFlow" | "maxMassFlow" | "minMassFlow" | "avgMassFlow" | "sumMassFlow" | "cntMassFlow" | "ssqMassFlow" | "inletMassFlow" | "maxInletMassFlow" | "minInletMassFlow" | "avgInletMassFlow" | "sumInletMassFlow" | "cntInletMassFlow" | "ssqInletMassFlow" | "outletMassFlow" | "maxOutletMassFlow" | "minOutletMassFlow" | "avgOutletMassFlow" | "sumOutletMassFlow" | "cntOutletMassFlow" | "ssqOutletMassFlow" | "flowTemperature" | "maxFlowTemperature" | "minFlowTemperature" | "avgFlowTemperature" | "sumFlowTemperature" | "cntFlowTemperature" | "ssqFlowTemperature" | "inletFlowTemperature" | "maxInletFlowTemperature" | "minInletFlowTemperature" | "avgInletFlowTemperature" | "sumInletFlowTemperature" | "cntInletFlowTemperature" | "ssqInletFlowTemperature" | "outletFlowTemperature" | "maxOutletFlowTemperature" | "minOutletFlowTemperature" | "avgOutletFlowTemperature" | "sumOutletFlowTemperature" | "cntOutletFlowTemperature" | "ssqOutletFlowTemperature" | "inletMinusOutletFlowTemperatureDifference" | "maxInletMinusOutletFlowTemperatureDifference" | "minInletMinusOutletFlowTemperatureDifference" | "avgInletMinusOutletFlowTemperatureDifference" | "sumInletMinusOutletFlowTemperatureDifference" | "cntInletMinusOutletFlowTemperatureDifference" | "ssqInletMinusOutletFlowTemperatureDifference" | "outletMinusInletFlowTemperatureDifference" | "maxOutletMinusInletFlowTemperatureDifference" | "minOutletMinusInletFlowTemperatureDifference" | "avgOutletMinusInletFlowTemperatureDifference" | "sumOutletMinusInletFlowTemperatureDifference" | "cntOutletMinusInletFlowTemperatureDifference" | "ssqOutletMinusInletFlowTemperatureDifference" | "ambientTemperature" | "maxAmbientTemperature" | "minAmbientTemperature" | "avgAmbientTemperature" | "sumAmbientTemperature" | "cntAmbientTemperature" | "ssqAmbientTemperature" | "radiatorTemperature" | "maxRadiatorTemperature" | "minRadiatorTemperature" | "avgRadiatorTemperature" | "sumRadiatorTemperature" | "cntRadiatorTemperature" | "ssqRadiatorTemperature" | "auxFlowTemperature" | "maxAuxFlowTemperature" | "minAuxFlowTemperature" | "avgAuxFlowTemperature" | "sumAuxFlowTemperature" | "cntAuxFlowTemperature" | "ssqAuxFlowTemperature" | "relativeHumidity" | "kamstrupE8Inlet" | "diffKamstrupE8Inlet" | "cntKamstrupE8Inlet" | "kamstrupE9Outlet" | "diffKamstrupE9Outlet" | "cntKamstrupE9Outlet" | "operatingTime" | "diffOperatingTime" | "cntOperatingTime" | "errorOperatingTime" | "diffErrorOperatingTime" | "cntErrorOperatingTime" | "remainingBatteryTime" | "diffRemainingBatteryTime" | "cntRemainingBatteryTime" | "deviceDate" | "deviceTime" | "deviceDateTime" | "timeSinceLastExactOverhearingArrived" | "timeAtLastExactOverhearingArrived" | "timeSinceLastPossibleCandidateOverhearingArrived" | "timeAtLastPossibleCandidateOverhearingArrived" | "timeSinceLastSampled" | "timeAtLastSampled" | "timeSinceLastInstallationMounted" | "timeAtLastInstallationMounted" | "basetime" | "instantTime" | "periodStartTime" | "periodEndTime" | "instantOrPeriodStartTime" | "instantOrPeriodEndTime" | "device" | "wMBusDeviceAddresses" | "kamdraftDeviceAddresses" | "tchlrDeviceAddresses" | "kamdaDeviceAddresses" | "msisdnDeviceAddresses" | "deviceRegisters" | "place" | "mBusFormatStringSignature" | "deviceSoftwareVersion" | "kamstrupMulticalInfocodeType1" | "kamstrupMulticalInfocodeType2" | "kamstrupMulticalInfocodeType3" | "kamstrupMulticalInfocodeType4" | "kamstrupMulticalInfocode" | "kamstrupModuleType" | "diehlInfocodeType1" | "diehlInfocode" | "landisGyrMBusStatusType1" | "landisGyrMBusStatusType2" | "landisGyrMBusStatus" | "landisGyrInfocodeType1" | "landisGyrInfocodeType2" | "landisGyrInfocode" | "infocode";
|
package/dist/esm/register-id.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=register-id.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { RegisterDefinition } from "./register-definition";
|
|
2
|
-
import { RegisterId } from "./register-id";
|
|
3
|
-
import { RegisterPack } from "./register-pack";
|
|
4
|
-
declare class Library {
|
|
5
|
-
private definitions;
|
|
6
|
-
add(...definitions: (RegisterDefinition | RegisterPack)[]): void;
|
|
7
|
-
private tryAdd;
|
|
8
|
-
has(id: RegisterId): boolean;
|
|
9
|
-
tryGet(id: RegisterId): RegisterDefinition | undefined;
|
|
10
|
-
get(id: RegisterId): RegisterDefinition;
|
|
11
|
-
all(): RegisterDefinition[];
|
|
12
|
-
reset(): void;
|
|
13
|
-
}
|
|
14
|
-
export declare const RegisterLibrary: Library;
|
|
15
|
-
export {};
|
|
1
|
+
import { RegisterDefinition } from "./register-definition";
|
|
2
|
+
import { RegisterId } from "./register-id";
|
|
3
|
+
import { RegisterPack } from "./register-pack";
|
|
4
|
+
declare class Library {
|
|
5
|
+
private definitions;
|
|
6
|
+
add(...definitions: (RegisterDefinition | RegisterPack)[]): void;
|
|
7
|
+
private tryAdd;
|
|
8
|
+
has(id: RegisterId): boolean;
|
|
9
|
+
tryGet(id: RegisterId): RegisterDefinition | undefined;
|
|
10
|
+
get(id: RegisterId): RegisterDefinition;
|
|
11
|
+
all(): RegisterDefinition[];
|
|
12
|
+
reset(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare const RegisterLibrary: Library;
|
|
15
|
+
export {};
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
class Library {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.definitions = {};
|
|
4
|
-
}
|
|
5
|
-
add(...definitions) {
|
|
6
|
-
for (const definition of definitions) {
|
|
7
|
-
if (isDefinition(definition)) {
|
|
8
|
-
this.tryAdd(definition);
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
for (const definitionInPack of Object.values(definition)) {
|
|
12
|
-
this.tryAdd(definitionInPack);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
tryAdd(definition) {
|
|
18
|
-
if (!this.definitions[definition.id]) {
|
|
19
|
-
this.definitions[definition.id] = definition;
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
has(id) {
|
|
25
|
-
return !!this.definitions[id];
|
|
26
|
-
}
|
|
27
|
-
tryGet(id) {
|
|
28
|
-
return this.definitions[id];
|
|
29
|
-
}
|
|
30
|
-
get(id) {
|
|
31
|
-
const definition = this.definitions[id];
|
|
32
|
-
if (!definition) {
|
|
33
|
-
throw new Error(`Defintion was not loaded for register ${id}`);
|
|
34
|
-
}
|
|
35
|
-
return definition;
|
|
36
|
-
}
|
|
37
|
-
all() {
|
|
38
|
-
return Object.values(this.definitions).map(x => x);
|
|
39
|
-
}
|
|
40
|
-
reset() {
|
|
41
|
-
this.definitions = {};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function isDefinition(definitionOrPack) {
|
|
45
|
-
return !!(definitionOrPack.id && definitionOrPack.aggregate && definitionOrPack.units);
|
|
46
|
-
}
|
|
47
|
-
export const RegisterLibrary = new Library();
|
|
1
|
+
class Library {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.definitions = {};
|
|
4
|
+
}
|
|
5
|
+
add(...definitions) {
|
|
6
|
+
for (const definition of definitions) {
|
|
7
|
+
if (isDefinition(definition)) {
|
|
8
|
+
this.tryAdd(definition);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
for (const definitionInPack of Object.values(definition)) {
|
|
12
|
+
this.tryAdd(definitionInPack);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
tryAdd(definition) {
|
|
18
|
+
if (!this.definitions[definition.id]) {
|
|
19
|
+
this.definitions[definition.id] = definition;
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
has(id) {
|
|
25
|
+
return !!this.definitions[id];
|
|
26
|
+
}
|
|
27
|
+
tryGet(id) {
|
|
28
|
+
return this.definitions[id];
|
|
29
|
+
}
|
|
30
|
+
get(id) {
|
|
31
|
+
const definition = this.definitions[id];
|
|
32
|
+
if (!definition) {
|
|
33
|
+
throw new Error(`Defintion was not loaded for register ${id}`);
|
|
34
|
+
}
|
|
35
|
+
return definition;
|
|
36
|
+
}
|
|
37
|
+
all() {
|
|
38
|
+
return Object.values(this.definitions).map(x => x);
|
|
39
|
+
}
|
|
40
|
+
reset() {
|
|
41
|
+
this.definitions = {};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function isDefinition(definitionOrPack) {
|
|
45
|
+
return !!(definitionOrPack.id && definitionOrPack.aggregate && definitionOrPack.units);
|
|
46
|
+
}
|
|
47
|
+
export const RegisterLibrary = new Library();
|
|
48
48
|
//# sourceMappingURL=register-library.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { RegisterLibrary } from "./register-library";
|
|
3
|
-
const volume = {
|
|
4
|
-
id: "volume",
|
|
5
|
-
measure: "volume",
|
|
6
|
-
aggregate: "instant",
|
|
7
|
-
units: ["cubicMeter"]
|
|
8
|
-
};
|
|
9
|
-
describe("library", () => {
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
RegisterLibrary.reset();
|
|
12
|
-
});
|
|
13
|
-
it("should get added definition", () => {
|
|
14
|
-
RegisterLibrary.add(volume);
|
|
15
|
-
const definition = RegisterLibrary.get("volume");
|
|
16
|
-
expect(definition.id).to.equal("volume");
|
|
17
|
-
});
|
|
18
|
-
it("should add all definitions in pack", () => {
|
|
19
|
-
RegisterLibrary.add({
|
|
20
|
-
someRandomKey: volume
|
|
21
|
-
});
|
|
22
|
-
const definition = RegisterLibrary.get("volume");
|
|
23
|
-
expect(definition.id).to.equal("volume");
|
|
24
|
-
});
|
|
25
|
-
it("should throw when getting not added register", () => {
|
|
26
|
-
expect(() => RegisterLibrary.get("volume")).to.throw();
|
|
27
|
-
});
|
|
28
|
-
it("should return all definitions when invoking all()", () => {
|
|
29
|
-
RegisterLibrary.add(volume);
|
|
30
|
-
RegisterLibrary.add(volume); // Only added once.
|
|
31
|
-
const all = RegisterLibrary.all();
|
|
32
|
-
expect(all.length).to.equal(1);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { RegisterLibrary } from "./register-library";
|
|
3
|
+
const volume = {
|
|
4
|
+
id: "volume",
|
|
5
|
+
measure: "volume",
|
|
6
|
+
aggregate: "instant",
|
|
7
|
+
units: ["cubicMeter"]
|
|
8
|
+
};
|
|
9
|
+
describe("library", () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
RegisterLibrary.reset();
|
|
12
|
+
});
|
|
13
|
+
it("should get added definition", () => {
|
|
14
|
+
RegisterLibrary.add(volume);
|
|
15
|
+
const definition = RegisterLibrary.get("volume");
|
|
16
|
+
expect(definition.id).to.equal("volume");
|
|
17
|
+
});
|
|
18
|
+
it("should add all definitions in pack", () => {
|
|
19
|
+
RegisterLibrary.add({
|
|
20
|
+
someRandomKey: volume
|
|
21
|
+
});
|
|
22
|
+
const definition = RegisterLibrary.get("volume");
|
|
23
|
+
expect(definition.id).to.equal("volume");
|
|
24
|
+
});
|
|
25
|
+
it("should throw when getting not added register", () => {
|
|
26
|
+
expect(() => RegisterLibrary.get("volume")).to.throw();
|
|
27
|
+
});
|
|
28
|
+
it("should return all definitions when invoking all()", () => {
|
|
29
|
+
RegisterLibrary.add(volume);
|
|
30
|
+
RegisterLibrary.add(volume); // Only added once.
|
|
31
|
+
const all = RegisterLibrary.all();
|
|
32
|
+
expect(all.length).to.equal(1);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
35
|
//# sourceMappingURL=register-library.spec.js.map
|