metar-taf-parser 7.1.1 → 7.1.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.
@@ -2180,6 +2180,9 @@ class CommandSupplier {
2180
2180
  _CommandSupplier_commands = new WeakMap();
2181
2181
 
2182
2182
  var _AbstractParser_INTENSITY_REGEX, _AbstractParser_CAVOK, _AbstractParser_commonSupplier, _MetarParser_commandSupplier, _TAFParser_commandSupplier, _TAFParser_validityPattern, _RemarkParser_supplier;
2183
+ function isStation(stationString) {
2184
+ return stationString.length === 4;
2185
+ }
2183
2186
  /**
2184
2187
  * Parses the delivery time of a METAR/TAF
2185
2188
  * @param abstractWeatherCode The TAF or METAR object
@@ -2434,9 +2437,17 @@ class MetarParser extends AbstractParser {
2434
2437
  */
2435
2438
  parse(input) {
2436
2439
  const metarTab = this.tokenize(input);
2440
+ let index = 0;
2441
+ // Only parse flag if precedes station identifier
2442
+ if (isStation(metarTab[index + 1])) {
2443
+ var flags = findFlags(metarTab[index]);
2444
+ if (flags)
2445
+ index += 1;
2446
+ }
2437
2447
  const metar = {
2438
- ...parseDeliveryTime(metarTab[1]),
2439
- station: metarTab[0],
2448
+ ...parseDeliveryTime(metarTab[index + 1]),
2449
+ station: metarTab[index],
2450
+ ...flags,
2440
2451
  message: input,
2441
2452
  remarks: [],
2442
2453
  clouds: [],
@@ -2444,7 +2455,7 @@ class MetarParser extends AbstractParser {
2444
2455
  trends: [],
2445
2456
  runwaysInfo: [],
2446
2457
  };
2447
- let index = 2;
2458
+ index += 2;
2448
2459
  while (index < metarTab.length) {
2449
2460
  if (!super.generalParse(metar, metarTab[index]) &&
2450
2461
  !parseFlags(metar, metarTab[index])) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metar-taf-parser",
3
- "version": "7.1.1",
3
+ "version": "7.1.2",
4
4
  "description": "Parse METAR and TAF reports",
5
5
  "homepage": "https://aeharding.github.io/metar-taf-parser",
6
6
  "keywords": [