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.
Files changed (57) hide show
  1. package/README.md +8 -2
  2. package/dist/{lib/command → command}/common.d.ts +1 -1
  3. package/dist/{lib/command → command}/common.js +4 -4
  4. package/dist/{lib/command → command}/metar.d.ts +5 -1
  5. package/dist/{lib/command → command}/metar.js +6 -5
  6. package/dist/{lib/command → command}/remark.d.ts +5 -1
  7. package/dist/{lib/command → command}/remark.js +130 -148
  8. package/dist/{lib/commons → commons}/converter.d.ts +0 -0
  9. package/dist/{lib/commons → commons}/converter.js +2 -2
  10. package/dist/{lib/commons → commons}/errors.d.ts +7 -2
  11. package/dist/{lib/commons → commons}/errors.js +8 -3
  12. package/dist/commons/i18n.d.ts +12 -0
  13. package/dist/{lib/commons → commons}/i18n.js +12 -4
  14. package/dist/{lib/helpers → helpers}/helpers.d.ts +0 -1
  15. package/dist/helpers/helpers.js +23 -0
  16. package/dist/index.d.ts +10 -0
  17. package/dist/index.js +38 -0
  18. package/dist/locale/de.d.ts +321 -0
  19. package/dist/locale/de.js +322 -0
  20. package/dist/locale/en.d.ts +387 -0
  21. package/dist/locale/en.js +398 -0
  22. package/dist/locale/fr.d.ts +365 -0
  23. package/dist/locale/fr.js +376 -0
  24. package/dist/locale/it.d.ts +337 -0
  25. package/dist/locale/it.js +338 -0
  26. package/dist/locale/pl.d.ts +98 -0
  27. package/dist/locale/pl.js +99 -0
  28. package/dist/locale/zh-CN.d.ts +111 -0
  29. package/dist/locale/zh-CN.js +112 -0
  30. package/dist/model/enum.d.ts +221 -0
  31. package/dist/model/enum.js +231 -0
  32. package/dist/{lib/model → model}/model.d.ts +14 -7
  33. package/dist/{lib/model → model}/model.js +1 -1
  34. package/dist/parser/parser.d.ts +66 -0
  35. package/dist/parser/parser.js +322 -0
  36. package/package.json +8 -3
  37. package/dist/lib/commons/i18n.d.ts +0 -3
  38. package/dist/lib/helpers/helpers.js +0 -28
  39. package/dist/lib/index.d.ts +0 -1
  40. package/dist/lib/index.js +0 -3
  41. package/dist/lib/locale/en.json +0 -396
  42. package/dist/lib/model/enum.d.ts +0 -122
  43. package/dist/lib/model/enum.js +0 -132
  44. package/dist/lib/parser/parser.d.ts +0 -26
  45. package/dist/lib/parser/parser.js +0 -198
  46. package/dist/tests/command/common.test.d.ts +0 -1
  47. package/dist/tests/command/common.test.js +0 -102
  48. package/dist/tests/command/metar.test.d.ts +0 -1
  49. package/dist/tests/command/metar.test.js +0 -52
  50. package/dist/tests/command/remark.test.d.ts +0 -1
  51. package/dist/tests/command/remark.test.js +0 -689
  52. package/dist/tests/common/converter.test.d.ts +0 -1
  53. package/dist/tests/common/converter.test.js +0 -78
  54. package/dist/tests/helpers/helpers.test.d.ts +0 -1
  55. package/dist/tests/helpers/helpers.test.js +0 -17
  56. package/dist/tests/parser/parser.test.d.ts +0 -1
  57. package/dist/tests/parser/parser.test.js +0 -96
@@ -1,78 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const converter = __importStar(require("commons/converter"));
27
- describe("degreesToCardinal", () => {
28
- test("VRB", () => {
29
- expect(converter.degreesToCardinal("VRB")).toBe("VRB");
30
- });
31
- const expected = [
32
- ["80", "E"],
33
- ["30", "NNE"],
34
- ["200", "SSW"],
35
- ["280", "W"],
36
- ["300", "WNW"],
37
- ["130", "SE"],
38
- ["230", "SW"],
39
- ["2", "N"],
40
- ["345", "NNW"],
41
- ["anything", "VRB"],
42
- ];
43
- expected.forEach(([input, expected]) => {
44
- test(input, () => {
45
- expect(converter.degreesToCardinal(input)).toBe(expected);
46
- });
47
- });
48
- });
49
- describe("convertVisibility", () => {
50
- test("convert visibility 10km", () => {
51
- expect(converter.convertVisibility("9999")).toBe("> 10km");
52
- });
53
- test("specific", () => {
54
- expect(converter.convertVisibility("4512")).toBe("4512m");
55
- });
56
- });
57
- describe("convertTemperature", () => {
58
- test("minus", () => {
59
- expect(converter.convertTemperature("M12")).toBe(-12);
60
- });
61
- test("positive", () => {
62
- expect(converter.convertTemperature("05")).toBe(5);
63
- });
64
- });
65
- test("convertInchesMercuryToPascal", () => {
66
- expect(converter.convertInchesMercuryToPascal(29.92)).toBeCloseTo(1013.2, 1);
67
- });
68
- describe("convertTemperatureRemarks", () => {
69
- test("positive", () => {
70
- expect(converter.convertTemperatureRemarks("0", "142")).toBe(14.2);
71
- });
72
- test("negative", () => {
73
- expect(converter.convertTemperatureRemarks("1", "021")).toBe(-2.1);
74
- });
75
- });
76
- test("convertPrecipitationAmount", () => {
77
- expect(converter.convertPrecipitationAmount("0217")).toBe(2.17);
78
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const helpers_1 = require("helpers/helpers");
4
- describe("pySplit", () => {
5
- it("no limit", () => {
6
- expect((0, helpers_1.pySplit)("1,2,3,4", ",")).toStrictEqual(["1", "2", "3", "4"]);
7
- });
8
- it("limit = 0", () => {
9
- expect((0, helpers_1.pySplit)("1,2,3,4", ",", 0)).toStrictEqual(["1,2,3,4"]);
10
- });
11
- it("limit = 1", () => {
12
- expect((0, helpers_1.pySplit)("1,2,3,4", ",", 1)).toStrictEqual(["1", "2,3,4"]);
13
- });
14
- it("limit = 10", () => {
15
- expect((0, helpers_1.pySplit)("1,2,3,4", ",", 10)).toStrictEqual(["1", "2", "3", "4"]);
16
- });
17
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const parser_1 = require("parser/parser");
7
- const i18n_1 = __importDefault(require("commons/i18n"));
8
- const enum_1 = require("model/enum");
9
- describe("RemarkParser", () => {
10
- (() => {
11
- const code = "Token AO1 End of remark";
12
- test(`parses "${code}"`, () => {
13
- const remarks = new parser_1.RemarkParser().parse(code);
14
- expect(remarks).toStrictEqual([
15
- "Token",
16
- i18n_1.default.Remark.AO1,
17
- "End",
18
- "of",
19
- "remark",
20
- ]);
21
- });
22
- })();
23
- });
24
- class StubParser extends parser_1.AbstractParser {
25
- }
26
- describe("RemarkParser", () => {
27
- (() => {
28
- const code = "-DZ";
29
- test(`parses "${code}"`, () => {
30
- const weatherCondition = new StubParser().parseWeatherCondition(code);
31
- expect(weatherCondition.intensity).toBe(enum_1.Intensity.LIGHT);
32
- expect(weatherCondition.phenomenons).toHaveLength(1);
33
- expect(weatherCondition.phenomenons[0]).toBe(enum_1.Phenomenon.DRIZZLE);
34
- });
35
- })();
36
- (() => {
37
- const code = "SHRAGR";
38
- test(`parses "${code}"`, () => {
39
- const weatherCondition = new StubParser().parseWeatherCondition(code);
40
- expect(weatherCondition.intensity).toBeUndefined();
41
- expect(weatherCondition.descriptive).toBe(enum_1.Descriptive.SHOWERS);
42
- expect(weatherCondition.phenomenons).toEqual([
43
- enum_1.Phenomenon.RAIN,
44
- enum_1.Phenomenon.HAIL,
45
- ]);
46
- });
47
- })();
48
- test("tokenize", () => {
49
- const code = "METAR KTTN 051853Z 04011KT 1 1/2SM VCTS SN FZFG BKN003 OVC010 M02/M02 A3006 RMK AO2 TSB40 SLP176 P0002 T10171017=";
50
- const expected = [
51
- "METAR",
52
- "KTTN",
53
- "051853Z",
54
- "04011KT",
55
- "1 1/2SM",
56
- "VCTS",
57
- "SN",
58
- "FZFG",
59
- "BKN003",
60
- "OVC010",
61
- "M02/M02",
62
- "A3006",
63
- "RMK",
64
- "AO2",
65
- "TSB40",
66
- "SLP176",
67
- "P0002",
68
- "T10171017",
69
- ];
70
- const res = new StubParser().tokenize(code);
71
- expect(res).toEqual(expected);
72
- });
73
- const values = [
74
- // ["05009KT", true],
75
- // ["030V113", true],
76
- // ["9999", true],
77
- // ["6 1/2SM", true],
78
- // ["1100w", true],
79
- // ["VV002", true],
80
- // ["CAVOK", true],
81
- // ["SCT026CB", true],
82
- // ["ZZZ026CV", false],
83
- // ["+SHGSRA", true],
84
- ["+VFDR", false],
85
- ];
86
- values.forEach(([input, expected]) => {
87
- test(input, () => {
88
- expect(new StubParser().generalParse({
89
- weatherConditions: [],
90
- visibility: {},
91
- wind: {},
92
- clouds: [],
93
- }, input)).toBe(expected);
94
- });
95
- });
96
- });