@utiliread/primitives 1.0.0-5 → 1.0.0-50
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/.parcel-cache/05bceb1debb074ab +0 -0
- package/.parcel-cache/98c3d22f150231c4 +0 -0
- package/.parcel-cache/a94329c46f41e756 +0 -0
- package/.parcel-cache/b72f446afb579f45 +0 -0
- package/.parcel-cache/d9963624c0099aed.txt +12308 -0
- package/.parcel-cache/data.mdb +0 -0
- package/.parcel-cache/lock.mdb +0 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +288 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +275 -0
- package/dist/index.mjs.map +1 -0
- package/karma.config.js +11 -14
- package/locales/da/aggregates.json +8 -0
- package/locales/da/consumption-types.json +7 -0
- package/locales/da/measures.json +15 -0
- package/locales/da/registers.json +198 -0
- package/locales/da/units.json +90 -0
- package/locales/en/aggregates.json +8 -0
- package/locales/en/consumption-types.json +7 -0
- package/locales/en/measures.json +15 -0
- package/locales/en/registers.json +198 -0
- package/locales/en/units.json +90 -0
- package/package.json +19 -8
- package/src/aggregate-id.ts +9 -9
- package/src/consumption-type-id.ts +8 -8
- package/src/index.ts +35 -15
- package/src/measure-id.ts +14 -0
- package/src/number-formatter.spec.ts +99 -0
- package/src/number-formatter.ts +88 -0
- package/src/optional.ts +1 -0
- package/src/precision-number.spec.ts +28 -0
- package/src/precision-number.ts +36 -0
- package/src/register-convention.spec.ts +43 -0
- package/src/register-convention.ts +61 -0
- package/src/register-definition.ts +23 -10
- package/src/register-id.ts +197 -191
- package/src/register-library.spec.ts +41 -33
- package/src/register-library.ts +57 -37
- package/src/register-pack.ts +5 -5
- package/src/register-utils.ts +6 -0
- package/src/repository.spec.ts +20 -0
- package/src/repository.ts +24 -0
- package/src/step.spec.ts +30 -0
- package/src/step.ts +37 -0
- package/src/time-or-rule.ts +17 -0
- package/src/unit-id.ts +100 -100
- package/tsconfig.json +12 -14
- package/tsconfig.test.json +7 -0
- package/coverage/Chrome Headless 90.0.4430.85 (Windows 10)/html/base.css +0 -224
- package/coverage/Chrome Headless 90.0.4430.85 (Windows 10)/html/block-navigation.js +0 -79
- package/coverage/Chrome Headless 90.0.4430.85 (Windows 10)/html/favicon.png +0 -0
- package/coverage/Chrome Headless 90.0.4430.85 (Windows 10)/html/index.html +0 -96
- package/coverage/Chrome Headless 90.0.4430.85 (Windows 10)/html/prettify.css +0 -1
- package/coverage/Chrome Headless 90.0.4430.85 (Windows 10)/html/prettify.js +0 -2
- package/coverage/Chrome Headless 90.0.4430.85 (Windows 10)/html/sort-arrow-sprite.png +0 -0
- package/coverage/Chrome Headless 90.0.4430.85 (Windows 10)/html/sorter.js +0 -170
- package/dist/cjs/aggregate-id.js +0 -3
- package/dist/cjs/aggregate-id.js.map +0 -1
- package/dist/cjs/consumption-type-id.js +0 -3
- package/dist/cjs/consumption-type-id.js.map +0 -1
- package/dist/cjs/index.js +0 -8
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/register-converter.js +0 -47
- package/dist/cjs/register-converter.js.map +0 -1
- package/dist/cjs/register-converter.spec.js +0 -29
- package/dist/cjs/register-converter.spec.js.map +0 -1
- package/dist/cjs/register-definition.js +0 -3
- package/dist/cjs/register-definition.js.map +0 -1
- package/dist/cjs/register-id.js +0 -3
- package/dist/cjs/register-id.js.map +0 -1
- package/dist/cjs/register-library.js +0 -42
- package/dist/cjs/register-library.js.map +0 -1
- package/dist/cjs/register-library.spec.js +0 -30
- package/dist/cjs/register-library.spec.js.map +0 -1
- package/dist/cjs/register-pack.js +0 -3
- package/dist/cjs/register-pack.js.map +0 -1
- package/dist/cjs/unit-id.js +0 -14
- package/dist/cjs/unit-id.js.map +0 -1
- package/dist/esm/aggregate-id.d.ts +0 -1
- package/dist/esm/aggregate-id.js +0 -2
- package/dist/esm/aggregate-id.js.map +0 -1
- package/dist/esm/consumption-type-id.d.ts +0 -1
- package/dist/esm/consumption-type-id.js +0 -2
- package/dist/esm/consumption-type-id.js.map +0 -1
- package/dist/esm/index.d.ts +0 -7
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/register-converter.d.ts +0 -9
- package/dist/esm/register-converter.js +0 -44
- package/dist/esm/register-converter.js.map +0 -1
- package/dist/esm/register-converter.spec.d.ts +0 -1
- package/dist/esm/register-converter.spec.js +0 -27
- package/dist/esm/register-converter.spec.js.map +0 -1
- package/dist/esm/register-definition.d.ts +0 -9
- package/dist/esm/register-definition.js +0 -2
- package/dist/esm/register-definition.js.map +0 -1
- package/dist/esm/register-id.d.ts +0 -1
- package/dist/esm/register-id.js +0 -2
- package/dist/esm/register-id.js.map +0 -1
- package/dist/esm/register-library.d.ts +0 -11
- package/dist/esm/register-library.js +0 -39
- package/dist/esm/register-library.js.map +0 -1
- package/dist/esm/register-library.spec.d.ts +0 -1
- package/dist/esm/register-library.spec.js +0 -28
- package/dist/esm/register-library.spec.js.map +0 -1
- package/dist/esm/register-pack.d.ts +0 -4
- package/dist/esm/register-pack.js +0 -2
- package/dist/esm/register-pack.js.map +0 -1
- package/dist/esm/unit-id.d.ts +0 -2
- package/dist/esm/unit-id.js +0 -11
- package/dist/esm/unit-id.js.map +0 -1
- package/src/register-converter.spec.ts +0 -31
- package/src/register-converter.ts +0 -48
- package/tsconfig.cjs.json +0 -9
package/src/register-id.ts
CHANGED
|
@@ -1,191 +1,197 @@
|
|
|
1
|
-
export type RegisterId =
|
|
2
|
-
"none" |
|
|
3
|
-
|
|
4
|
-
"heatEnergy" |
|
|
5
|
-
"diffHeatEnergy" |
|
|
6
|
-
|
|
7
|
-
"heatEnergyVolumeInInlet" |
|
|
8
|
-
"diffHeatEnergyVolumeInInlet" |
|
|
9
|
-
|
|
10
|
-
"heatEnergyVolumeInOutlet" |
|
|
11
|
-
"diffHeatEnergyVolumeInOutlet" |
|
|
12
|
-
|
|
13
|
-
"coolingEnergy" |
|
|
14
|
-
"diffCoolingEnergy" |
|
|
15
|
-
|
|
16
|
-
"coolingEnergyVolumeInInlet" |
|
|
17
|
-
"diffCoolingEnergyVolumeInInlet" |
|
|
18
|
-
|
|
19
|
-
"coolingEnergyVolumeInOutlet" |
|
|
20
|
-
"diffCoolingEnergyVolumeInOutlet" |
|
|
21
|
-
|
|
22
|
-
"electricalEnergy" |
|
|
23
|
-
"diffElectricalEnergy" |
|
|
24
|
-
|
|
25
|
-
"reactiveEnergy" |
|
|
26
|
-
"diffReactiveEnergy" |
|
|
27
|
-
|
|
28
|
-
"volume" |
|
|
29
|
-
"diffVolume" |
|
|
30
|
-
|
|
31
|
-
"inletVolume" |
|
|
32
|
-
"diffInletVolume" |
|
|
33
|
-
|
|
34
|
-
"outletVolume" |
|
|
35
|
-
"diffOutletVolume" |
|
|
36
|
-
|
|
37
|
-
"pulseInputAVolume" |
|
|
38
|
-
"diffPulseInputAVolume" |
|
|
39
|
-
|
|
40
|
-
"pulseInputBVolume" |
|
|
41
|
-
"diffPulseInputBVolume" |
|
|
42
|
-
|
|
43
|
-
"mass" |
|
|
44
|
-
"diffMass" |
|
|
45
|
-
|
|
46
|
-
"inletMass" |
|
|
47
|
-
"diffInletMass" |
|
|
48
|
-
|
|
49
|
-
"outletMass" |
|
|
50
|
-
"diffOutletMass" |
|
|
51
|
-
|
|
52
|
-
"power" |
|
|
53
|
-
"maxPower" |
|
|
54
|
-
"minPower" |
|
|
55
|
-
"avgPower" |
|
|
56
|
-
|
|
57
|
-
"inletPower" |
|
|
58
|
-
"maxInletPower" |
|
|
59
|
-
"minInletPower" |
|
|
60
|
-
"avgInletPower" |
|
|
61
|
-
|
|
62
|
-
"outletPower" |
|
|
63
|
-
"maxOutletPower" |
|
|
64
|
-
"minOutletPower" |
|
|
65
|
-
"avgOutletPower" |
|
|
66
|
-
|
|
67
|
-
"volumeFlow" |
|
|
68
|
-
"maxVolumeFlow" |
|
|
69
|
-
"minVolumeFlow" |
|
|
70
|
-
"avgVolumeFlow" |
|
|
71
|
-
|
|
72
|
-
"inletVolumeFlow" |
|
|
73
|
-
"maxInletVolumeFlow" |
|
|
74
|
-
"minInletVolumeFlow" |
|
|
75
|
-
"avgInletVolumeFlow" |
|
|
76
|
-
|
|
77
|
-
"outletVolumeFlow" |
|
|
78
|
-
"maxOutletVolumeFlow" |
|
|
79
|
-
"minOutletVolumeFlow" |
|
|
80
|
-
"avgOutletVolumeFlow" |
|
|
81
|
-
|
|
82
|
-
"massFlow" |
|
|
83
|
-
"maxMassFlow" |
|
|
84
|
-
"minMassFlow" |
|
|
85
|
-
"avgMassFlow" |
|
|
86
|
-
|
|
87
|
-
"inletMassFlow" |
|
|
88
|
-
"maxInletMassFlow" |
|
|
89
|
-
"minInletMassFlow" |
|
|
90
|
-
"avgInletMassFlow" |
|
|
91
|
-
|
|
92
|
-
"outletMassFlow" |
|
|
93
|
-
"maxOutletMassFlow" |
|
|
94
|
-
"minOutletMassFlow" |
|
|
95
|
-
"avgOutletMassFlow" |
|
|
96
|
-
|
|
97
|
-
"flowTemperature" |
|
|
98
|
-
"maxFlowTemperature" |
|
|
99
|
-
"minFlowTemperature" |
|
|
100
|
-
"avgFlowTemperature" |
|
|
101
|
-
|
|
102
|
-
"inletFlowTemperature" |
|
|
103
|
-
"maxInletFlowTemperature" |
|
|
104
|
-
"minInletFlowTemperature" |
|
|
105
|
-
"avgInletFlowTemperature" |
|
|
106
|
-
|
|
107
|
-
"outletFlowTemperature" |
|
|
108
|
-
"maxOutletFlowTemperature" |
|
|
109
|
-
"minOutletFlowTemperature" |
|
|
110
|
-
"avgOutletFlowTemperature" |
|
|
111
|
-
|
|
112
|
-
"inletMinusOutletFlowTemperatureDifference" |
|
|
113
|
-
"maxInletMinusOutletFlowTemperatureDifference" |
|
|
114
|
-
"minInletMinusOutletFlowTemperatureDifference" |
|
|
115
|
-
"avgInletMinusOutletFlowTemperatureDifference" |
|
|
116
|
-
|
|
117
|
-
"outletMinusInletFlowTemperatureDifference" |
|
|
118
|
-
"maxOutletMinusInletFlowTemperatureDifference" |
|
|
119
|
-
"minOutletMinusInletFlowTemperatureDifference" |
|
|
120
|
-
"avgOutletMinusInletFlowTemperatureDifference" |
|
|
121
|
-
|
|
122
|
-
"ambientTemperature" |
|
|
123
|
-
"maxAmbientTemperature" |
|
|
124
|
-
"minAmbientTemperature" |
|
|
125
|
-
"avgAmbientTemperature" |
|
|
126
|
-
|
|
127
|
-
"radiatorTemperature" |
|
|
128
|
-
"maxRadiatorTemperature" |
|
|
129
|
-
"minRadiatorTemperature" |
|
|
130
|
-
"avgRadiatorTemperature" |
|
|
131
|
-
|
|
132
|
-
"relativeHumidity" |
|
|
133
|
-
|
|
134
|
-
"kamstrupE8Inlet" |
|
|
135
|
-
"diffKamstrupE8Inlet" |
|
|
136
|
-
"kamstrupE9Outlet" |
|
|
137
|
-
"diffKamstrupE9Outlet" |
|
|
138
|
-
|
|
139
|
-
"operatingTime" |
|
|
140
|
-
"diffOperatingTime" |
|
|
141
|
-
|
|
142
|
-
"remainingBatteryTime" |
|
|
143
|
-
"diffRemainingBatteryTime" |
|
|
144
|
-
|
|
145
|
-
"deviceDate" |
|
|
146
|
-
"deviceTime" |
|
|
147
|
-
"deviceDateTime" |
|
|
148
|
-
|
|
149
|
-
"timeSinceLastExactOverhearingArrived" |
|
|
150
|
-
"timeAtLastExactOverhearingArrived" |
|
|
151
|
-
|
|
152
|
-
"timeSinceLastPossibleCandidateOverhearingArrived" |
|
|
153
|
-
"timeAtLastPossibleCandidateOverhearingArrived" |
|
|
154
|
-
|
|
155
|
-
"timeSinceLastSampled" |
|
|
156
|
-
"timeAtLastSampled" |
|
|
157
|
-
|
|
158
|
-
"timeSinceLastInstallationMounted" |
|
|
159
|
-
"timeAtLastInstallationMounted" |
|
|
160
|
-
|
|
161
|
-
"basetime" |
|
|
162
|
-
|
|
163
|
-
"
|
|
164
|
-
"
|
|
165
|
-
"
|
|
166
|
-
"
|
|
167
|
-
|
|
168
|
-
"
|
|
169
|
-
"
|
|
170
|
-
"
|
|
171
|
-
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
"
|
|
175
|
-
"
|
|
176
|
-
|
|
177
|
-
"
|
|
178
|
-
"
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
"
|
|
182
|
-
"
|
|
183
|
-
|
|
184
|
-
"
|
|
185
|
-
"
|
|
186
|
-
|
|
187
|
-
"
|
|
188
|
-
"
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
"
|
|
1
|
+
export type RegisterId =
|
|
2
|
+
"none" |
|
|
3
|
+
|
|
4
|
+
"heatEnergy" |
|
|
5
|
+
"diffHeatEnergy" |
|
|
6
|
+
|
|
7
|
+
"heatEnergyVolumeInInlet" |
|
|
8
|
+
"diffHeatEnergyVolumeInInlet" |
|
|
9
|
+
|
|
10
|
+
"heatEnergyVolumeInOutlet" |
|
|
11
|
+
"diffHeatEnergyVolumeInOutlet" |
|
|
12
|
+
|
|
13
|
+
"coolingEnergy" |
|
|
14
|
+
"diffCoolingEnergy" |
|
|
15
|
+
|
|
16
|
+
"coolingEnergyVolumeInInlet" |
|
|
17
|
+
"diffCoolingEnergyVolumeInInlet" |
|
|
18
|
+
|
|
19
|
+
"coolingEnergyVolumeInOutlet" |
|
|
20
|
+
"diffCoolingEnergyVolumeInOutlet" |
|
|
21
|
+
|
|
22
|
+
"electricalEnergy" |
|
|
23
|
+
"diffElectricalEnergy" |
|
|
24
|
+
|
|
25
|
+
"reactiveEnergy" |
|
|
26
|
+
"diffReactiveEnergy" |
|
|
27
|
+
|
|
28
|
+
"volume" |
|
|
29
|
+
"diffVolume" |
|
|
30
|
+
|
|
31
|
+
"inletVolume" |
|
|
32
|
+
"diffInletVolume" |
|
|
33
|
+
|
|
34
|
+
"outletVolume" |
|
|
35
|
+
"diffOutletVolume" |
|
|
36
|
+
|
|
37
|
+
"pulseInputAVolume" |
|
|
38
|
+
"diffPulseInputAVolume" |
|
|
39
|
+
|
|
40
|
+
"pulseInputBVolume" |
|
|
41
|
+
"diffPulseInputBVolume" |
|
|
42
|
+
|
|
43
|
+
"mass" |
|
|
44
|
+
"diffMass" |
|
|
45
|
+
|
|
46
|
+
"inletMass" |
|
|
47
|
+
"diffInletMass" |
|
|
48
|
+
|
|
49
|
+
"outletMass" |
|
|
50
|
+
"diffOutletMass" |
|
|
51
|
+
|
|
52
|
+
"power" |
|
|
53
|
+
"maxPower" |
|
|
54
|
+
"minPower" |
|
|
55
|
+
"avgPower" |
|
|
56
|
+
|
|
57
|
+
"inletPower" |
|
|
58
|
+
"maxInletPower" |
|
|
59
|
+
"minInletPower" |
|
|
60
|
+
"avgInletPower" |
|
|
61
|
+
|
|
62
|
+
"outletPower" |
|
|
63
|
+
"maxOutletPower" |
|
|
64
|
+
"minOutletPower" |
|
|
65
|
+
"avgOutletPower" |
|
|
66
|
+
|
|
67
|
+
"volumeFlow" |
|
|
68
|
+
"maxVolumeFlow" |
|
|
69
|
+
"minVolumeFlow" |
|
|
70
|
+
"avgVolumeFlow" |
|
|
71
|
+
|
|
72
|
+
"inletVolumeFlow" |
|
|
73
|
+
"maxInletVolumeFlow" |
|
|
74
|
+
"minInletVolumeFlow" |
|
|
75
|
+
"avgInletVolumeFlow" |
|
|
76
|
+
|
|
77
|
+
"outletVolumeFlow" |
|
|
78
|
+
"maxOutletVolumeFlow" |
|
|
79
|
+
"minOutletVolumeFlow" |
|
|
80
|
+
"avgOutletVolumeFlow" |
|
|
81
|
+
|
|
82
|
+
"massFlow" |
|
|
83
|
+
"maxMassFlow" |
|
|
84
|
+
"minMassFlow" |
|
|
85
|
+
"avgMassFlow" |
|
|
86
|
+
|
|
87
|
+
"inletMassFlow" |
|
|
88
|
+
"maxInletMassFlow" |
|
|
89
|
+
"minInletMassFlow" |
|
|
90
|
+
"avgInletMassFlow" |
|
|
91
|
+
|
|
92
|
+
"outletMassFlow" |
|
|
93
|
+
"maxOutletMassFlow" |
|
|
94
|
+
"minOutletMassFlow" |
|
|
95
|
+
"avgOutletMassFlow" |
|
|
96
|
+
|
|
97
|
+
"flowTemperature" |
|
|
98
|
+
"maxFlowTemperature" |
|
|
99
|
+
"minFlowTemperature" |
|
|
100
|
+
"avgFlowTemperature" |
|
|
101
|
+
|
|
102
|
+
"inletFlowTemperature" |
|
|
103
|
+
"maxInletFlowTemperature" |
|
|
104
|
+
"minInletFlowTemperature" |
|
|
105
|
+
"avgInletFlowTemperature" |
|
|
106
|
+
|
|
107
|
+
"outletFlowTemperature" |
|
|
108
|
+
"maxOutletFlowTemperature" |
|
|
109
|
+
"minOutletFlowTemperature" |
|
|
110
|
+
"avgOutletFlowTemperature" |
|
|
111
|
+
|
|
112
|
+
"inletMinusOutletFlowTemperatureDifference" |
|
|
113
|
+
"maxInletMinusOutletFlowTemperatureDifference" |
|
|
114
|
+
"minInletMinusOutletFlowTemperatureDifference" |
|
|
115
|
+
"avgInletMinusOutletFlowTemperatureDifference" |
|
|
116
|
+
|
|
117
|
+
"outletMinusInletFlowTemperatureDifference" |
|
|
118
|
+
"maxOutletMinusInletFlowTemperatureDifference" |
|
|
119
|
+
"minOutletMinusInletFlowTemperatureDifference" |
|
|
120
|
+
"avgOutletMinusInletFlowTemperatureDifference" |
|
|
121
|
+
|
|
122
|
+
"ambientTemperature" |
|
|
123
|
+
"maxAmbientTemperature" |
|
|
124
|
+
"minAmbientTemperature" |
|
|
125
|
+
"avgAmbientTemperature" |
|
|
126
|
+
|
|
127
|
+
"radiatorTemperature" |
|
|
128
|
+
"maxRadiatorTemperature" |
|
|
129
|
+
"minRadiatorTemperature" |
|
|
130
|
+
"avgRadiatorTemperature" |
|
|
131
|
+
|
|
132
|
+
"relativeHumidity" |
|
|
133
|
+
|
|
134
|
+
"kamstrupE8Inlet" |
|
|
135
|
+
"diffKamstrupE8Inlet" |
|
|
136
|
+
"kamstrupE9Outlet" |
|
|
137
|
+
"diffKamstrupE9Outlet" |
|
|
138
|
+
|
|
139
|
+
"operatingTime" |
|
|
140
|
+
"diffOperatingTime" |
|
|
141
|
+
|
|
142
|
+
"remainingBatteryTime" |
|
|
143
|
+
"diffRemainingBatteryTime" |
|
|
144
|
+
|
|
145
|
+
"deviceDate" |
|
|
146
|
+
"deviceTime" |
|
|
147
|
+
"deviceDateTime" |
|
|
148
|
+
|
|
149
|
+
"timeSinceLastExactOverhearingArrived" |
|
|
150
|
+
"timeAtLastExactOverhearingArrived" |
|
|
151
|
+
|
|
152
|
+
"timeSinceLastPossibleCandidateOverhearingArrived" |
|
|
153
|
+
"timeAtLastPossibleCandidateOverhearingArrived" |
|
|
154
|
+
|
|
155
|
+
"timeSinceLastSampled" |
|
|
156
|
+
"timeAtLastSampled" |
|
|
157
|
+
|
|
158
|
+
"timeSinceLastInstallationMounted" |
|
|
159
|
+
"timeAtLastInstallationMounted" |
|
|
160
|
+
|
|
161
|
+
"basetime" |
|
|
162
|
+
"instantTime" |
|
|
163
|
+
"periodStartTime" |
|
|
164
|
+
"periodEndTime" |
|
|
165
|
+
"instantOrPeriodStartTime" |
|
|
166
|
+
"instantOrPeriodEndTime" |
|
|
167
|
+
|
|
168
|
+
"device" |
|
|
169
|
+
"wMBusDeviceAddresses" |
|
|
170
|
+
"kamdraftDeviceAddresses" |
|
|
171
|
+
"tchlrDeviceAddresses" |
|
|
172
|
+
"kamdaDeviceAddresses" |
|
|
173
|
+
"msisdnDeviceAddresses" |
|
|
174
|
+
"deviceRegisters" |
|
|
175
|
+
"consumptionZone" |
|
|
176
|
+
|
|
177
|
+
"mBusFormatStringSignature" |
|
|
178
|
+
"deviceSoftwareVersion" |
|
|
179
|
+
|
|
180
|
+
"kamstrupMulticalInfocodeType1" |
|
|
181
|
+
"kamstrupMulticalInfocodeType2" |
|
|
182
|
+
"kamstrupMulticalInfocodeType3" |
|
|
183
|
+
"kamstrupMulticalInfocodeType4" |
|
|
184
|
+
"kamstrupMulticalInfocode" |
|
|
185
|
+
"kamstrupModuleType" |
|
|
186
|
+
|
|
187
|
+
"diehlInfocodeType1" |
|
|
188
|
+
"diehlInfocode" |
|
|
189
|
+
|
|
190
|
+
"landisGyrMBusStatusType1" |
|
|
191
|
+
"landisGyrMBusStatusType2" |
|
|
192
|
+
"landisGyrMBusStatus" |
|
|
193
|
+
"landisGyrInfocodeType1" |
|
|
194
|
+
"landisGyrInfocodeType2" |
|
|
195
|
+
"landisGyrInfocode" |
|
|
196
|
+
|
|
197
|
+
"infocode";
|
|
@@ -1,33 +1,41 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { RegisterDefinition } from ".";
|
|
3
|
-
import { RegisterLibrary } from "./register-library";
|
|
4
|
-
|
|
5
|
-
const volume: RegisterDefinition = {
|
|
6
|
-
id: "volume",
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { RegisterDefinition } from ".";
|
|
3
|
+
import { RegisterLibrary } from "./register-library";
|
|
4
|
+
|
|
5
|
+
const volume: RegisterDefinition = {
|
|
6
|
+
id: "volume",
|
|
7
|
+
measure: "volume",
|
|
8
|
+
aggregate: "instant",
|
|
9
|
+
units: ["cubicMeter"]
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
describe("library", () => {
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
RegisterLibrary.reset();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should get added definition", () => {
|
|
18
|
+
RegisterLibrary.add(volume);
|
|
19
|
+
const definition = RegisterLibrary.get("volume");
|
|
20
|
+
expect(definition.id).to.equal("volume");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should add all definitions in pack", () => {
|
|
24
|
+
RegisterLibrary.add({
|
|
25
|
+
someRandomKey: volume
|
|
26
|
+
});
|
|
27
|
+
const definition = RegisterLibrary.get("volume");
|
|
28
|
+
expect(definition.id).to.equal("volume");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should throw when getting not added register", () => {
|
|
32
|
+
expect(() => RegisterLibrary.get("volume")).to.throw();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should return all definitions when invoking all()", () => {
|
|
36
|
+
RegisterLibrary.add(volume);
|
|
37
|
+
RegisterLibrary.add(volume); // Only added once.
|
|
38
|
+
const all = RegisterLibrary.all();
|
|
39
|
+
expect(all.length).to.equal(1);
|
|
40
|
+
})
|
|
41
|
+
});
|
package/src/register-library.ts
CHANGED
|
@@ -1,37 +1,57 @@
|
|
|
1
|
-
import { RegisterDefinition } from "./register-definition";
|
|
2
|
-
import { RegisterId } from "./register-id";
|
|
3
|
-
import { RegisterPack } from "./register-pack";
|
|
4
|
-
|
|
5
|
-
class Library {
|
|
6
|
-
private definitions: Partial<{ [id in RegisterId]: RegisterDefinition }> = {};
|
|
7
|
-
public add(...definitions: (RegisterDefinition | RegisterPack)[]) {
|
|
8
|
-
for (const definition of definitions) {
|
|
9
|
-
if (isDefinition(definition)) {
|
|
10
|
-
this.
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
for (const definitionInPack of Object.values(definition)) {
|
|
14
|
-
this.
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public
|
|
29
|
-
this.definitions
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
import { RegisterDefinition } from "./register-definition";
|
|
2
|
+
import { RegisterId } from "./register-id";
|
|
3
|
+
import { RegisterPack } from "./register-pack";
|
|
4
|
+
|
|
5
|
+
class Library {
|
|
6
|
+
private definitions: Partial<{ [id in RegisterId]: RegisterDefinition }> = {};
|
|
7
|
+
public add(...definitions: (RegisterDefinition | RegisterPack)[]) {
|
|
8
|
+
for (const definition of definitions) {
|
|
9
|
+
if (isDefinition(definition)) {
|
|
10
|
+
this.tryAdd(definition);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
for (const definitionInPack of Object.values(definition)) {
|
|
14
|
+
this.tryAdd(definitionInPack);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private tryAdd(definition: RegisterDefinition) {
|
|
21
|
+
if (!this.definitions[definition.id]) {
|
|
22
|
+
this.definitions[definition.id] = definition;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public has(id: RegisterId) {
|
|
29
|
+
return !!this.definitions[id];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public tryGet(id: RegisterId) {
|
|
33
|
+
return this.definitions[id];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public get(id: RegisterId) {
|
|
37
|
+
const definition = this.definitions[id];
|
|
38
|
+
if (!definition) {
|
|
39
|
+
throw new Error(`Defintion was not loaded for register ${id}`);
|
|
40
|
+
}
|
|
41
|
+
return definition;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public all() {
|
|
45
|
+
return Object.values(this.definitions).map(x => x!);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public reset() {
|
|
49
|
+
this.definitions = {};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function isDefinition(definitionOrPack: RegisterDefinition | RegisterPack): definitionOrPack is RegisterDefinition {
|
|
54
|
+
return !!(definitionOrPack.id && definitionOrPack.aggregate && definitionOrPack.units);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const RegisterLibrary = new Library();
|
package/src/register-pack.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RegisterDefinition } from "./register-definition";
|
|
2
|
-
|
|
3
|
-
export interface RegisterPack {
|
|
4
|
-
[key: string]: RegisterDefinition;
|
|
5
|
-
}
|
|
1
|
+
import { RegisterDefinition } from "./register-definition";
|
|
2
|
+
|
|
3
|
+
export interface RegisterPack {
|
|
4
|
+
[key: string]: RegisterDefinition;
|
|
5
|
+
}
|
|
@@ -0,0 +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
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// This is clearly not correct but it provides some amazing type safety
|
|
2
|
+
export type Repository = "some/repo";
|
|
3
|
+
|
|
4
|
+
export function Repository(repo: string): Repository;
|
|
5
|
+
export function Repository(team: string, name: string): Repository;
|
|
6
|
+
export function Repository(repoOrTeam: string, name?: string): Repository {
|
|
7
|
+
if (name) {
|
|
8
|
+
return <Repository>`${repoOrTeam}/${name}`;
|
|
9
|
+
} else if (repoOrTeam.indexOf("/") > 0) {
|
|
10
|
+
return <Repository>repoOrTeam;
|
|
11
|
+
} else {
|
|
12
|
+
throw new TypeError("Invalid repository format");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export namespace Repository {
|
|
17
|
+
export function split(repo: Repository) {
|
|
18
|
+
const parts = repo.split("/");
|
|
19
|
+
return {
|
|
20
|
+
team: parts[0],
|
|
21
|
+
name: parts[1],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
package/src/step.spec.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
|
+
import { DayOfWeek, Step } from "./step";
|
|
4
|
+
|
|
5
|
+
describe("startOf", () => {
|
|
6
|
+
it("returns start of day", () => {
|
|
7
|
+
const dt = DateTime.fromISO("2020-01-11T05:00:00+01:00");
|
|
8
|
+
const result = Step.startOf(dt, "day");
|
|
9
|
+
expect(+result).to.equal(+DateTime.fromISO("2020-01-11T00:00:00+01:00"));
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("returns previous monday from saturday", () => {
|
|
13
|
+
const dt = DateTime.fromISO("2020-01-11T05:00:00+01:00");
|
|
14
|
+
const result = Step.startOf(dt, "week", DayOfWeek.Monday);
|
|
15
|
+
expect(+result).to.equal(+DateTime.fromISO("2020-01-06T00:00:00+01:00"));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("returns same monday from monday with hour", () => {
|
|
19
|
+
const dt = DateTime.fromISO("2020-01-13T05:00:00+01:00");
|
|
20
|
+
const result = Step.startOf(dt, "week", DayOfWeek.Monday);
|
|
21
|
+
expect(+result).to.equal(+DateTime.fromISO("2020-01-13T00:00:00+01:00"));
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe("asDuration", () => {
|
|
26
|
+
it("should return equivalent duration", () => {
|
|
27
|
+
const duration = Step.asDuration("week");
|
|
28
|
+
expect(duration.days).to.equal(7);
|
|
29
|
+
});
|
|
30
|
+
});
|