@tbiegner99/reporter 1.0.0
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/README.md +0 -0
- package/dist/src/constants.d.ts +9 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +11 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +20 -0
- package/dist/src/models/index.d.ts +2 -0
- package/dist/src/models/index.d.ts.map +1 -0
- package/dist/src/models/index.js +17 -0
- package/dist/src/models/measures/index.d.ts +9 -0
- package/dist/src/models/measures/index.d.ts.map +1 -0
- package/dist/src/models/measures/index.js +24 -0
- package/dist/src/models/measures/unit.d.ts +25 -0
- package/dist/src/models/measures/unit.d.ts.map +1 -0
- package/dist/src/models/measures/unit.js +51 -0
- package/dist/src/models/measures/units/direction.d.ts +20 -0
- package/dist/src/models/measures/units/direction.d.ts.map +1 -0
- package/dist/src/models/measures/units/direction.js +105 -0
- package/dist/src/models/measures/units/distance.d.ts +26 -0
- package/dist/src/models/measures/units/distance.d.ts.map +1 -0
- package/dist/src/models/measures/units/distance.js +60 -0
- package/dist/src/models/measures/units/percent.d.ts +18 -0
- package/dist/src/models/measures/units/percent.d.ts.map +1 -0
- package/dist/src/models/measures/units/percent.js +48 -0
- package/dist/src/models/measures/units/pressure.d.ts +25 -0
- package/dist/src/models/measures/units/pressure.d.ts.map +1 -0
- package/dist/src/models/measures/units/pressure.js +62 -0
- package/dist/src/models/measures/units/speed.d.ts +19 -0
- package/dist/src/models/measures/units/speed.d.ts.map +1 -0
- package/dist/src/models/measures/units/speed.js +64 -0
- package/dist/src/models/measures/units/temperature.d.ts +17 -0
- package/dist/src/models/measures/units/temperature.d.ts.map +1 -0
- package/dist/src/models/measures/units/temperature.js +56 -0
- package/dist/src/models/measures/units/time.d.ts +19 -0
- package/dist/src/models/measures/units/time.d.ts.map +1 -0
- package/dist/src/models/measures/units/time.js +50 -0
- package/dist/src/reading/HumidityReading.d.ts +5 -0
- package/dist/src/reading/HumidityReading.d.ts.map +1 -0
- package/dist/src/reading/HumidityReading.js +11 -0
- package/dist/src/reading/Reading.d.ts +10 -0
- package/dist/src/reading/Reading.d.ts.map +1 -0
- package/dist/src/reading/Reading.js +20 -0
- package/dist/src/reading/TemperatureReading.d.ts +6 -0
- package/dist/src/reading/TemperatureReading.d.ts.map +1 -0
- package/dist/src/reading/TemperatureReading.js +12 -0
- package/dist/src/reporter/CurrentStatusReporter.d.ts +13 -0
- package/dist/src/reporter/CurrentStatusReporter.d.ts.map +1 -0
- package/dist/src/reporter/CurrentStatusReporter.js +35 -0
- package/dist/src/reporter/DatabaseReporter.d.ts +29 -0
- package/dist/src/reporter/DatabaseReporter.d.ts.map +1 -0
- package/dist/src/reporter/DatabaseReporter.js +56 -0
- package/dist/src/reporter/KafkaReporter.d.ts +34 -0
- package/dist/src/reporter/KafkaReporter.d.ts.map +1 -0
- package/dist/src/reporter/KafkaReporter.js +86 -0
- package/dist/src/reporter/LoggerReporter.d.ts +24 -0
- package/dist/src/reporter/LoggerReporter.d.ts.map +1 -0
- package/dist/src/reporter/LoggerReporter.js +34 -0
- package/dist/src/reporter/MQTTReporter.d.ts +44 -0
- package/dist/src/reporter/MQTTReporter.d.ts.map +1 -0
- package/dist/src/reporter/MQTTReporter.js +101 -0
- package/dist/src/reporter/Reporter.d.ts +10 -0
- package/dist/src/reporter/Reporter.d.ts.map +1 -0
- package/dist/src/reporter/Reporter.js +15 -0
- package/dist/src/reporter/ReporterConfig.d.ts +136 -0
- package/dist/src/reporter/ReporterConfig.d.ts.map +1 -0
- package/dist/src/reporter/ReporterConfig.js +99 -0
- package/dist/src/reporter/ReporterFactory.d.ts +14 -0
- package/dist/src/reporter/ReporterFactory.d.ts.map +1 -0
- package/dist/src/reporter/ReporterFactory.js +74 -0
- package/dist/src/reporter/formatter/DefaultFormatter.d.ts +6 -0
- package/dist/src/reporter/formatter/DefaultFormatter.d.ts.map +1 -0
- package/dist/src/reporter/formatter/DefaultFormatter.js +12 -0
- package/dist/src/reporter/formatter/FormatterFactory.d.ts +9 -0
- package/dist/src/reporter/formatter/FormatterFactory.d.ts.map +1 -0
- package/dist/src/reporter/formatter/FormatterFactory.js +59 -0
- package/dist/src/reporter/formatter/HumidityFormatter.d.ts +7 -0
- package/dist/src/reporter/formatter/HumidityFormatter.d.ts.map +1 -0
- package/dist/src/reporter/formatter/HumidityFormatter.js +14 -0
- package/dist/src/reporter/formatter/TemperatureFormatter.d.ts +12 -0
- package/dist/src/reporter/formatter/TemperatureFormatter.d.ts.map +1 -0
- package/dist/src/reporter/formatter/TemperatureFormatter.js +20 -0
- package/dist/src/reporter/index.d.ts +5 -0
- package/dist/src/reporter/index.d.ts.map +1 -0
- package/dist/src/reporter/index.js +20 -0
- package/dist/src/service/CurrentConditionsManager.d.ts +34 -0
- package/dist/src/service/CurrentConditionsManager.d.ts.map +1 -0
- package/dist/src/service/CurrentConditionsManager.js +58 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;CAGlB,CAAC;AACF,eAAO,MAAM,YAAY;;;CAGxB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReadingTypes = exports.Timing = void 0;
|
|
4
|
+
exports.Timing = {
|
|
5
|
+
ONE_MIN: 60000,
|
|
6
|
+
FIVE_MIN: 60000 * 5,
|
|
7
|
+
};
|
|
8
|
+
exports.ReadingTypes = {
|
|
9
|
+
TEMPERATURE: 'Temperature',
|
|
10
|
+
HUMIDITY: 'Humidity',
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,oCAAoC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./reporter"), exports);
|
|
18
|
+
__exportStar(require("./models"), exports);
|
|
19
|
+
__exportStar(require("./constants"), exports);
|
|
20
|
+
__exportStar(require("./service/CurrentConditionsManager"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./measures"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './unit';
|
|
2
|
+
export * from './units/direction';
|
|
3
|
+
export * from './units/distance';
|
|
4
|
+
export * from './units/temperature';
|
|
5
|
+
export * from './units/percent';
|
|
6
|
+
export * from './units/pressure';
|
|
7
|
+
export * from './units/speed';
|
|
8
|
+
export * from './units/time';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/measures/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./unit"), exports);
|
|
18
|
+
__exportStar(require("./units/direction"), exports);
|
|
19
|
+
__exportStar(require("./units/distance"), exports);
|
|
20
|
+
__exportStar(require("./units/temperature"), exports);
|
|
21
|
+
__exportStar(require("./units/percent"), exports);
|
|
22
|
+
__exportStar(require("./units/pressure"), exports);
|
|
23
|
+
__exportStar(require("./units/speed"), exports);
|
|
24
|
+
__exportStar(require("./units/time"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface Unit<T> {
|
|
2
|
+
symbol: T;
|
|
3
|
+
convertTo(unit: Unit<T>, value: number): number;
|
|
4
|
+
toString(): string;
|
|
5
|
+
toDisplayString(): string;
|
|
6
|
+
}
|
|
7
|
+
export declare const Unitless: Unit<void>;
|
|
8
|
+
export declare class Value<T> {
|
|
9
|
+
value: number;
|
|
10
|
+
unit: Unit<T>;
|
|
11
|
+
constructor(value: number, unit: Unit<T>);
|
|
12
|
+
static fromString<T>(value: string, unit: Unit<T>): Value<T> | undefined;
|
|
13
|
+
static from<T>(value: number, unit: Unit<T>): Value<T> | undefined;
|
|
14
|
+
add(other: Value<T>): Value<T>;
|
|
15
|
+
divide(divisor: number): Value<T>;
|
|
16
|
+
convertTo(unit: Unit<T>): Value<T>;
|
|
17
|
+
toDisplayString(places?: number): string;
|
|
18
|
+
toString(): string;
|
|
19
|
+
}
|
|
20
|
+
export interface Reading<T> {
|
|
21
|
+
timestamp: Date;
|
|
22
|
+
reading: Value<T>;
|
|
23
|
+
type: string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=unit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit.d.ts","sourceRoot":"","sources":["../../../../src/models/measures/unit.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI,CAAC,CAAC;IACrB,MAAM,EAAE,CAAC,CAAC;IACV,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAChD,QAAQ,IAAI,MAAM,CAAC;IACnB,eAAe,IAAI,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,IAAI,CAW/B,CAAC;AAEF,qBAAa,KAAK,CAAC,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;gBAEF,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAKxC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS;IAMxE,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS;IAOlE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAS9B,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;IAIjC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAKlC,eAAe,CAAC,MAAM,SAAI,GAAG,MAAM;IAInC,QAAQ,IAAI,MAAM;CAGnB;AAED,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Value = exports.Unitless = void 0;
|
|
4
|
+
exports.Unitless = {
|
|
5
|
+
symbol: null,
|
|
6
|
+
convertTo(unit, value) {
|
|
7
|
+
return value;
|
|
8
|
+
},
|
|
9
|
+
toString() {
|
|
10
|
+
return '';
|
|
11
|
+
},
|
|
12
|
+
toDisplayString() {
|
|
13
|
+
return '';
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
class Value {
|
|
17
|
+
constructor(value, unit) {
|
|
18
|
+
this.value = value;
|
|
19
|
+
this.unit = unit;
|
|
20
|
+
}
|
|
21
|
+
static fromString(value, unit) {
|
|
22
|
+
const parsedValue = parseFloat(value);
|
|
23
|
+
return Value.from(parsedValue, unit);
|
|
24
|
+
}
|
|
25
|
+
static from(value, unit) {
|
|
26
|
+
if (isNaN(value)) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return new Value(value, unit);
|
|
30
|
+
}
|
|
31
|
+
add(other) {
|
|
32
|
+
if (this.unit.symbol !== other.unit.symbol) {
|
|
33
|
+
throw new Error(`Cannot add values with different units: ${this.unit.symbol} and ${other.unit.symbol}`);
|
|
34
|
+
}
|
|
35
|
+
return new Value(this.value + other.value, this.unit);
|
|
36
|
+
}
|
|
37
|
+
divide(divisor) {
|
|
38
|
+
return new Value(this.value / divisor, this.unit);
|
|
39
|
+
}
|
|
40
|
+
convertTo(unit) {
|
|
41
|
+
const newValue = this.unit.convertTo(unit, this.value);
|
|
42
|
+
return new Value(newValue, unit);
|
|
43
|
+
}
|
|
44
|
+
toDisplayString(places = 1) {
|
|
45
|
+
return `${this.value.toFixed(places)} ${this.unit.toDisplayString()}`;
|
|
46
|
+
}
|
|
47
|
+
toString() {
|
|
48
|
+
return `${this.value} ${this.unit.toString()}`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.Value = Value;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Unit, Value } from '../unit';
|
|
2
|
+
export type Direction = 'compass' | 'degrees' | 'radians';
|
|
3
|
+
export declare const CompassDirections: string[];
|
|
4
|
+
export declare class DirectionUnit implements Unit<Direction> {
|
|
5
|
+
readonly symbol: Direction;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
private readonly aliasSymbols;
|
|
8
|
+
static COMPASS: DirectionUnit;
|
|
9
|
+
static DEGREES: DirectionUnit;
|
|
10
|
+
static RADIANS: DirectionUnit;
|
|
11
|
+
static SUPPORTED_UNITS: DirectionUnit[];
|
|
12
|
+
static fromSymbol(symbol: string): Unit<Direction>;
|
|
13
|
+
static fromCompassDirection(direction: string): Value<Direction>;
|
|
14
|
+
static toCompassDirection(value?: Value<Direction>): string;
|
|
15
|
+
private constructor();
|
|
16
|
+
toDisplayString(): string;
|
|
17
|
+
toDegrees(unit: Unit<Direction>, value: number): number;
|
|
18
|
+
convertTo(unit: Unit<Direction>, value: number): number;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=direction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direction.d.ts","sourceRoot":"","sources":["../../../../../src/models/measures/units/direction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAE1D,eAAO,MAAM,iBAAiB,UAiB7B,CAAC;AAEF,qBAAa,aAAc,YAAW,IAAI,CAAC,SAAS,CAAC;aA6C7B,MAAM,EAAE,SAAS;aACjB,IAAI,EAAE,MAAM;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY;IA9CjC,MAAM,CAAC,OAAO,EAAE,aAAa,CAAmE;IAChG,MAAM,CAAC,OAAO,EAAE,aAAa,CAK1B;IACH,MAAM,CAAC,OAAO,EAAE,aAAa,CAA2C;IACxE,MAAM,CAAC,eAAe,EAAE,aAAa,EAAE,CAIrC;IAEF,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;IAUlD,MAAM,CAAC,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IAQhE,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,MAAM;IAW3D,OAAO;IAMP,eAAe,IAAI,MAAM;IAOzB,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAavD,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAgB1D"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DirectionUnit = exports.CompassDirections = void 0;
|
|
4
|
+
const unit_1 = require("../unit");
|
|
5
|
+
exports.CompassDirections = [
|
|
6
|
+
'N',
|
|
7
|
+
'NNE',
|
|
8
|
+
'NE',
|
|
9
|
+
'ENE',
|
|
10
|
+
'E',
|
|
11
|
+
'ESE',
|
|
12
|
+
'SE',
|
|
13
|
+
'SSE',
|
|
14
|
+
'S',
|
|
15
|
+
'SSW',
|
|
16
|
+
'SW',
|
|
17
|
+
'WSW',
|
|
18
|
+
'W',
|
|
19
|
+
'WNW',
|
|
20
|
+
'NW',
|
|
21
|
+
'NNW'
|
|
22
|
+
];
|
|
23
|
+
class DirectionUnit {
|
|
24
|
+
static fromSymbol(symbol) {
|
|
25
|
+
let unit = DirectionUnit.SUPPORTED_UNITS.find((u) => u.symbol === symbol || u.aliasSymbols.includes(symbol));
|
|
26
|
+
if (!unit) {
|
|
27
|
+
throw new Error(`Unsupported direction unit: ${symbol}`);
|
|
28
|
+
}
|
|
29
|
+
return unit;
|
|
30
|
+
}
|
|
31
|
+
static fromCompassDirection(direction) {
|
|
32
|
+
const index = exports.CompassDirections.indexOf(direction);
|
|
33
|
+
if (index === -1) {
|
|
34
|
+
throw new Error(`Invalid compass direction: ${direction}`);
|
|
35
|
+
}
|
|
36
|
+
return new unit_1.Value(index, DirectionUnit.COMPASS);
|
|
37
|
+
}
|
|
38
|
+
static toCompassDirection(value) {
|
|
39
|
+
if (!value) {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
if (value.unit.symbol !== 'compass') {
|
|
43
|
+
value = value.convertTo(DirectionUnit.COMPASS);
|
|
44
|
+
}
|
|
45
|
+
const index = Math.round(value.value) % exports.CompassDirections.length;
|
|
46
|
+
return exports.CompassDirections[index];
|
|
47
|
+
}
|
|
48
|
+
constructor(symbol, name, aliasSymbols = []) {
|
|
49
|
+
this.symbol = symbol;
|
|
50
|
+
this.name = name;
|
|
51
|
+
this.aliasSymbols = aliasSymbols;
|
|
52
|
+
}
|
|
53
|
+
toDisplayString() {
|
|
54
|
+
if (this.symbol === 'compass') {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
return '°';
|
|
58
|
+
}
|
|
59
|
+
toDegrees(unit, value) {
|
|
60
|
+
if (!unit || unit.symbol === 'degrees') {
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
else if (unit.symbol === 'radians') {
|
|
64
|
+
return (value * 180) / Math.PI;
|
|
65
|
+
}
|
|
66
|
+
else if (unit.symbol === 'compass') {
|
|
67
|
+
const index = value;
|
|
68
|
+
const sliceWidth = 360 / exports.CompassDirections.length;
|
|
69
|
+
return index * sliceWidth;
|
|
70
|
+
}
|
|
71
|
+
throw new Error(`Unsupported direction unit: ${unit.symbol}`);
|
|
72
|
+
}
|
|
73
|
+
convertTo(unit, value) {
|
|
74
|
+
if (!unit || unit.symbol === this.symbol) {
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
const degrees = this.toDegrees(unit, value);
|
|
78
|
+
if (unit.symbol === 'degrees') {
|
|
79
|
+
return degrees;
|
|
80
|
+
}
|
|
81
|
+
else if (unit.symbol === 'radians') {
|
|
82
|
+
return (degrees * Math.PI) / 180;
|
|
83
|
+
}
|
|
84
|
+
else if (unit.symbol === 'compass') {
|
|
85
|
+
const sliceWidth = 360 / exports.CompassDirections.length;
|
|
86
|
+
const normalizedAngle = (degrees + sliceWidth / 2) % 360;
|
|
87
|
+
return Math.floor(normalizedAngle / sliceWidth);
|
|
88
|
+
}
|
|
89
|
+
throw new Error(`Unsupported direction unit: ${unit.symbol}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.DirectionUnit = DirectionUnit;
|
|
93
|
+
DirectionUnit.COMPASS = new DirectionUnit('compass', 'Compass', [...exports.CompassDirections]);
|
|
94
|
+
DirectionUnit.DEGREES = new DirectionUnit('degrees', 'Degrees', [
|
|
95
|
+
'°',
|
|
96
|
+
'deg',
|
|
97
|
+
'degT',
|
|
98
|
+
'degree_(angle)'
|
|
99
|
+
]);
|
|
100
|
+
DirectionUnit.RADIANS = new DirectionUnit('radians', 'Radians');
|
|
101
|
+
DirectionUnit.SUPPORTED_UNITS = [
|
|
102
|
+
DirectionUnit.COMPASS,
|
|
103
|
+
DirectionUnit.DEGREES,
|
|
104
|
+
DirectionUnit.RADIANS
|
|
105
|
+
];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Unit } from '../unit';
|
|
2
|
+
export type MetricDistanceUnit = 'mm' | 'cm' | 'm' | 'km';
|
|
3
|
+
export type ImperialDistanceUnit = 'in' | 'ft' | 'yd' | 'mi' | 'nmi';
|
|
4
|
+
export type Distance = MetricDistanceUnit | ImperialDistanceUnit;
|
|
5
|
+
export declare class DistanceUnit implements Unit<Distance> {
|
|
6
|
+
readonly symbol: Distance;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
private readonly toMetersFactor;
|
|
9
|
+
private readonly aliasSymbols;
|
|
10
|
+
static MILLIMETER: DistanceUnit;
|
|
11
|
+
static CENTIMETER: DistanceUnit;
|
|
12
|
+
static METER: DistanceUnit;
|
|
13
|
+
static KILOMETER: DistanceUnit;
|
|
14
|
+
static INCH: DistanceUnit;
|
|
15
|
+
static FOOT: DistanceUnit;
|
|
16
|
+
static YARD: DistanceUnit;
|
|
17
|
+
static MILE: DistanceUnit;
|
|
18
|
+
static NAUTICAL_MILE: DistanceUnit;
|
|
19
|
+
static SUPPORTED_UNITS: DistanceUnit[];
|
|
20
|
+
static fromSymbol(symbol: string): Unit<Distance>;
|
|
21
|
+
private constructor();
|
|
22
|
+
toDisplayString(): string;
|
|
23
|
+
toMeters(unit: Unit<Distance>, value: number): number;
|
|
24
|
+
convertTo(unit: Unit<Distance>, value: number): number;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=distance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distance.d.ts","sourceRoot":"","sources":["../../../../../src/models/measures/units/distance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,MAAM,kBAAkB,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC;AAC1D,MAAM,MAAM,oBAAoB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AACrE,MAAM,MAAM,QAAQ,GAAG,kBAAkB,GAAG,oBAAoB,CAAC;AAEjE,qBAAa,YAAa,YAAW,IAAI,CAAC,QAAQ,CAAC;aAiC3B,MAAM,EAAE,QAAQ;aAChB,IAAI,EAAE,MAAM;IAC5B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAnCjC,MAAM,CAAC,UAAU,EAAE,YAAY,CAA+C;IAC9E,MAAM,CAAC,UAAU,EAAE,YAAY,CAA8C;IAC7E,MAAM,CAAC,KAAK,EAAE,YAAY,CAAqC;IAC/D,MAAM,CAAC,SAAS,EAAE,YAAY,CAA6C;IAC3E,MAAM,CAAC,IAAI,EAAE,YAAY,CAA0C;IACnE,MAAM,CAAC,IAAI,EAAE,YAAY,CAA0C;IACnE,MAAM,CAAC,IAAI,EAAE,YAAY,CAA0C;IACnE,MAAM,CAAC,IAAI,EAAE,YAAY,CAA2C;IACpE,MAAM,CAAC,aAAa,EAAE,YAAY,CAAkD;IACpF,MAAM,CAAC,eAAe,EAAE,YAAY,EAAE,CAUpC;IAEF,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;IAUjD,OAAO;IAMP,eAAe,IAAI,MAAM;IAIzB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAQrD,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAWzD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DistanceUnit = void 0;
|
|
4
|
+
class DistanceUnit {
|
|
5
|
+
static fromSymbol(symbol) {
|
|
6
|
+
let unit = DistanceUnit.SUPPORTED_UNITS.find((u) => u.symbol === symbol || u.aliasSymbols.includes(symbol));
|
|
7
|
+
if (!unit) {
|
|
8
|
+
throw new Error(`Unsupported distance unit: ${symbol}`);
|
|
9
|
+
}
|
|
10
|
+
return unit;
|
|
11
|
+
}
|
|
12
|
+
constructor(symbol, name, toMetersFactor, aliasSymbols = []) {
|
|
13
|
+
this.symbol = symbol;
|
|
14
|
+
this.name = name;
|
|
15
|
+
this.toMetersFactor = toMetersFactor;
|
|
16
|
+
this.aliasSymbols = aliasSymbols;
|
|
17
|
+
}
|
|
18
|
+
toDisplayString() {
|
|
19
|
+
return this.symbol;
|
|
20
|
+
}
|
|
21
|
+
toMeters(unit, value) {
|
|
22
|
+
const targetUnit = DistanceUnit.SUPPORTED_UNITS.find((u) => u.symbol === unit.symbol);
|
|
23
|
+
if (!targetUnit) {
|
|
24
|
+
throw new Error(`Unsupported distance unit: ${unit.symbol}`);
|
|
25
|
+
}
|
|
26
|
+
return value * targetUnit.toMetersFactor;
|
|
27
|
+
}
|
|
28
|
+
convertTo(unit, value) {
|
|
29
|
+
if (!unit || unit.symbol === this.symbol) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
const meters = this.toMeters(this, value);
|
|
33
|
+
const targetUnit = DistanceUnit.SUPPORTED_UNITS.find((u) => u.symbol === unit.symbol);
|
|
34
|
+
if (!targetUnit) {
|
|
35
|
+
throw new Error(`Unsupported distance unit: ${unit.symbol}`);
|
|
36
|
+
}
|
|
37
|
+
return meters / targetUnit.toMetersFactor;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.DistanceUnit = DistanceUnit;
|
|
41
|
+
DistanceUnit.MILLIMETER = new DistanceUnit('mm', 'Millimeter', 0.001);
|
|
42
|
+
DistanceUnit.CENTIMETER = new DistanceUnit('cm', 'Centimeter', 0.01);
|
|
43
|
+
DistanceUnit.METER = new DistanceUnit('m', 'Meter', 1);
|
|
44
|
+
DistanceUnit.KILOMETER = new DistanceUnit('km', 'Kilometer', 1000);
|
|
45
|
+
DistanceUnit.INCH = new DistanceUnit('in', 'Inch', 0.0254);
|
|
46
|
+
DistanceUnit.FOOT = new DistanceUnit('ft', 'Foot', 0.3048);
|
|
47
|
+
DistanceUnit.YARD = new DistanceUnit('yd', 'Yard', 0.9144);
|
|
48
|
+
DistanceUnit.MILE = new DistanceUnit('mi', 'Mile', 1609.34);
|
|
49
|
+
DistanceUnit.NAUTICAL_MILE = new DistanceUnit('nmi', 'Nautical Mile', 1852);
|
|
50
|
+
DistanceUnit.SUPPORTED_UNITS = [
|
|
51
|
+
DistanceUnit.MILLIMETER,
|
|
52
|
+
DistanceUnit.CENTIMETER,
|
|
53
|
+
DistanceUnit.METER,
|
|
54
|
+
DistanceUnit.KILOMETER,
|
|
55
|
+
DistanceUnit.INCH,
|
|
56
|
+
DistanceUnit.FOOT,
|
|
57
|
+
DistanceUnit.YARD,
|
|
58
|
+
DistanceUnit.MILE,
|
|
59
|
+
DistanceUnit.NAUTICAL_MILE
|
|
60
|
+
];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Unit } from '../unit';
|
|
2
|
+
export type Percent = '%' | '‰' | '';
|
|
3
|
+
export declare class PercentUnit implements Unit<Percent> {
|
|
4
|
+
readonly symbol: Percent;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
private readonly toDecimalFactor;
|
|
7
|
+
private readonly aliasSymbols;
|
|
8
|
+
static readonly PERCENT: PercentUnit;
|
|
9
|
+
static readonly PERMILLE: PercentUnit;
|
|
10
|
+
static readonly DECIMAL: PercentUnit;
|
|
11
|
+
static readonly SUPPORTED_UNITS: PercentUnit[];
|
|
12
|
+
static fromSymbol(symbol: string): Unit<Percent>;
|
|
13
|
+
private constructor();
|
|
14
|
+
toDisplayString(): string;
|
|
15
|
+
toDecimal(unit: Unit<Percent>, value: number): number;
|
|
16
|
+
convertTo(unit: Unit<Percent>, value: number): number;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=percent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"percent.d.ts","sourceRoot":"","sources":["../../../../../src/models/measures/units/percent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,MAAM,OAAO,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC;AAErC,qBAAa,WAAY,YAAW,IAAI,CAAC,OAAO,CAAC;aAqBzB,MAAM,EAAE,OAAO;aACf,IAAI,EAAE,MAAM;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAvBjC,MAAM,CAAC,QAAQ,CAAC,OAAO,cAA6D;IACpF,MAAM,CAAC,QAAQ,CAAC,QAAQ,cAA+C;IACvE,MAAM,CAAC,QAAQ,CAAC,OAAO,cAA0C;IACjE,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,WAAW,EAAE,CAI5C;IAEF,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;IAUhD,OAAO;IAOP,eAAe,IAAI,MAAM;IAIzB,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAQrD,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAWxD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PercentUnit = void 0;
|
|
4
|
+
class PercentUnit {
|
|
5
|
+
static fromSymbol(symbol) {
|
|
6
|
+
let unit = PercentUnit.SUPPORTED_UNITS.find((u) => u.symbol === symbol || u.aliasSymbols.includes(symbol));
|
|
7
|
+
if (!unit) {
|
|
8
|
+
throw new Error(`Unsupported percent unit: ${symbol}`);
|
|
9
|
+
}
|
|
10
|
+
return unit;
|
|
11
|
+
}
|
|
12
|
+
constructor(symbol, name, toDecimalFactor, aliasSymbols) {
|
|
13
|
+
this.symbol = symbol;
|
|
14
|
+
this.name = name;
|
|
15
|
+
this.toDecimalFactor = toDecimalFactor;
|
|
16
|
+
this.aliasSymbols = aliasSymbols;
|
|
17
|
+
}
|
|
18
|
+
toDisplayString() {
|
|
19
|
+
return this.symbol;
|
|
20
|
+
}
|
|
21
|
+
toDecimal(unit, value) {
|
|
22
|
+
const targetUnit = PercentUnit.SUPPORTED_UNITS.find((u) => u.symbol === unit.symbol);
|
|
23
|
+
if (!targetUnit) {
|
|
24
|
+
throw new Error(`Unsupported percent unit: ${unit.symbol}`);
|
|
25
|
+
}
|
|
26
|
+
return value * targetUnit.toDecimalFactor;
|
|
27
|
+
}
|
|
28
|
+
convertTo(unit, value) {
|
|
29
|
+
if (!unit || unit.symbol === this.symbol) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
const decimal = this.toDecimal(unit, value);
|
|
33
|
+
const targetUnit = PercentUnit.SUPPORTED_UNITS.find((u) => u.symbol === unit.symbol);
|
|
34
|
+
if (!targetUnit) {
|
|
35
|
+
throw new Error(`Unsupported percent unit: ${unit.symbol}`);
|
|
36
|
+
}
|
|
37
|
+
return decimal / targetUnit.toDecimalFactor;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.PercentUnit = PercentUnit;
|
|
41
|
+
PercentUnit.PERCENT = new PercentUnit('%', 'Percent', 0.01, ['pct', 'percent']);
|
|
42
|
+
PercentUnit.PERMILLE = new PercentUnit('‰', 'Permille', 0.001, []);
|
|
43
|
+
PercentUnit.DECIMAL = new PercentUnit('', 'Fraction', 1, []);
|
|
44
|
+
PercentUnit.SUPPORTED_UNITS = [
|
|
45
|
+
PercentUnit.PERCENT,
|
|
46
|
+
PercentUnit.PERMILLE,
|
|
47
|
+
PercentUnit.DECIMAL
|
|
48
|
+
];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Unit } from '../unit';
|
|
2
|
+
export type Pressure = 'Pa' | 'hPa' | 'kPa' | 'MPa' | 'bar' | 'mbar' | 'psi' | 'atm' | 'inHg' | 'mmHg';
|
|
3
|
+
export declare class PressureUnit implements Unit<Pressure> {
|
|
4
|
+
readonly symbol: Pressure;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
private readonly toPascalsFactor;
|
|
7
|
+
private readonly aliasSymbols;
|
|
8
|
+
static PASCAL: PressureUnit;
|
|
9
|
+
static HECTOPASCAL: PressureUnit;
|
|
10
|
+
static KILOPASCAL: PressureUnit;
|
|
11
|
+
static MEGAPASCAL: PressureUnit;
|
|
12
|
+
static BAR: PressureUnit;
|
|
13
|
+
static MILLIBAR: PressureUnit;
|
|
14
|
+
static PSI: PressureUnit;
|
|
15
|
+
static ATMOSPHERE: PressureUnit;
|
|
16
|
+
static MILLIMETER_OF_MERCURY: PressureUnit;
|
|
17
|
+
static INCH_OF_MERCURY: PressureUnit;
|
|
18
|
+
static SUPPORTED_UNITS: PressureUnit[];
|
|
19
|
+
static fromSymbol(symbol: string): Unit<Pressure>;
|
|
20
|
+
private constructor();
|
|
21
|
+
toDisplayString(): string;
|
|
22
|
+
toPascals(unit: Unit<Pressure>, value: number): number;
|
|
23
|
+
convertTo(unit: Unit<Pressure>, value: number): number;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=pressure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pressure.d.ts","sourceRoot":"","sources":["../../../../../src/models/measures/units/pressure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,MAAM,QAAQ,GACd,IAAI,GACJ,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,MAAM,GACN,KAAK,GACL,KAAK,GACL,MAAM,GACN,MAAM,CAAC;AACb,qBAAa,YAAa,YAAW,IAAI,CAAC,QAAQ,CAAC;aAwC3B,MAAM,EAAE,QAAQ;aAChB,IAAI,EAAE,MAAM;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY;IA1CjC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAuC;IAClE,MAAM,CAAC,WAAW,EAAE,YAAY,CAA+C;IAC/E,MAAM,CAAC,UAAU,EAAE,YAAY,CAA+C;IAC9E,MAAM,CAAC,UAAU,EAAE,YAAY,CAAoD;IACnF,MAAM,CAAC,GAAG,EAAE,YAAY,CAA2C;IACnE,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAiE;IAC9F,MAAM,CAAC,GAAG,EAAE,YAAY,CAA6D;IACrF,MAAM,CAAC,UAAU,EAAE,YAAY,CAAkD;IACjF,MAAM,CAAC,qBAAqB,EAAE,YAAY,CAIxC;IACF,MAAM,CAAC,eAAe,EAAE,YAAY,CAAwD;IAE5F,MAAM,CAAC,eAAe,EAAE,YAAY,EAAE,CAWpC;IAEF,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;IAUjD,OAAO;IAOP,eAAe,IAAI,MAAM;IAIzB,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAQtD,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAWzD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PressureUnit = void 0;
|
|
4
|
+
class PressureUnit {
|
|
5
|
+
static fromSymbol(symbol) {
|
|
6
|
+
let unit = PressureUnit.SUPPORTED_UNITS.find((u) => u.symbol === symbol || u.aliasSymbols.includes(symbol));
|
|
7
|
+
if (!unit) {
|
|
8
|
+
throw new Error(`Unsupported pressure unit: ${symbol}`);
|
|
9
|
+
}
|
|
10
|
+
return unit;
|
|
11
|
+
}
|
|
12
|
+
constructor(symbol, name, toPascalsFactor, aliasSymbols = []) {
|
|
13
|
+
this.symbol = symbol;
|
|
14
|
+
this.name = name;
|
|
15
|
+
this.toPascalsFactor = toPascalsFactor;
|
|
16
|
+
this.aliasSymbols = aliasSymbols;
|
|
17
|
+
}
|
|
18
|
+
toDisplayString() {
|
|
19
|
+
return this.symbol;
|
|
20
|
+
}
|
|
21
|
+
toPascals(unit, value) {
|
|
22
|
+
const targetUnit = PressureUnit.SUPPORTED_UNITS.find((u) => u.symbol === unit.symbol);
|
|
23
|
+
if (!targetUnit) {
|
|
24
|
+
throw new Error(`Unsupported pressure unit: ${unit.symbol}`);
|
|
25
|
+
}
|
|
26
|
+
return value * targetUnit.toPascalsFactor;
|
|
27
|
+
}
|
|
28
|
+
convertTo(unit, value) {
|
|
29
|
+
if (!unit || unit.symbol === this.symbol) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
const pascals = this.toPascals(this, value);
|
|
33
|
+
const targetUnit = PressureUnit.SUPPORTED_UNITS.find((u) => u.symbol === unit.symbol);
|
|
34
|
+
if (!targetUnit) {
|
|
35
|
+
throw new Error(`Unsupported pressure unit: ${unit.symbol}`);
|
|
36
|
+
}
|
|
37
|
+
return pascals / targetUnit.toPascalsFactor;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.PressureUnit = PressureUnit;
|
|
41
|
+
PressureUnit.PASCAL = new PressureUnit('Pa', 'Pascal', 1);
|
|
42
|
+
PressureUnit.HECTOPASCAL = new PressureUnit('hPa', 'Hectopascal', 100);
|
|
43
|
+
PressureUnit.KILOPASCAL = new PressureUnit('kPa', 'Kilopascal', 1000);
|
|
44
|
+
PressureUnit.MEGAPASCAL = new PressureUnit('MPa', 'Megapascal', 1000000);
|
|
45
|
+
PressureUnit.BAR = new PressureUnit('bar', 'Bar', 100000);
|
|
46
|
+
PressureUnit.MILLIBAR = new PressureUnit('mbar', 'Millibar', 100, ['mb', 'millibar']);
|
|
47
|
+
PressureUnit.PSI = new PressureUnit('psi', 'Pound per Square Inch', 6894.76);
|
|
48
|
+
PressureUnit.ATMOSPHERE = new PressureUnit('atm', 'Atmosphere', 101325);
|
|
49
|
+
PressureUnit.MILLIMETER_OF_MERCURY = new PressureUnit('mmHg', 'Millimeter of Mercury', 133.322);
|
|
50
|
+
PressureUnit.INCH_OF_MERCURY = new PressureUnit('inHg', 'Inch of Mercury', 3386.39);
|
|
51
|
+
PressureUnit.SUPPORTED_UNITS = [
|
|
52
|
+
PressureUnit.PASCAL,
|
|
53
|
+
PressureUnit.HECTOPASCAL,
|
|
54
|
+
PressureUnit.KILOPASCAL,
|
|
55
|
+
PressureUnit.MEGAPASCAL,
|
|
56
|
+
PressureUnit.BAR,
|
|
57
|
+
PressureUnit.MILLIBAR,
|
|
58
|
+
PressureUnit.PSI,
|
|
59
|
+
PressureUnit.ATMOSPHERE,
|
|
60
|
+
PressureUnit.MILLIMETER_OF_MERCURY,
|
|
61
|
+
PressureUnit.INCH_OF_MERCURY
|
|
62
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Unit } from '../unit';
|
|
2
|
+
export type Speed = 'm/s' | 'ft/s' | 'kmh' | 'mph';
|
|
3
|
+
export declare class SpeedUnit implements Unit<Speed> {
|
|
4
|
+
readonly symbol: Speed;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
private readonly toMpsFactor;
|
|
7
|
+
private readonly aliasSymbols;
|
|
8
|
+
static readonly MPS: SpeedUnit;
|
|
9
|
+
static readonly FPS: SpeedUnit;
|
|
10
|
+
static readonly KMH: SpeedUnit;
|
|
11
|
+
static readonly MPH: SpeedUnit;
|
|
12
|
+
static readonly SUPPORTED_UNITS: SpeedUnit[];
|
|
13
|
+
static fromSymbol(symbol: string): Unit<Speed>;
|
|
14
|
+
private constructor();
|
|
15
|
+
toDisplayString(): string;
|
|
16
|
+
toMps(unit: Unit<Speed>, value: number): number;
|
|
17
|
+
convertTo(unit: Unit<Speed>, value: number): number;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=speed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speed.d.ts","sourceRoot":"","sources":["../../../../../src/models/measures/units/speed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,MAAM,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAEnD,qBAAa,SAAU,YAAW,IAAI,CAAC,KAAK,CAAC;aAsCrB,MAAM,EAAE,KAAK;aACb,IAAI,EAAE,MAAM;IAC5B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAxCjC,MAAM,CAAC,QAAQ,CAAC,GAAG,YAAyE;IAC5F,MAAM,CAAC,QAAQ,CAAC,GAAG,YAKhB;IACH,MAAM,CAAC,QAAQ,CAAC,GAAG,YAKhB;IACH,MAAM,CAAC,QAAQ,CAAC,GAAG,YAIhB;IAEH,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,SAAS,EAAE,CAK1C;IAEF,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;IAU9C,OAAO;IAOP,eAAe,IAAI,MAAM;IAIzB,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAQ/C,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAWtD"}
|