metar-taf-parser 0.0.1 → 0.0.2
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 +8 -2
- package/dist/{lib/command → command}/common.d.ts +1 -1
- package/dist/{lib/command → command}/common.js +4 -4
- package/dist/{lib/command → command}/metar.d.ts +5 -1
- package/dist/{lib/command → command}/metar.js +6 -5
- package/dist/{lib/command → command}/remark.d.ts +5 -1
- package/dist/{lib/command → command}/remark.js +130 -148
- package/dist/{lib/commons → commons}/converter.d.ts +0 -0
- package/dist/{lib/commons → commons}/converter.js +2 -2
- package/dist/{lib/commons → commons}/errors.d.ts +7 -2
- package/dist/{lib/commons → commons}/errors.js +8 -3
- package/dist/commons/i18n.d.ts +12 -0
- package/dist/{lib/commons → commons}/i18n.js +12 -4
- package/dist/{lib/helpers → helpers}/helpers.d.ts +0 -1
- package/dist/helpers/helpers.js +23 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +38 -0
- package/dist/locale/de.d.ts +321 -0
- package/dist/locale/de.js +322 -0
- package/dist/locale/en.d.ts +387 -0
- package/dist/locale/en.js +398 -0
- package/dist/locale/fr.d.ts +365 -0
- package/dist/locale/fr.js +376 -0
- package/dist/locale/it.d.ts +337 -0
- package/dist/locale/it.js +338 -0
- package/dist/locale/pl.d.ts +98 -0
- package/dist/locale/pl.js +99 -0
- package/dist/locale/zh-CN.d.ts +111 -0
- package/dist/locale/zh-CN.js +112 -0
- package/dist/model/enum.d.ts +221 -0
- package/dist/model/enum.js +231 -0
- package/dist/{lib/model → model}/model.d.ts +14 -7
- package/dist/{lib/model → model}/model.js +1 -1
- package/dist/parser/parser.d.ts +66 -0
- package/dist/parser/parser.js +322 -0
- package/package.json +8 -3
- package/dist/lib/commons/i18n.d.ts +0 -3
- package/dist/lib/helpers/helpers.js +0 -28
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.js +0 -3
- package/dist/lib/locale/en.json +0 -396
- package/dist/lib/model/enum.d.ts +0 -122
- package/dist/lib/model/enum.js +0 -132
- package/dist/lib/parser/parser.d.ts +0 -26
- package/dist/lib/parser/parser.js +0 -198
- package/dist/tests/command/common.test.d.ts +0 -1
- package/dist/tests/command/common.test.js +0 -102
- package/dist/tests/command/metar.test.d.ts +0 -1
- package/dist/tests/command/metar.test.js +0 -52
- package/dist/tests/command/remark.test.d.ts +0 -1
- package/dist/tests/command/remark.test.js +0 -689
- package/dist/tests/common/converter.test.d.ts +0 -1
- package/dist/tests/common/converter.test.js +0 -78
- package/dist/tests/helpers/helpers.test.d.ts +0 -1
- package/dist/tests/helpers/helpers.test.js +0 -17
- package/dist/tests/parser/parser.test.d.ts +0 -1
- package/dist/tests/parser/parser.test.js +0 -96
package/README.md
CHANGED
|
@@ -40,9 +40,15 @@ const tafResult = parseTAF(taf)
|
|
|
40
40
|
|
|
41
41
|
```ts
|
|
42
42
|
import { parseMetar } from 'metar-taf-parser'
|
|
43
|
-
import de from 'metar-taf-parser/locale/de'
|
|
43
|
+
import de from 'metar-taf-parser/dist/locale/de'
|
|
44
44
|
|
|
45
45
|
const { metar } = await myService.getAirportData('KMSN')
|
|
46
46
|
|
|
47
47
|
const metarResult = parseMetar(metar, { locale: de })
|
|
48
|
-
```
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Development
|
|
51
|
+
|
|
52
|
+
### Example site
|
|
53
|
+
|
|
54
|
+
Please see [the example site README.md](example/README.md).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAbstractWeatherContainer, ICloud, IWind, IWindShear } from "model/model";
|
|
1
|
+
import { IAbstractWeatherContainer, ICloud, IWind, IWindShear } from "../model/model";
|
|
2
2
|
interface ICommand {
|
|
3
3
|
canParse(str: string): boolean;
|
|
4
4
|
execute(container: IAbstractWeatherContainer, str: string): boolean;
|
|
@@ -30,9 +30,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
30
30
|
var _CloudCommand_cloudRegex, _MainVisibilityCommand_regex, _WindCommand_regex, _WindVariationCommand_regex, _WindShearCommand_regex, _VerticalVisibilityCommand_regex, _MinimalVisibilityCommand_regex, _MainVisibilityNauticalMilesCommand_regex, _CommandSupplier_commands;
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.CommandSupplier = exports.MainVisibilityNauticalMilesCommand = exports.MinimalVisibilityCommand = exports.VerticalVisibilityCommand = exports.WindShearCommand = exports.WindVariationCommand = exports.WindCommand = exports.MainVisibilityCommand = exports.CloudCommand = void 0;
|
|
33
|
-
const converter = __importStar(require("commons/converter"));
|
|
34
|
-
const enum_1 = require("model/enum");
|
|
35
|
-
const errors_1 = require("commons/errors");
|
|
33
|
+
const converter = __importStar(require("../commons/converter"));
|
|
34
|
+
const enum_1 = require("../model/enum");
|
|
35
|
+
const errors_1 = require("../commons/errors");
|
|
36
36
|
/**
|
|
37
37
|
* This function creates a wind element.
|
|
38
38
|
* @param wind The wind object
|
|
@@ -110,7 +110,7 @@ class WindCommand {
|
|
|
110
110
|
const matches = windString.match(__classPrivateFieldGet(this, _WindCommand_regex, "f"));
|
|
111
111
|
if (!matches)
|
|
112
112
|
throw new errors_1.UnexpectedParseError("Wind should be defined");
|
|
113
|
-
return makeWind(matches[1], matches[2], matches[3], matches[
|
|
113
|
+
return makeWind(matches[1], matches[2], matches[3], matches[4]);
|
|
114
114
|
}
|
|
115
115
|
execute(container, windString) {
|
|
116
116
|
const wind = this.parseWind(windString);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMetar } from "model/model";
|
|
1
|
+
import { IMetar } from "../model/model";
|
|
2
2
|
interface ICommand {
|
|
3
3
|
canParse(str: string): boolean;
|
|
4
4
|
execute(metar: IMetar, str: string): void;
|
|
@@ -23,4 +23,8 @@ export declare class TemperatureCommand implements ICommand {
|
|
|
23
23
|
canParse(input: string): boolean;
|
|
24
24
|
execute(metar: IMetar, input: string): void;
|
|
25
25
|
}
|
|
26
|
+
export declare class CommandSupplier {
|
|
27
|
+
#private;
|
|
28
|
+
get(input: string): ICommand | undefined;
|
|
29
|
+
}
|
|
26
30
|
export {};
|
|
@@ -29,9 +29,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
29
29
|
};
|
|
30
30
|
var _AltimeterCommand_regex, _AltimeterMercuryCommand_regex, _RunwayCommand_genericRegex, _RunwayCommand_runwayMaxRangeRegex, _RunwayCommand_runwayRegex, _TemperatureCommand_regex, _CommandSupplier_commands;
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.TemperatureCommand = exports.RunwayCommand = exports.AltimeterMercuryCommand = exports.AltimeterCommand = void 0;
|
|
33
|
-
const converter = __importStar(require("commons/converter"));
|
|
34
|
-
const errors_1 = require("commons/errors");
|
|
32
|
+
exports.CommandSupplier = exports.TemperatureCommand = exports.RunwayCommand = exports.AltimeterMercuryCommand = exports.AltimeterCommand = void 0;
|
|
33
|
+
const converter = __importStar(require("../commons/converter"));
|
|
34
|
+
const errors_1 = require("../commons/errors");
|
|
35
35
|
class AltimeterCommand {
|
|
36
36
|
constructor() {
|
|
37
37
|
_AltimeterCommand_regex.set(this, /^Q(\d{4})$/);
|
|
@@ -43,7 +43,7 @@ class AltimeterCommand {
|
|
|
43
43
|
const matches = input.match(__classPrivateFieldGet(this, _AltimeterCommand_regex, "f"));
|
|
44
44
|
if (!matches)
|
|
45
45
|
throw new errors_1.UnexpectedParseError("Match not found");
|
|
46
|
-
metar.altimeter = +matches[1];
|
|
46
|
+
metar.altimeter = Math.trunc(+matches[1]);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
exports.AltimeterCommand = AltimeterCommand;
|
|
@@ -60,7 +60,7 @@ class AltimeterMercuryCommand {
|
|
|
60
60
|
if (!matches)
|
|
61
61
|
throw new errors_1.UnexpectedParseError("Match not found");
|
|
62
62
|
const mercury = +matches[1] / 100;
|
|
63
|
-
metar.altimeter = converter.convertInchesMercuryToPascal(mercury);
|
|
63
|
+
metar.altimeter = Math.trunc(converter.convertInchesMercuryToPascal(mercury));
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
exports.AltimeterMercuryCommand = AltimeterMercuryCommand;
|
|
@@ -131,4 +131,5 @@ class CommandSupplier {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
exports.CommandSupplier = CommandSupplier;
|
|
134
135
|
_CommandSupplier_commands = new WeakMap();
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../commons/i18n";
|
|
1
2
|
export declare abstract class Command {
|
|
3
|
+
protected locale: Locale;
|
|
4
|
+
constructor(locale: Locale);
|
|
2
5
|
abstract canParse(code: string): boolean;
|
|
3
6
|
abstract execute(code: string, remark: string[]): [string, string[]];
|
|
4
7
|
}
|
|
@@ -192,8 +195,9 @@ export declare class DefaultCommand extends Command {
|
|
|
192
195
|
execute(code: string, remark: string[]): [string, string[]];
|
|
193
196
|
}
|
|
194
197
|
export declare class RemarkCommandSupplier {
|
|
198
|
+
private locale;
|
|
195
199
|
defaultCommand: Command;
|
|
196
200
|
commandList: Command[];
|
|
197
|
-
constructor();
|
|
201
|
+
constructor(locale: Locale);
|
|
198
202
|
get(code: string): Command;
|
|
199
203
|
}
|