metar-taf-parser 9.0.1 → 9.1.1

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/locale/en.d.ts CHANGED
@@ -142,6 +142,7 @@ declare const _default: {
142
142
  ALQDS: string;
143
143
  AO1: string;
144
144
  AO2: string;
145
+ AO2A: string;
145
146
  BASED: string;
146
147
  Barometer: string[];
147
148
  Ceiling: {
@@ -183,6 +184,11 @@ declare const _default: {
183
184
  LGT: string;
184
185
  LTG: string;
185
186
  MOD: string;
187
+ Next: {
188
+ Forecast: {
189
+ By: string;
190
+ };
191
+ };
186
192
  NXT: string;
187
193
  ON: string;
188
194
  Obscuration: string;
package/locale/en.js CHANGED
@@ -94,7 +94,7 @@ var en = {
94
94
  TS: "thunderstorm",
95
95
  },
96
96
  Error: {
97
- prefix: "An error occured. Error code n°",
97
+ prefix: "An error occurred. Error code n°",
98
98
  },
99
99
  ErrorCode: {
100
100
  AirportNotFound: "The airport was not found for this message.",
@@ -142,6 +142,7 @@ var en = {
142
142
  ALQDS: "all quadrants",
143
143
  AO1: "automated stations without a precipitation discriminator",
144
144
  AO2: "automated station with a precipitation discriminator",
145
+ AO2A: "automated station with a precipitation discriminator (augmented)",
145
146
  BASED: "based",
146
147
  Barometer: [
147
148
  "Increase, then decrease",
@@ -157,7 +158,7 @@ var en = {
157
158
  Ceiling: {
158
159
  Height: "ceiling varying between {0} and {1} feet",
159
160
  Second: {
160
- Location: "ceiling of {0} feet mesured by a second sensor located at {1}",
161
+ Location: "ceiling of {0} feet measured by a second sensor located at {1}",
161
162
  },
162
163
  },
163
164
  DSNT: "distant",
@@ -193,6 +194,11 @@ var en = {
193
194
  LGT: "light",
194
195
  LTG: "lightning",
195
196
  MOD: "moderate",
197
+ Next: {
198
+ Forecast: {
199
+ By: "next forecast by {0}, {1}:{2}Z"
200
+ },
201
+ },
196
202
  NXT: "next",
197
203
  ON: "on",
198
204
  Obscuration: "{0} layer at {1} feet composed of {2}",
@@ -224,7 +230,7 @@ var en = {
224
230
  },
225
231
  Second: {
226
232
  Location: {
227
- Visibility: "visibility of {0} SM mesured by a second sensor located at {1}",
233
+ Visibility: "visibility of {0} SM measured by a second sensor located at {1}",
228
234
  },
229
235
  },
230
236
  Sector: {
@@ -517,6 +517,7 @@ declare const _default: {
517
517
  ALQDS: string;
518
518
  AO1: string;
519
519
  AO2: string;
520
+ AO2A: string;
520
521
  BASED: string;
521
522
  Barometer: string[];
522
523
  Ceiling: {
@@ -558,6 +559,11 @@ declare const _default: {
558
559
  LGT: string;
559
560
  LTG: string;
560
561
  MOD: string;
562
+ Next: {
563
+ Forecast: {
564
+ By: string;
565
+ };
566
+ };
561
567
  NXT: string;
562
568
  ON: string;
563
569
  Obscuration: string;
@@ -1079,6 +1085,17 @@ interface IPrecipitationEndRemark extends IBaseRemark {
1079
1085
  endMin: number;
1080
1086
  }
1081
1087
 
1088
+ interface INextForecastByRemark extends IBaseRemark {
1089
+ type: RemarkType.NextForecastBy;
1090
+ day: number;
1091
+ hour: number;
1092
+ minute: number;
1093
+ }
1094
+ interface INextForecastByRemarkDated extends INextForecastByRemark {
1095
+ type: RemarkType.NextForecastBy;
1096
+ date: Date;
1097
+ }
1098
+
1082
1099
  interface IBaseRemark {
1083
1100
  type: RemarkType;
1084
1101
  description?: string;
@@ -1135,9 +1152,12 @@ declare enum RemarkType {
1135
1152
  PrecipitationAmount24Hour = "PrecipitationAmount24Hour",
1136
1153
  SnowDepth = "SnowDepth",
1137
1154
  SunshineDuration = "SunshineDuration",
1138
- WaterEquivalentSnow = "WaterEquivalentSnow"
1155
+ WaterEquivalentSnow = "WaterEquivalentSnow",
1156
+ NextForecastBy = "NextForecastBy"
1139
1157
  }
1140
- type Remark = IUnknownRemark | IDefaultCommandRemark | ICeilingHeightRemark | ICeilingSecondLocationRemark | IHailSizeRemark | IHourlyMaximumMinimumTemperatureRemark | IHourlyMaximumTemperatureRemark | IHourlyMinimumTemperatureRemark | IHourlyPrecipitationAmountRemark | IHourlyPressureRemark | IHourlyTemperatureDewPointRemark | IIceAccretionRemark | IObscurationRemark | IPrecipitationAmount24HourRemark | IPrecipitationAmount36HourRemark | IPrecipitationAmount36HourRemark | IPrecipitationBegRemark | IPrecipitationBegEndRemark | IPrecipitationEndRemark | IPrevailingVisibilityRemark | ISeaLevelPressureRemark | ISecondLocationVisibilityRemark | ISectorVisibilityRemark | ISmallHailSizeRemark | ISnowDepthRemark | ISnowIncreaseRemark | ISnowPelletsRemark | ISunshineDurationRemark | ISurfaceVisibilityRemark | IThunderStormLocationRemark | IThunderStormLocationMovingRemark | ITornadicActivityBegRemark | ITornadicActivityBegEndRemark | ITornadicActivityEndRemark | ITowerVisibilityRemark | IVariableSkyRemark | IVariableSkyHeightRemark | IVirgaDirectionRemark | IWaterEquivalentSnowRemark | IWindPeakCommandRemark | IWindShiftRemark | IWindShiftFropaRemark;
1158
+ type RemarkBase = IUnknownRemark | IDefaultCommandRemark | ICeilingHeightRemark | ICeilingSecondLocationRemark | IHailSizeRemark | IHourlyMaximumMinimumTemperatureRemark | IHourlyMaximumTemperatureRemark | IHourlyMinimumTemperatureRemark | IHourlyPrecipitationAmountRemark | IHourlyPressureRemark | IHourlyTemperatureDewPointRemark | IIceAccretionRemark | IObscurationRemark | IPrecipitationAmount24HourRemark | IPrecipitationAmount36HourRemark | IPrecipitationBegRemark | IPrecipitationBegEndRemark | IPrecipitationEndRemark | IPrevailingVisibilityRemark | ISeaLevelPressureRemark | ISecondLocationVisibilityRemark | ISectorVisibilityRemark | ISmallHailSizeRemark | ISnowDepthRemark | ISnowIncreaseRemark | ISnowPelletsRemark | ISunshineDurationRemark | ISurfaceVisibilityRemark | IThunderStormLocationRemark | IThunderStormLocationMovingRemark | ITornadicActivityBegRemark | ITornadicActivityBegEndRemark | ITornadicActivityEndRemark | ITowerVisibilityRemark | IVariableSkyRemark | IVariableSkyHeightRemark | IVirgaDirectionRemark | IWaterEquivalentSnowRemark | IWindPeakCommandRemark | IWindShiftRemark | IWindShiftFropaRemark;
1159
+ type RemarkDated = RemarkBase | INextForecastByRemarkDated;
1160
+ type Remark = RemarkBase | INextForecastByRemark;
1141
1161
 
1142
1162
  interface IWind {
1143
1163
  speed: number;
@@ -1443,6 +1463,7 @@ type TAFTrendDated = IAbstractTrend & IBaseTAFTrend & {
1443
1463
  start: Date;
1444
1464
  end?: Date;
1445
1465
  };
1466
+ remarks: RemarkDated[];
1446
1467
  } & ({
1447
1468
  type: WeatherChangeType.FM;
1448
1469
  validity: IFMValidity & {
@@ -1464,6 +1485,7 @@ interface ITAFDated extends ITAF {
1464
1485
  minTemperature?: ITemperatureDated;
1465
1486
  maxTemperature?: ITemperatureDated;
1466
1487
  trends: TAFTrendDated[];
1488
+ remarks: RemarkDated[];
1467
1489
  }
1468
1490
 
1469
1491
  declare abstract class ParseError extends Error {
@@ -1571,4 +1593,4 @@ declare function parseTAF(rawTAF: string, options?: IMetarTAFParserOptions): ITA
1571
1593
  declare function parseTAF(rawTAF: string, options?: IMetarTAFParserOptionsDated): ITAFDated;
1572
1594
  declare function parseTAFAsForecast(rawTAF: string, options: IMetarTAFParserOptionsDated): IForecastContainer;
1573
1595
 
1574
- export { AltimeterUnit, CloudQuantity, CloudType, CommandExecutionError, DepositCoverage, DepositType, Descriptive, Direction, type Distance, DistanceUnit, type Forecast, type IAbstractTrend, type IAbstractValidity, type IAbstractWeatherCode, type IAbstractWeatherCodeDated, type IAbstractWeatherContainer, type IAltimeter, type IBaseRemark, type IBaseRunwayInfo, type IBaseTAFTrend, type ICeilingHeightRemark, type ICeilingSecondLocationRemark, type ICloud, type ICompositeForecast, type IEndValidity, type IFMValidity, type IFlags, type IForecastContainer, type IHourlyMaximumMinimumTemperatureRemark, type IHourlyMaximumTemperatureRemark, type IHourlyMinimumTemperatureRemark, type IHourlyPrecipitationAmountRemark, type IHourlyPressureRemark, type IHourlyTemperatureDewPointRemark, type IIceAccretionRemark, type IIcing, type IMetar, type IMetarDated, type IMetarTAFParserOptions, type IMetarTAFParserOptionsDated, type IMetarTrend, type IMetarTrendTime, type IObscurationRemark, type IPrecipitationAmount24HourRemark, type IPrecipitationAmount36HourRemark, type IPrecipitationBegEndRemark, type IPrevailingVisibilityRemark, type IRunwayInfoDeposit, type IRunwayInfoRange, type ISeaLevelPressureRemark, type ISecondLocationVisibilityRemark, type ISectorVisibilityRemark, type ISmallHailSizeRemark, type ISnowIncreaseRemark, type ISnowPelletsRemark, type ISunshineDurationRemark, type ISurfaceVisibilityRemark, type ITAF, type ITAFDated, type ITafGroups, type ITemperature, type ITemperatureDated, type IThunderStormLocationMovingRemark, type IThunderStormLocationRemark, type ITime, type ITornadicActivityBegEndRemark, type ITornadicActivityBegRemark, type ITornadicActivityEndRemark, type ITowerVisibilityRemark, type ITurbulence, type IUnknownRemark, type IValidity, type IValidityDated, type IVariableSkyHeightRemark, type IVariableSkyRemark, type IVirgaDirectionRemark, type IWaterEquivalentSnowRemark, type IWeatherCondition, type IWind, type IWindPeakCommandRemark, type IWindShear, type IWindShiftFropaRemark, IcingIntensity, Intensity, InvalidWeatherStatementError, type Locale, MetarType, ParseError, PartialWeatherStatementError, Phenomenon, type Remark, RemarkType, type RunwayInfo, RunwayInfoTrend, RunwayInfoUnit, SpeedUnit, type TAFTrend, type TAFTrendDated, TimeIndicator, TimestampOutOfBoundsError, TurbulenceIntensity, UnexpectedParseError, ValueIndicator, type Visibility, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
1596
+ export { AltimeterUnit, CloudQuantity, CloudType, CommandExecutionError, DepositCoverage, DepositType, Descriptive, Direction, type Distance, DistanceUnit, type Forecast, type IAbstractTrend, type IAbstractValidity, type IAbstractWeatherCode, type IAbstractWeatherCodeDated, type IAbstractWeatherContainer, type IAltimeter, type IBaseRemark, type IBaseRunwayInfo, type IBaseTAFTrend, type ICeilingHeightRemark, type ICeilingSecondLocationRemark, type ICloud, type ICompositeForecast, type IEndValidity, type IFMValidity, type IFlags, type IForecastContainer, type IHourlyMaximumMinimumTemperatureRemark, type IHourlyMaximumTemperatureRemark, type IHourlyMinimumTemperatureRemark, type IHourlyPrecipitationAmountRemark, type IHourlyPressureRemark, type IHourlyTemperatureDewPointRemark, type IIceAccretionRemark, type IIcing, type IMetar, type IMetarDated, type IMetarTAFParserOptions, type IMetarTAFParserOptionsDated, type IMetarTrend, type IMetarTrendTime, type INextForecastByRemark, type INextForecastByRemarkDated, type IObscurationRemark, type IPrecipitationAmount24HourRemark, type IPrecipitationAmount36HourRemark, type IPrecipitationBegEndRemark, type IPrevailingVisibilityRemark, type IRunwayInfoDeposit, type IRunwayInfoRange, type ISeaLevelPressureRemark, type ISecondLocationVisibilityRemark, type ISectorVisibilityRemark, type ISmallHailSizeRemark, type ISnowIncreaseRemark, type ISnowPelletsRemark, type ISunshineDurationRemark, type ISurfaceVisibilityRemark, type ITAF, type ITAFDated, type ITafGroups, type ITemperature, type ITemperatureDated, type IThunderStormLocationMovingRemark, type IThunderStormLocationRemark, type ITime, type ITornadicActivityBegEndRemark, type ITornadicActivityBegRemark, type ITornadicActivityEndRemark, type ITowerVisibilityRemark, type ITurbulence, type IUnknownRemark, type IValidity, type IValidityDated, type IVariableSkyHeightRemark, type IVariableSkyRemark, type IVirgaDirectionRemark, type IWaterEquivalentSnowRemark, type IWeatherCondition, type IWind, type IWindPeakCommandRemark, type IWindShear, type IWindShiftFropaRemark, IcingIntensity, Intensity, InvalidWeatherStatementError, type Locale, MetarType, ParseError, PartialWeatherStatementError, Phenomenon, type Remark, type RemarkDated, RemarkType, type RunwayInfo, RunwayInfoTrend, RunwayInfoUnit, SpeedUnit, type TAFTrend, type TAFTrendDated, TimeIndicator, TimestampOutOfBoundsError, TurbulenceIntensity, UnexpectedParseError, ValueIndicator, type Visibility, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
@@ -14,7 +14,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
14
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
15
  PERFORMANCE OF THIS SOFTWARE.
16
16
  ***************************************************************************** */
17
- /* global Reflect, Promise, SuppressedError, Symbol */
17
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
18
18
 
19
19
 
20
20
  function __classPrivateFieldGet(receiver, state, kind, f) {
@@ -1752,6 +1752,36 @@ class PrecipitationEndCommand extends Command {
1752
1752
  }
1753
1753
  _PrecipitationEndCommand_regex = new WeakMap();
1754
1754
 
1755
+ var _NextForecastByCommand_regex;
1756
+ class NextForecastByCommand extends Command {
1757
+ constructor() {
1758
+ super(...arguments);
1759
+ _NextForecastByCommand_regex.set(this, /^NXT FCST BY (\d{2})(\d{2})(\d{2})Z/);
1760
+ }
1761
+ canParse(code) {
1762
+ return __classPrivateFieldGet(this, _NextForecastByCommand_regex, "f").test(code);
1763
+ }
1764
+ execute(code, remark) {
1765
+ const matches = code.match(__classPrivateFieldGet(this, _NextForecastByCommand_regex, "f"));
1766
+ if (!matches)
1767
+ throw new UnexpectedParseError("Match not found");
1768
+ const day = +matches[1];
1769
+ const hour = matches[2];
1770
+ const minute = matches[3];
1771
+ const description = format(_("Remark.Next.Forecast.By", this.locale), day, hour, minute);
1772
+ remark.push({
1773
+ type: RemarkType.NextForecastBy,
1774
+ description,
1775
+ raw: matches[0],
1776
+ day,
1777
+ hour: +hour,
1778
+ minute: +minute,
1779
+ });
1780
+ return [code.replace(__classPrivateFieldGet(this, _NextForecastByCommand_regex, "f"), "").trim(), remark];
1781
+ }
1782
+ }
1783
+ _NextForecastByCommand_regex = new WeakMap();
1784
+
1755
1785
  class RemarkCommandSupplier {
1756
1786
  constructor(locale) {
1757
1787
  this.locale = locale;
@@ -1796,6 +1826,7 @@ class RemarkCommandSupplier {
1796
1826
  new SnowDepthCommand(locale),
1797
1827
  new SunshineDurationCommand(locale),
1798
1828
  new WaterEquivalentSnowCommand(locale),
1829
+ new NextForecastByCommand(locale),
1799
1830
  ];
1800
1831
  }
1801
1832
  get(code) {
@@ -1859,6 +1890,8 @@ var RemarkType;
1859
1890
  RemarkType["SnowDepth"] = "SnowDepth";
1860
1891
  RemarkType["SunshineDuration"] = "SunshineDuration";
1861
1892
  RemarkType["WaterEquivalentSnow"] = "WaterEquivalentSnow";
1893
+ // Canada commands below
1894
+ RemarkType["NextForecastBy"] = "NextForecastBy";
1862
1895
  })(RemarkType || (RemarkType = {}));
1863
1896
 
1864
1897
  function isWeatherConditionValid(weather) {
@@ -2117,8 +2150,8 @@ var _RunwayCommand_genericRegex, _RunwayCommand_runwayMaxRangeRegex, _RunwayComm
2117
2150
  class RunwayCommand {
2118
2151
  constructor() {
2119
2152
  _RunwayCommand_genericRegex.set(this, /^(R\d{2}\w?\/)/);
2120
- _RunwayCommand_runwayMaxRangeRegex.set(this, /^R(\d{2}\w?)\/(\d{4})V(\d{3,4})([UDN])?(FT)?/);
2121
- _RunwayCommand_runwayRegex.set(this, /^R(\d{2}\w?)\/([MP])?(\d{4})([UDN])?(FT)?$/);
2153
+ _RunwayCommand_runwayMaxRangeRegex.set(this, /^R(\d{2}\w?)\/(\d{4})V(\d{3,4})(?:([UDN])|(FT)(?:\/([UDN]))?)$/);
2154
+ _RunwayCommand_runwayRegex.set(this, /^R(\d{2}\w?)\/([MP])?(\d{4})(?:([UDN])|(FT)(?:\/([UDN]))?)$/);
2122
2155
  _RunwayCommand_runwayDepositRegex.set(this, /^R(\d{2}\w?)\/([/\d])([/\d])(\/\/|\d{2})(\/\/|\d{2})$/);
2123
2156
  }
2124
2157
  canParse(input) {
@@ -2144,7 +2177,12 @@ class RunwayCommand {
2144
2177
  if (!matches)
2145
2178
  throw new UnexpectedParseError("Should be able to parse");
2146
2179
  const indicator = matches[2] ? as(matches[2], ValueIndicator) : undefined;
2147
- const trend = matches[4] ? as(matches[4], RunwayInfoTrend) : undefined;
2180
+ const trend = (() => {
2181
+ if (matches[6])
2182
+ return as(matches[6], RunwayInfoTrend);
2183
+ if (matches[4])
2184
+ return as(matches[4], RunwayInfoTrend);
2185
+ })();
2148
2186
  const unit = matches[5]
2149
2187
  ? as(matches[5], RunwayInfoUnit)
2150
2188
  : RunwayInfoUnit.Meters;
@@ -2160,7 +2198,12 @@ class RunwayCommand {
2160
2198
  const matches = input.match(__classPrivateFieldGet(this, _RunwayCommand_runwayMaxRangeRegex, "f"));
2161
2199
  if (!matches)
2162
2200
  throw new UnexpectedParseError("Should be able to parse");
2163
- const trend = matches[4] ? as(matches[4], RunwayInfoTrend) : undefined;
2201
+ const trend = (() => {
2202
+ if (matches[6])
2203
+ return as(matches[6], RunwayInfoTrend);
2204
+ if (matches[4])
2205
+ return as(matches[4], RunwayInfoTrend);
2206
+ })();
2164
2207
  const unit = matches[5]
2165
2208
  ? as(matches[5], RunwayInfoUnit)
2166
2209
  : RunwayInfoUnit.Meters;
@@ -2900,6 +2943,17 @@ function metarDatesHydrator(report, date) {
2900
2943
  };
2901
2944
  }
2902
2945
 
2946
+ function remarksDatesHydrator(remarks, date) {
2947
+ return remarks.map((remark) => {
2948
+ if (remark.type === RemarkType.NextForecastBy) {
2949
+ return {
2950
+ ...remark,
2951
+ date: determineReportDate(date, remark.day, remark.hour, remark.minute),
2952
+ };
2953
+ }
2954
+ return remark;
2955
+ });
2956
+ }
2903
2957
  function tafDatesHydrator(report, date) {
2904
2958
  const issued = determineReportDate(date, report.day, report.hour, report.minute);
2905
2959
  return {
@@ -2924,6 +2978,7 @@ function tafDatesHydrator(report, date) {
2924
2978
  : undefined,
2925
2979
  trends: report.trends.map((trend) => ({
2926
2980
  ...trend,
2981
+ remarks: remarksDatesHydrator(trend.remarks, issued),
2927
2982
  validity: (() => {
2928
2983
  switch (trend.type) {
2929
2984
  case WeatherChangeType.FM:
@@ -2940,6 +2995,7 @@ function tafDatesHydrator(report, date) {
2940
2995
  }
2941
2996
  })(),
2942
2997
  })),
2998
+ remarks: remarksDatesHydrator(report.remarks, issued),
2943
2999
  };
2944
3000
  }
2945
3001
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metar-taf-parser",
3
- "version": "9.0.1",
3
+ "version": "9.1.1",
4
4
  "description": "Parse METAR and TAF reports",
5
5
  "homepage": "https://aeharding.github.io/metar-taf-parser",
6
6
  "packageManager": "pnpm@9.0.6+sha256.0624e30eff866cdeb363b15061bdb7fd9425b17bc1bb42c22f5f4efdea21f6b3",
@@ -39,23 +39,23 @@
39
39
  "metar-taf-parser.*"
40
40
  ],
41
41
  "devDependencies": {
42
- "@babel/preset-env": "^7.24.5",
43
- "@babel/preset-typescript": "^7.24.1",
44
- "@rollup/plugin-typescript": "^11.1.6",
45
- "@types/jest": "^29.5.12",
46
- "@types/lodash": "^4.17.1",
47
- "@types/node": "^20.12.8",
42
+ "@babel/preset-env": "^7.26.0",
43
+ "@babel/preset-typescript": "^7.26.0",
44
+ "@rollup/plugin-typescript": "^12.1.2",
45
+ "@types/jest": "^29.5.14",
46
+ "@types/lodash": "^4.17.14",
47
+ "@types/node": "^22.10.5",
48
48
  "jest": "^29.7.0",
49
49
  "lodash": "^4.17.21",
50
- "prettier": "^3.2.5",
51
- "rimraf": "^5.0.5",
52
- "rollup": "^4.17.2",
53
- "rollup-plugin-dts": "^6.1.0",
54
- "ts-jest": "^29.1.2",
50
+ "prettier": "^3.4.2",
51
+ "rimraf": "^6.0.1",
52
+ "rollup": "^4.29.2",
53
+ "rollup-plugin-dts": "^6.1.1",
54
+ "ts-jest": "^29.2.5",
55
55
  "ts-node": "^10.9.2",
56
- "tsc-alias": "^1.8.8",
57
- "tslib": "^2.6.2",
58
- "typescript": "^5.4.5",
56
+ "tsc-alias": "^1.8.10",
57
+ "tslib": "^2.8.1",
58
+ "typescript": "^5.7.2",
59
59
  "watch": "^1.0.2"
60
60
  }
61
61
  }