@utiliread/primitives 1.0.0-44 → 1.0.0-48
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/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/number-formatter.js +16 -6
- package/dist/cjs/number-formatter.js.map +1 -1
- package/dist/cjs/number-formatter.spec.js +61 -57
- package/dist/cjs/number-formatter.spec.js.map +1 -1
- package/dist/cjs/optional.js +3 -0
- package/dist/cjs/optional.js.map +1 -0
- package/dist/cjs/register-convention.js +2 -2
- package/dist/cjs/register-convention.js.map +1 -1
- package/dist/cjs/register-convention.spec.js +7 -7
- package/dist/cjs/register-convention.spec.js.map +1 -1
- package/dist/cjs/register-library.spec.js +4 -4
- package/dist/cjs/register-library.spec.js.map +1 -1
- package/dist/cjs/repository.js +26 -0
- package/dist/cjs/repository.js.map +1 -0
- package/dist/cjs/repository.spec.js +21 -0
- package/dist/cjs/repository.spec.js.map +1 -0
- package/dist/cjs/step.spec.js +4 -4
- package/dist/cjs/step.spec.js.map +1 -1
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/number-formatter.d.ts +1 -1
- package/dist/esm/number-formatter.js +16 -6
- package/dist/esm/number-formatter.js.map +1 -1
- package/dist/esm/number-formatter.spec.js +54 -50
- package/dist/esm/number-formatter.spec.js.map +1 -1
- package/dist/esm/optional.d.ts +1 -0
- package/dist/esm/optional.js +2 -0
- package/dist/esm/optional.js.map +1 -0
- package/dist/esm/register-definition.d.ts +2 -0
- package/dist/esm/repository.d.ts +9 -0
- package/dist/esm/repository.js +22 -0
- package/dist/esm/repository.js.map +1 -0
- package/dist/esm/repository.spec.d.ts +1 -0
- package/dist/esm/repository.spec.js +19 -0
- package/dist/esm/repository.spec.js.map +1 -0
- package/package.json +36 -36
- package/src/index.ts +35 -33
- package/src/number-formatter.spec.ts +56 -51
- package/src/number-formatter.ts +18 -8
- package/src/optional.ts +1 -0
- package/src/precision-number.ts +33 -33
- package/src/register-definition.ts +23 -23
- package/src/repository.spec.ts +20 -20
|
@@ -4,50 +4,52 @@ import { NumberFormatter, Parts, localeDecimalSeparator, invariantDecimalSeparat
|
|
|
4
4
|
describe("toParts and toPrecision", () => {
|
|
5
5
|
it("should format correctly", () => {
|
|
6
6
|
const data: [number, number, Parts][] = [
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[77.1274,
|
|
10
|
-
[77.1274,
|
|
11
|
-
[77.1274,
|
|
12
|
-
[77.1274,
|
|
13
|
-
[77.1274,
|
|
14
|
-
[77.1274,
|
|
15
|
-
[77.1274,
|
|
16
|
-
[77.1274,
|
|
17
|
-
[77.1274,
|
|
18
|
-
[77.1274,
|
|
19
|
-
[77.1274,
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[0.00000123,
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[123456,
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[0
|
|
29
|
-
[0.
|
|
30
|
-
[0.
|
|
31
|
-
[0.
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
[9.
|
|
39
|
-
[9.
|
|
40
|
-
[
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[Number.
|
|
48
|
-
[Number.
|
|
49
|
-
[Number.
|
|
50
|
-
[
|
|
7
|
+
[0, 0, { invariantPrecisionString: "0", invariantCoefficientString: "0", exponent: 0, noOfCoefficientDecimals: 0 }],
|
|
8
|
+
[0.0, 1, { invariantPrecisionString: "0.0", invariantCoefficientString: "0.0", exponent: 0, noOfCoefficientDecimals: 1 }],
|
|
9
|
+
[77.1274, 1, { invariantPrecisionString: "8e+1", invariantCoefficientString: "8", exponent: 1, noOfCoefficientDecimals: 0 }],
|
|
10
|
+
[77.1274, 2, { invariantPrecisionString: "77", invariantCoefficientString: "77", exponent: 0, noOfCoefficientDecimals: 0 }],
|
|
11
|
+
[77.1274, 4, { invariantPrecisionString: "77.13", invariantCoefficientString: "77.13", exponent: 0, noOfCoefficientDecimals: 2 }],
|
|
12
|
+
[77.1274, 5, { invariantPrecisionString: "77.127", invariantCoefficientString: "77.127", exponent: 0, noOfCoefficientDecimals: 3 }],
|
|
13
|
+
[77.1274, 6, { invariantPrecisionString: "77.1274", invariantCoefficientString: "77.1274", exponent: 0, noOfCoefficientDecimals: 4 }],
|
|
14
|
+
[77.1274, 7, { invariantPrecisionString: "77.12740", invariantCoefficientString: "77.12740", exponent: 0, noOfCoefficientDecimals: 5 }],
|
|
15
|
+
[77.1274, 15, { invariantPrecisionString: "77.1274000000000", invariantCoefficientString: "77.1274000000000", exponent: 0, noOfCoefficientDecimals: 13 }],
|
|
16
|
+
[77.1274, 16, { invariantPrecisionString: "77.12739999999999", invariantCoefficientString: "77.12739999999999", exponent: 0, noOfCoefficientDecimals: 14 }],
|
|
17
|
+
[77.1274, 17, { invariantPrecisionString: "77.127399999999994", invariantCoefficientString: "77.127399999999994", exponent: 0, noOfCoefficientDecimals: 15 }],
|
|
18
|
+
[77.1274, 18, { invariantPrecisionString: "77.1273999999999944", invariantCoefficientString: "77.1273999999999944", exponent: 0, noOfCoefficientDecimals: 16 }],
|
|
19
|
+
[77.1274, 19, { invariantPrecisionString: "77.12739999999999441", invariantCoefficientString: "77.12739999999999441", exponent: 0, noOfCoefficientDecimals: 17 }],
|
|
20
|
+
[77.1274, 20, { invariantPrecisionString: "77.127399999999994407", invariantCoefficientString: "77.127399999999994407", exponent: 0, noOfCoefficientDecimals: 18 }],
|
|
21
|
+
[77.1274, 21, { invariantPrecisionString: "77.1273999999999944066", invariantCoefficientString: "77.1273999999999944066", exponent: 0, noOfCoefficientDecimals: 19 }],
|
|
22
|
+
[0.00000123, 2, { invariantPrecisionString: "0.0000012", invariantCoefficientString: "0.0000012", exponent: 0, noOfCoefficientDecimals: 7 }],
|
|
23
|
+
[0.000000123, 2, { invariantPrecisionString: "1.2e-7", invariantCoefficientString: "1.2", exponent: -7, noOfCoefficientDecimals: 1 }],
|
|
24
|
+
[0.00000123, 21, { invariantPrecisionString: "0.00000123000000000000008198", invariantCoefficientString: "0.00000123000000000000008198", exponent: 0, noOfCoefficientDecimals: 26 }],
|
|
25
|
+
[123456, 3, { invariantPrecisionString: "1.23e+5", invariantCoefficientString: "1.23", exponent: 5, noOfCoefficientDecimals: 2 }],
|
|
26
|
+
[Number.MAX_VALUE, 3, { invariantPrecisionString: "1.80e+308", invariantCoefficientString: "1.80", exponent: 308, noOfCoefficientDecimals: 2 }],
|
|
27
|
+
[123456, 15, { invariantPrecisionString: "123456.000000000", invariantCoefficientString: "123456.000000000", exponent: 0, noOfCoefficientDecimals: 9 }],
|
|
28
|
+
[0, 5, { invariantPrecisionString: "0.0000", invariantCoefficientString: "0.0000", exponent: 0, noOfCoefficientDecimals: 4 }],
|
|
29
|
+
[0.000001, 1, { invariantPrecisionString: "0.000001", invariantCoefficientString: "0.000001", exponent: 0, noOfCoefficientDecimals: 6 }],
|
|
30
|
+
[0.000001, 10, { invariantPrecisionString: "0.000001000000000", invariantCoefficientString: "0.000001000000000", exponent: 0, noOfCoefficientDecimals: 15 }],
|
|
31
|
+
[0.0000001, 10, { invariantPrecisionString: "1.000000000e-7", invariantCoefficientString: "1.000000000", exponent: -7, noOfCoefficientDecimals: 9 }],
|
|
32
|
+
[0.00000000001, 1, { invariantPrecisionString: "1e-11", invariantCoefficientString: "1", exponent: -11, noOfCoefficientDecimals: 0 }],
|
|
33
|
+
[0.00000000001, 2, { invariantPrecisionString: "1.0e-11", invariantCoefficientString: "1.0", exponent: -11, noOfCoefficientDecimals: 1 }],
|
|
34
|
+
[55, 2, { invariantPrecisionString: "55", invariantCoefficientString: "55", exponent: 0, noOfCoefficientDecimals: 0 }],
|
|
35
|
+
[55, 1, { invariantPrecisionString: "6e+1", invariantCoefficientString: "6", exponent: 1, noOfCoefficientDecimals: 0 }],
|
|
36
|
+
[-55, 2, { invariantPrecisionString: "-55", invariantCoefficientString: "-55", exponent: 0, noOfCoefficientDecimals: 0 }],
|
|
37
|
+
[-55, 1, { invariantPrecisionString: "-6e+1", invariantCoefficientString: "-6", exponent: 1, noOfCoefficientDecimals: 0 }],
|
|
38
|
+
[9.59, 1, { invariantPrecisionString: "1e+1", invariantCoefficientString: "1", exponent: 1, noOfCoefficientDecimals: 0 }],
|
|
39
|
+
[9.59, 2, { invariantPrecisionString: "10", invariantCoefficientString: "10", exponent: 0, noOfCoefficientDecimals: 0 }],
|
|
40
|
+
[9.95, 2, { invariantPrecisionString: "10", invariantCoefficientString: "10", exponent: 0, noOfCoefficientDecimals: 0 }],
|
|
41
|
+
[9.96, 2, { invariantPrecisionString: "10", invariantCoefficientString: "10", exponent: 0, noOfCoefficientDecimals: 0 }],
|
|
42
|
+
[-555555555555555555555, 1, { invariantPrecisionString: "-6e+20", invariantCoefficientString: "-6", exponent: 20, noOfCoefficientDecimals: 0 }],
|
|
43
|
+
[-5555555555555555555555, 1, { invariantPrecisionString: "-6e+21", invariantCoefficientString: "-6", exponent: 21, noOfCoefficientDecimals: 0 }],
|
|
44
|
+
[18014398509482012, 21, { invariantPrecisionString: "18014398509482012.0000", invariantCoefficientString: "18014398509482012.0000", exponent: 0, noOfCoefficientDecimals: 4 }],
|
|
45
|
+
[180143985094820121234, 21, { invariantPrecisionString: "180143985094820134912", invariantCoefficientString: "180143985094820134912", exponent: 0, noOfCoefficientDecimals: 0 }],
|
|
46
|
+
[0.1, 21, { invariantPrecisionString: "0.100000000000000005551", invariantCoefficientString: "0.100000000000000005551", exponent: 0, noOfCoefficientDecimals: 21 }],
|
|
47
|
+
[Number.EPSILON, 2, { invariantPrecisionString: "2.2e-16", invariantCoefficientString: "2.2", exponent: -16, noOfCoefficientDecimals: 1 }],
|
|
48
|
+
[Number.EPSILON, 21, { invariantPrecisionString: "2.22044604925031308085e-16", invariantCoefficientString: "2.22044604925031308085", exponent: -16, noOfCoefficientDecimals: 20 }],
|
|
49
|
+
[Number.NaN, 3, { invariantPrecisionString: "NaN", invariantCoefficientString: "NaN", exponent: 0, noOfCoefficientDecimals: 0 }],
|
|
50
|
+
[Number.POSITIVE_INFINITY, 3, { invariantPrecisionString: "Infinity", invariantCoefficientString: "Infinity", exponent: 0, noOfCoefficientDecimals: 0 }],
|
|
51
|
+
[Number.NEGATIVE_INFINITY, 3, { invariantPrecisionString: "-Infinity", invariantCoefficientString: "-Infinity", exponent: 0, noOfCoefficientDecimals: 0 }],
|
|
52
|
+
[164735280, 7, { invariantPrecisionString: "1.647353e+8", invariantCoefficientString: "1.647353", exponent: 8, noOfCoefficientDecimals: 6 }],
|
|
51
53
|
];
|
|
52
54
|
|
|
53
55
|
for (const [value, precision, expectedParts] of data) {
|
|
@@ -58,12 +60,7 @@ describe("toParts and toPrecision", () => {
|
|
|
58
60
|
|
|
59
61
|
const parts = NumberFormatter.getParts(value, precision);
|
|
60
62
|
expect(parts.invariantPrecisionString).to.equal(expectedParts.invariantPrecisionString);
|
|
61
|
-
|
|
62
|
-
expect(isNaN(parts.coefficient)).to.equal(true);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
expect(parts.coefficient).to.equal(expectedParts.coefficient);
|
|
66
|
-
}
|
|
63
|
+
expect(parts.invariantCoefficientString).to.equal(expectedParts.invariantCoefficientString);
|
|
67
64
|
expect(parts.exponent).to.equal(expectedParts.exponent);
|
|
68
65
|
expect(parts.noOfCoefficientDecimals).to.equal(expectedParts.noOfCoefficientDecimals);
|
|
69
66
|
}
|
|
@@ -73,6 +70,8 @@ describe("toParts and toPrecision", () => {
|
|
|
73
70
|
describe("toFixed", () => {
|
|
74
71
|
it("should format correctly", () => {
|
|
75
72
|
const data: [number, number, string][] = [
|
|
73
|
+
[0, 0, "0"],
|
|
74
|
+
[0.0, 1, "0.0"],
|
|
76
75
|
[10, 1, "10"],
|
|
77
76
|
[10, 2, "10"],
|
|
78
77
|
[10, 3, "10.0"],
|
|
@@ -91,4 +90,10 @@ describe("toFixed", () => {
|
|
|
91
90
|
expect(NumberFormatter.toLocaleFixed(value, precision)).to.equal(localeExpected);
|
|
92
91
|
}
|
|
93
92
|
})
|
|
94
|
-
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
describe("toLocaleFixed", () => {
|
|
96
|
+
it("should format correctly", () => {
|
|
97
|
+
expect(NumberFormatter.toLocaleFixed(400, 2)).to.equal("400");
|
|
98
|
+
})
|
|
99
|
+
});
|
package/src/number-formatter.ts
CHANGED
|
@@ -3,13 +3,23 @@ export const localeDecimalSeparator = (0.1).toLocaleString()[1];
|
|
|
3
3
|
|
|
4
4
|
export interface Parts {
|
|
5
5
|
invariantPrecisionString: string;
|
|
6
|
+
invariantCoefficientString: string;
|
|
6
7
|
exponent: number;
|
|
7
|
-
coefficient: number;
|
|
8
8
|
noOfCoefficientDecimals: number;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
class Formatter {
|
|
12
12
|
public toPrecision(value: number, precision: number) {
|
|
13
|
+
if (value === 0) {
|
|
14
|
+
// (0).toPrecision(1) == "0"
|
|
15
|
+
// (0).toPrecision(2) == "0.0"
|
|
16
|
+
// (0).toPrecision(3) == "0.00"
|
|
17
|
+
// However, we want:
|
|
18
|
+
// Formatter.toPrecision(0, 0) == "0"
|
|
19
|
+
// Formatter.toPrecision(0, 1) == "0.0"
|
|
20
|
+
// Formatter.toPrecision(0, 2) == "0.00"
|
|
21
|
+
return value.toPrecision(precision + 1);
|
|
22
|
+
}
|
|
13
23
|
const absValue = Math.abs(value);
|
|
14
24
|
if (absValue < 1) {
|
|
15
25
|
return value.toPrecision(precision);
|
|
@@ -29,7 +39,7 @@ class Formatter {
|
|
|
29
39
|
public toFixed(value: number, precision: number) {
|
|
30
40
|
const parts = this.getParts(value, precision);
|
|
31
41
|
if (parts.noOfCoefficientDecimals < parts.exponent) {
|
|
32
|
-
const number = parts.
|
|
42
|
+
const number = parts.invariantCoefficientString.replace(invariantDecimalSeparator, "");
|
|
33
43
|
const zeros = parts.exponent - parts.noOfCoefficientDecimals;
|
|
34
44
|
return `${number}${"0".repeat(zeros)}`;
|
|
35
45
|
}
|
|
@@ -47,15 +57,15 @@ class Formatter {
|
|
|
47
57
|
const precisionString = this.toPrecision(value, precision);
|
|
48
58
|
if (precisionString.indexOf("e") >= 0) {
|
|
49
59
|
const match = /(.*)e([\+-]\d+)$/.exec(precisionString)!;
|
|
50
|
-
const
|
|
60
|
+
const coefficientString = match[1];
|
|
51
61
|
const exponent = parseInt(match[2]);
|
|
52
|
-
const decimalSeparatorIndex =
|
|
62
|
+
const decimalSeparatorIndex = coefficientString.indexOf(invariantDecimalSeparator);
|
|
53
63
|
const noOfCoefficientDecimals = decimalSeparatorIndex >= 0
|
|
54
|
-
?
|
|
64
|
+
? coefficientString.length - decimalSeparatorIndex - 1
|
|
55
65
|
: 0;
|
|
56
66
|
return {
|
|
57
67
|
invariantPrecisionString: precisionString,
|
|
58
|
-
|
|
68
|
+
invariantCoefficientString: coefficientString,
|
|
59
69
|
exponent,
|
|
60
70
|
noOfCoefficientDecimals,
|
|
61
71
|
};
|
|
@@ -67,7 +77,7 @@ class Formatter {
|
|
|
67
77
|
: 0;
|
|
68
78
|
return {
|
|
69
79
|
invariantPrecisionString: precisionString,
|
|
70
|
-
|
|
80
|
+
invariantCoefficientString: precisionString,
|
|
71
81
|
exponent: 0,
|
|
72
82
|
noOfCoefficientDecimals,
|
|
73
83
|
};
|
|
@@ -75,4 +85,4 @@ class Formatter {
|
|
|
75
85
|
}
|
|
76
86
|
}
|
|
77
87
|
|
|
78
|
-
export const NumberFormatter = new Formatter();
|
|
88
|
+
export const NumberFormatter = new Formatter();
|
package/src/optional.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
package/src/precision-number.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { invariantDecimalSeparator } from ".";
|
|
2
|
-
import { localeDecimalSeparator, NumberFormatter } from "./number-formatter";
|
|
3
|
-
|
|
4
|
-
export class PrecisionNumber {
|
|
5
|
-
constructor(public value: number, public precision: number) {
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
static parse(input: string) {
|
|
9
|
-
const normalized = input.trim().replace(",", ".").replace(localeDecimalSeparator, invariantDecimalSeparator);
|
|
10
|
-
const precision = normalized.replace(".", "").replace("+", "").replace("-", "").length;
|
|
11
|
-
return new PrecisionNumber(parseFloat(normalized), precision);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
toString() {
|
|
15
|
-
return this.value.toString();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
toFixed() {
|
|
19
|
-
return NumberFormatter.toFixed(this.value, this.precision);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
toPrecision() {
|
|
23
|
-
return NumberFormatter.toPrecision(this.value, this.precision);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
toLocaleFixed() {
|
|
27
|
-
return NumberFormatter.toLocaleFixed(this.value, this.precision);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
toLocalePrecision() {
|
|
31
|
-
return NumberFormatter.toLocalePrecision(this.value, this.precision);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
import { invariantDecimalSeparator } from ".";
|
|
2
|
+
import { localeDecimalSeparator, NumberFormatter } from "./number-formatter";
|
|
3
|
+
|
|
4
|
+
export class PrecisionNumber {
|
|
5
|
+
constructor(public value: number, public precision: number) {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
static parse(input: string) {
|
|
9
|
+
const normalized = input.trim().replace(",", ".").replace(localeDecimalSeparator, invariantDecimalSeparator);
|
|
10
|
+
const precision = normalized.replace(".", "").replace("+", "").replace("-", "").length;
|
|
11
|
+
return new PrecisionNumber(parseFloat(normalized), precision);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
toString() {
|
|
15
|
+
return this.value.toString();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
toFixed() {
|
|
19
|
+
return NumberFormatter.toFixed(this.value, this.precision);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
toPrecision() {
|
|
23
|
+
return NumberFormatter.toPrecision(this.value, this.precision);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
toLocaleFixed() {
|
|
27
|
+
return NumberFormatter.toLocaleFixed(this.value, this.precision);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
toLocalePrecision() {
|
|
31
|
+
return NumberFormatter.toLocalePrecision(this.value, this.precision);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { UnitId } from ".";
|
|
2
|
-
import { AggregateId } from "./aggregate-id";
|
|
3
|
-
import { MeasureId } from "./measure-id";
|
|
4
|
-
import { RegisterId } from "./register-id";
|
|
5
|
-
|
|
6
|
-
export interface RegisterDefinition {
|
|
7
|
-
/// The id of the register
|
|
8
|
-
id: RegisterId;
|
|
9
|
-
/// The register measure
|
|
10
|
-
measure: MeasureId;
|
|
11
|
-
/// The aggregate of the register
|
|
12
|
-
aggregate: AggregateId;
|
|
13
|
-
/// The possible register units
|
|
14
|
-
units: ReadonlyArray<UnitId>;
|
|
15
|
-
/// Whether the register can only be resolved by "present value".
|
|
16
|
-
immediate?: true;
|
|
17
|
-
/// An optional concise register name.
|
|
18
|
-
/// Only used for custom registers as locales exist for standard registers.
|
|
19
|
-
name?: string;
|
|
20
|
-
/// An optional register description.
|
|
21
|
-
/// Only used for custom registers as locales exist for standard registers.
|
|
22
|
-
description?: string;
|
|
23
|
-
}
|
|
1
|
+
import { UnitId } from ".";
|
|
2
|
+
import { AggregateId } from "./aggregate-id";
|
|
3
|
+
import { MeasureId } from "./measure-id";
|
|
4
|
+
import { RegisterId } from "./register-id";
|
|
5
|
+
|
|
6
|
+
export interface RegisterDefinition {
|
|
7
|
+
/// The id of the register
|
|
8
|
+
id: RegisterId;
|
|
9
|
+
/// The register measure
|
|
10
|
+
measure: MeasureId;
|
|
11
|
+
/// The aggregate of the register
|
|
12
|
+
aggregate: AggregateId;
|
|
13
|
+
/// The possible register units
|
|
14
|
+
units: ReadonlyArray<UnitId>;
|
|
15
|
+
/// Whether the register can only be resolved by "present value".
|
|
16
|
+
immediate?: true;
|
|
17
|
+
/// An optional concise register name.
|
|
18
|
+
/// Only used for custom registers as locales exist for standard registers.
|
|
19
|
+
name?: string;
|
|
20
|
+
/// An optional register description.
|
|
21
|
+
/// Only used for custom registers as locales exist for standard registers.
|
|
22
|
+
description?: string;
|
|
23
|
+
}
|
package/src/repository.spec.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { Repository } from "./repository";
|
|
3
|
-
|
|
4
|
-
describe("ctor", () => {
|
|
5
|
-
it("creates", () => {
|
|
6
|
-
expect(Repository("gpkv", "gjoel")).to.equal("gpkv/gjoel");
|
|
7
|
-
expect(Repository("gpkv/gjoel")).to.equal("gpkv/gjoel");
|
|
8
|
-
});
|
|
9
|
-
it("throws if wrong format", () => {
|
|
10
|
-
expect(() => Repository("invalid")).to.throw();
|
|
11
|
-
})
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
describe("split", () => {
|
|
15
|
-
it("splits into correct parts", () => {
|
|
16
|
-
const { team, name } = Repository.split(Repository("gpkv", "gjoel"));
|
|
17
|
-
expect(team).to.equal("gpkv");
|
|
18
|
-
expect(name).to.equal("gjoel");
|
|
19
|
-
});
|
|
20
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { Repository } from "./repository";
|
|
3
|
+
|
|
4
|
+
describe("ctor", () => {
|
|
5
|
+
it("creates", () => {
|
|
6
|
+
expect(Repository("gpkv", "gjoel")).to.equal("gpkv/gjoel");
|
|
7
|
+
expect(Repository("gpkv/gjoel")).to.equal("gpkv/gjoel");
|
|
8
|
+
});
|
|
9
|
+
it("throws if wrong format", () => {
|
|
10
|
+
expect(() => Repository("invalid")).to.throw();
|
|
11
|
+
})
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe("split", () => {
|
|
15
|
+
it("splits into correct parts", () => {
|
|
16
|
+
const { team, name } = Repository.split(Repository("gpkv", "gjoel"));
|
|
17
|
+
expect(team).to.equal("gpkv");
|
|
18
|
+
expect(name).to.equal("gjoel");
|
|
19
|
+
});
|
|
20
|
+
});
|