metar-taf-parser 4.0.0 → 4.1.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/locale/en.js +1 -1
- package/metar-taf-parser.d.ts +24 -4
- package/metar-taf-parser.js +105 -34
- package/package.json +3 -3
package/locale/en.js
CHANGED
|
@@ -207,7 +207,7 @@ var en = {
|
|
|
207
207
|
Hourly: "{0}/100 of an inch of precipitation fell in the last hour",
|
|
208
208
|
},
|
|
209
209
|
Beg: {
|
|
210
|
-
"0": "{0} {1} beginning at {2}:{3}
|
|
210
|
+
"0": "{0} {1} beginning at {2}:{3}",
|
|
211
211
|
End: "{0} {1} beginning at {2}:{3} ending at {4}:{5}",
|
|
212
212
|
},
|
|
213
213
|
End: "{0} {1} ending at {2}:{3}",
|
package/metar-taf-parser.d.ts
CHANGED
|
@@ -1101,7 +1101,29 @@ interface ICloud {
|
|
|
1101
1101
|
quantity: CloudQuantity;
|
|
1102
1102
|
type?: CloudType;
|
|
1103
1103
|
}
|
|
1104
|
-
interface
|
|
1104
|
+
interface IFlags {
|
|
1105
|
+
/**
|
|
1106
|
+
* Amended TAF
|
|
1107
|
+
*/
|
|
1108
|
+
amendment?: true;
|
|
1109
|
+
/**
|
|
1110
|
+
* Amended METAR
|
|
1111
|
+
*/
|
|
1112
|
+
auto?: true;
|
|
1113
|
+
/**
|
|
1114
|
+
* Canceled TAF
|
|
1115
|
+
*/
|
|
1116
|
+
canceled?: true;
|
|
1117
|
+
/**
|
|
1118
|
+
* Corrected METAR/TAF
|
|
1119
|
+
*/
|
|
1120
|
+
corrected?: true;
|
|
1121
|
+
/**
|
|
1122
|
+
* No data
|
|
1123
|
+
*/
|
|
1124
|
+
nil?: true;
|
|
1125
|
+
}
|
|
1126
|
+
interface IAbstractWeatherContainer extends IFlags {
|
|
1105
1127
|
wind?: IWind;
|
|
1106
1128
|
visibility?: Visibility;
|
|
1107
1129
|
verticalVisibility?: number;
|
|
@@ -1138,7 +1160,6 @@ interface IMetar extends IAbstractWeatherCode {
|
|
|
1138
1160
|
dewPoint?: number;
|
|
1139
1161
|
altimeter?: number;
|
|
1140
1162
|
nosig?: true;
|
|
1141
|
-
auto?: true;
|
|
1142
1163
|
runwaysInfo: IRunwayInfo[];
|
|
1143
1164
|
/**
|
|
1144
1165
|
* Not used in North America
|
|
@@ -1149,7 +1170,6 @@ interface ITAF extends IAbstractWeatherCode {
|
|
|
1149
1170
|
validity: IValidity;
|
|
1150
1171
|
maxTemperature?: ITemperatureDated;
|
|
1151
1172
|
minTemperature?: ITemperatureDated;
|
|
1152
|
-
amendment?: true;
|
|
1153
1173
|
trends: TAFTrend[];
|
|
1154
1174
|
}
|
|
1155
1175
|
interface IAbstractTrend extends IAbstractWeatherContainer {
|
|
@@ -1322,4 +1342,4 @@ declare function parseTAF(rawTAF: string, options?: IMetarTAFParserOptions): ITA
|
|
|
1322
1342
|
declare function parseTAF(rawTAF: string, options?: IMetarTAFParserOptionsDated): ITAFDated;
|
|
1323
1343
|
declare function parseTAFAsForecast(rawTAF: string, options: IMetarTAFParserOptionsDated): IForecastContainer;
|
|
1324
1344
|
|
|
1325
|
-
export { CloudQuantity, CloudType, CommandExecutionError, Descriptive, Direction, Distance, DistanceUnit, Forecast, IAbstractTrend, IAbstractValidity, IAbstractWeatherCode, IAbstractWeatherCodeDated, IAbstractWeatherContainer, IAirport, IBaseRemark, IBaseTAFTrend, ICeilingHeightRemark, ICeilingSecondLocationRemark, ICloud, ICompositeForecast, ICountry, IEndValidity, IFMValidity, IForecastContainer, IHourlyMaximumMinimumTemperatureRemark, IHourlyMaximumTemperatureRemark, IHourlyMinimumTemperatureRemark, IHourlyPrecipitationAmountRemark, IHourlyPressureRemark, IHourlyTemperatureDewPointRemark, IIceAccretionRemark, IMetar, IMetarTAFParserOptions, IMetarTAFParserOptionsDated, IMetarTrend, IMetarTrendTime, IObscurationRemark, IPrecipitationAmount24HourRemark, IPrecipitationAmount36HourRemark, IPrecipitationBegEndRemark, IPrevailingVisibilityRemark, IRunwayInfo, ISeaLevelPressureRemark, ISecondLocationVisibilityRemark, ISectorVisibilityRemark, ISmallHailSizeRemark, ISnowIncreaseRemark, ISnowPelletsRemark, ISunshineDurationRemark, ISurfaceVisibilityRemark, ITAF, ITAFDated, ITemperatureDated, IThunderStormLocationMovingRemark, IThunderStormLocationRemark, ITime, ITornadicActivityBegEndRemark, ITornadicActivityBegRemark, ITornadicActivityEndRemark, ITowerVisibilityRemark, IUnknownRemark, IValidity, IValidityDated, IVariableSkyHeightRemark, IVariableSkyRemark, IVirgaDirectionRemark, IWaterEquivalentSnowRemark, IWeatherCondition, IWind, IWindPeakCommandRemark, IWindShear, IWindShiftFropaRemark, Intensity, InvalidWeatherStatementError, Locale, ParseError, Phenomenon, Remark, RemarkType, RunwayInfoTrend, RunwayInfoUnit, TAFTrend, TAFTrendDated, TimeIndicator, TimestampOutOfBoundsError, UnexpectedParseError, ValueIndicator, Visibility, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
|
|
1345
|
+
export { CloudQuantity, CloudType, CommandExecutionError, Descriptive, Direction, Distance, DistanceUnit, Forecast, IAbstractTrend, IAbstractValidity, IAbstractWeatherCode, IAbstractWeatherCodeDated, IAbstractWeatherContainer, IAirport, IBaseRemark, IBaseTAFTrend, ICeilingHeightRemark, ICeilingSecondLocationRemark, ICloud, ICompositeForecast, ICountry, IEndValidity, IFMValidity, IFlags, IForecastContainer, IHourlyMaximumMinimumTemperatureRemark, IHourlyMaximumTemperatureRemark, IHourlyMinimumTemperatureRemark, IHourlyPrecipitationAmountRemark, IHourlyPressureRemark, IHourlyTemperatureDewPointRemark, IIceAccretionRemark, IMetar, IMetarTAFParserOptions, IMetarTAFParserOptionsDated, IMetarTrend, IMetarTrendTime, IObscurationRemark, IPrecipitationAmount24HourRemark, IPrecipitationAmount36HourRemark, IPrecipitationBegEndRemark, IPrevailingVisibilityRemark, IRunwayInfo, ISeaLevelPressureRemark, ISecondLocationVisibilityRemark, ISectorVisibilityRemark, ISmallHailSizeRemark, ISnowIncreaseRemark, ISnowPelletsRemark, ISunshineDurationRemark, ISurfaceVisibilityRemark, ITAF, ITAFDated, ITemperatureDated, IThunderStormLocationMovingRemark, IThunderStormLocationRemark, ITime, ITornadicActivityBegEndRemark, ITornadicActivityBegRemark, ITornadicActivityEndRemark, ITowerVisibilityRemark, IUnknownRemark, IValidity, IValidityDated, IVariableSkyHeightRemark, IVariableSkyRemark, IVirgaDirectionRemark, IWaterEquivalentSnowRemark, IWeatherCondition, IWind, IWindPeakCommandRemark, IWindShear, IWindShiftFropaRemark, Intensity, InvalidWeatherStatementError, Locale, ParseError, Phenomenon, Remark, RemarkType, RunwayInfoTrend, RunwayInfoUnit, TAFTrend, TAFTrendDated, TimeIndicator, TimestampOutOfBoundsError, UnexpectedParseError, ValueIndicator, Visibility, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
|
package/metar-taf-parser.js
CHANGED
|
@@ -87,7 +87,7 @@ function pySplit(string, separator, n) {
|
|
|
87
87
|
*/
|
|
88
88
|
function resolve(obj, path, separator = ".") {
|
|
89
89
|
const properties = Array.isArray(path) ? path : path.split(separator);
|
|
90
|
-
return properties.reduce((prev, curr) => prev
|
|
90
|
+
return properties.reduce((prev, curr) => prev?.[curr], obj);
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
93
|
* For safely casting input values
|
|
@@ -1537,7 +1537,7 @@ class DefaultCommand extends Command {
|
|
|
1537
1537
|
}
|
|
1538
1538
|
else {
|
|
1539
1539
|
const lastRemark = remark[remark.length - 1];
|
|
1540
|
-
if (
|
|
1540
|
+
if (lastRemark?.type === RemarkType.Unknown) {
|
|
1541
1541
|
// Merge with last unknown value
|
|
1542
1542
|
lastRemark.raw = `${lastRemark.raw} ${rmkSplit[0]}`;
|
|
1543
1543
|
}
|
|
@@ -1562,13 +1562,12 @@ class PrecipitationBegCommand extends Command {
|
|
|
1562
1562
|
return __classPrivateFieldGet(this, _PrecipitationBegCommand_regex, "f").test(code);
|
|
1563
1563
|
}
|
|
1564
1564
|
execute(code, remark) {
|
|
1565
|
-
var _a;
|
|
1566
1565
|
const matches = code.match(__classPrivateFieldGet(this, _PrecipitationBegCommand_regex, "f"));
|
|
1567
1566
|
if (!matches)
|
|
1568
1567
|
throw new UnexpectedParseError("Match not found");
|
|
1569
1568
|
const descriptive = matches[2] ? as(matches[2], Descriptive) : undefined;
|
|
1570
1569
|
const phenomenon = as(matches[3], Phenomenon);
|
|
1571
|
-
const description =
|
|
1570
|
+
const description = format(_("Remark.Precipitation.Beg.0", this.locale), descriptive ? _(`Descriptive.${descriptive}`, this.locale) : "", _(`Phenomenon.${phenomenon}`, this.locale), matches[4] || "", matches[5])?.trim();
|
|
1572
1571
|
remark.push({
|
|
1573
1572
|
type: RemarkType.PrecipitationBeg,
|
|
1574
1573
|
description,
|
|
@@ -1593,13 +1592,12 @@ class PrecipitationEndCommand extends Command {
|
|
|
1593
1592
|
return __classPrivateFieldGet(this, _PrecipitationEndCommand_regex, "f").test(code);
|
|
1594
1593
|
}
|
|
1595
1594
|
execute(code, remark) {
|
|
1596
|
-
var _a;
|
|
1597
1595
|
const matches = code.match(__classPrivateFieldGet(this, _PrecipitationEndCommand_regex, "f"));
|
|
1598
1596
|
if (!matches)
|
|
1599
1597
|
throw new UnexpectedParseError("Match not found");
|
|
1600
1598
|
const descriptive = matches[2] ? as(matches[2], Descriptive) : undefined;
|
|
1601
1599
|
const phenomenon = as(matches[3], Phenomenon);
|
|
1602
|
-
const description =
|
|
1600
|
+
const description = format(_("Remark.Precipitation.End", this.locale), descriptive ? _(`Descriptive.${descriptive}`, this.locale) : "", _(`Phenomenon.${phenomenon}`, this.locale), matches[4] || "", matches[5])?.trim();
|
|
1603
1601
|
remark.push({
|
|
1604
1602
|
type: RemarkType.PrecipitationEnd,
|
|
1605
1603
|
description,
|
|
@@ -1790,7 +1788,7 @@ class MainVisibilityCommand {
|
|
|
1790
1788
|
const distance = convertVisibility(matches[1]);
|
|
1791
1789
|
if (!container.visibility)
|
|
1792
1790
|
container.visibility = distance;
|
|
1793
|
-
container.visibility =
|
|
1791
|
+
container.visibility = { ...container.visibility, ...distance };
|
|
1794
1792
|
if (matches[2] === "NDV")
|
|
1795
1793
|
container.visibility.ndv = true;
|
|
1796
1794
|
return true;
|
|
@@ -1850,7 +1848,10 @@ class WindShearCommand {
|
|
|
1850
1848
|
const matches = windString.match(__classPrivateFieldGet(this, _WindShearCommand_regex, "f"));
|
|
1851
1849
|
if (!matches)
|
|
1852
1850
|
throw new UnexpectedParseError("Wind shear should be defined");
|
|
1853
|
-
return
|
|
1851
|
+
return {
|
|
1852
|
+
...makeWind(matches[2], matches[3], matches[4], matches[5]),
|
|
1853
|
+
height: 100 * +matches[1],
|
|
1854
|
+
};
|
|
1854
1855
|
}
|
|
1855
1856
|
execute(container, windString) {
|
|
1856
1857
|
container.windShear = this.parseWindShear(windString);
|
|
@@ -2070,6 +2071,24 @@ function parseDeliveryTime(timeString) {
|
|
|
2070
2071
|
minute,
|
|
2071
2072
|
};
|
|
2072
2073
|
}
|
|
2074
|
+
function parseFlags(abstractWeatherCode, flag) {
|
|
2075
|
+
const flags = findFlags(flag);
|
|
2076
|
+
if (flags)
|
|
2077
|
+
Object.assign(abstractWeatherCode, flags);
|
|
2078
|
+
return !!flags;
|
|
2079
|
+
}
|
|
2080
|
+
var FlagMap;
|
|
2081
|
+
(function (FlagMap) {
|
|
2082
|
+
FlagMap["AMD"] = "amendment";
|
|
2083
|
+
FlagMap["AUTO"] = "auto";
|
|
2084
|
+
FlagMap["CNL"] = "canceled";
|
|
2085
|
+
FlagMap["COR"] = "corrected";
|
|
2086
|
+
FlagMap["NIL"] = "nil";
|
|
2087
|
+
})(FlagMap || (FlagMap = {}));
|
|
2088
|
+
function findFlags(flag) {
|
|
2089
|
+
if (flag in FlagMap)
|
|
2090
|
+
return { [FlagMap[flag]]: true };
|
|
2091
|
+
}
|
|
2073
2092
|
/**
|
|
2074
2093
|
* This function parses the array containing the remark and concat the array into a string
|
|
2075
2094
|
* @param container the metar, taf or taf trend to update
|
|
@@ -2140,10 +2159,9 @@ class AbstractParser {
|
|
|
2140
2159
|
_AbstractParser_commonSupplier.set(this, new CommandSupplier$1());
|
|
2141
2160
|
}
|
|
2142
2161
|
parseWeatherCondition(input) {
|
|
2143
|
-
var _a;
|
|
2144
2162
|
let intensity;
|
|
2145
2163
|
if (input.match(__classPrivateFieldGet(this, _AbstractParser_INTENSITY_REGEX, "f"))) {
|
|
2146
|
-
const match =
|
|
2164
|
+
const match = input.match(__classPrivateFieldGet(this, _AbstractParser_INTENSITY_REGEX, "f"))?.[0];
|
|
2147
2165
|
if (match)
|
|
2148
2166
|
intensity = match;
|
|
2149
2167
|
}
|
|
@@ -2184,7 +2202,6 @@ class AbstractParser {
|
|
|
2184
2202
|
if (digitRegex.test(splitted[i])) {
|
|
2185
2203
|
if (splitted[i + 1] && smRegex.test(splitted[i + 1])) {
|
|
2186
2204
|
splitted.splice(i, 2, `${splitted[i]} ${splitted[i + 1]}`);
|
|
2187
|
-
i--;
|
|
2188
2205
|
}
|
|
2189
2206
|
}
|
|
2190
2207
|
}
|
|
@@ -2262,16 +2279,23 @@ class MetarParser extends AbstractParser {
|
|
|
2262
2279
|
*/
|
|
2263
2280
|
parse(input) {
|
|
2264
2281
|
const metarTab = this.tokenize(input);
|
|
2265
|
-
const metar =
|
|
2282
|
+
const metar = {
|
|
2283
|
+
...parseDeliveryTime(metarTab[1]),
|
|
2284
|
+
station: metarTab[0],
|
|
2285
|
+
message: input,
|
|
2286
|
+
remarks: [],
|
|
2287
|
+
clouds: [],
|
|
2288
|
+
weatherConditions: [],
|
|
2289
|
+
trends: [],
|
|
2290
|
+
runwaysInfo: [],
|
|
2291
|
+
};
|
|
2266
2292
|
let index = 2;
|
|
2267
2293
|
while (index < metarTab.length) {
|
|
2268
|
-
if (!super.generalParse(metar, metarTab[index])
|
|
2294
|
+
if (!super.generalParse(metar, metarTab[index]) &&
|
|
2295
|
+
!parseFlags(metar, metarTab[index])) {
|
|
2269
2296
|
if (metarTab[index] === "NOSIG") {
|
|
2270
2297
|
metar.nosig = true;
|
|
2271
2298
|
}
|
|
2272
|
-
else if (metarTab[index] === "AUTO") {
|
|
2273
|
-
metar.auto = true;
|
|
2274
|
-
}
|
|
2275
2299
|
else if (metarTab[index] === this.TEMPO ||
|
|
2276
2300
|
metarTab[index] === this.BECMG) {
|
|
2277
2301
|
const trend = {
|
|
@@ -2319,15 +2343,14 @@ class TAFParser extends AbstractParser {
|
|
|
2319
2343
|
* @throws ParseError if the message is invalid
|
|
2320
2344
|
*/
|
|
2321
2345
|
parse(input) {
|
|
2322
|
-
let amendment;
|
|
2323
2346
|
const lines = this.extractLinesTokens(input);
|
|
2324
2347
|
let index = 0;
|
|
2325
2348
|
if (lines[0][0] === this.TAF)
|
|
2326
2349
|
index = 1;
|
|
2327
2350
|
if (lines[0][1] === this.TAF)
|
|
2328
2351
|
index = 2;
|
|
2329
|
-
|
|
2330
|
-
|
|
2352
|
+
const flags = findFlags(lines[0][index]);
|
|
2353
|
+
if (flags) {
|
|
2331
2354
|
index += 1;
|
|
2332
2355
|
}
|
|
2333
2356
|
const station = lines[0][index];
|
|
@@ -2335,8 +2358,17 @@ class TAFParser extends AbstractParser {
|
|
|
2335
2358
|
const time = parseDeliveryTime(lines[0][index]);
|
|
2336
2359
|
index += 1;
|
|
2337
2360
|
const validity = parseValidity(lines[0][index]);
|
|
2338
|
-
const taf =
|
|
2339
|
-
|
|
2361
|
+
const taf = {
|
|
2362
|
+
station,
|
|
2363
|
+
...flags,
|
|
2364
|
+
...time,
|
|
2365
|
+
validity,
|
|
2366
|
+
message: input,
|
|
2367
|
+
trends: [],
|
|
2368
|
+
remarks: [],
|
|
2369
|
+
clouds: [],
|
|
2370
|
+
weatherConditions: [],
|
|
2371
|
+
};
|
|
2340
2372
|
for (let i = index + 1; i < lines[0].length; i++) {
|
|
2341
2373
|
const token = lines[0][i];
|
|
2342
2374
|
if (token == this.RMK) {
|
|
@@ -2347,8 +2379,10 @@ class TAFParser extends AbstractParser {
|
|
|
2347
2379
|
taf.maxTemperature = parseTemperature(token);
|
|
2348
2380
|
else if (token.startsWith(this.TN))
|
|
2349
2381
|
taf.minTemperature = parseTemperature(token);
|
|
2350
|
-
else
|
|
2382
|
+
else {
|
|
2383
|
+
parseFlags(taf, token);
|
|
2351
2384
|
this.generalParse(taf, token);
|
|
2385
|
+
}
|
|
2352
2386
|
}
|
|
2353
2387
|
// Handle the other lines
|
|
2354
2388
|
for (let i = 1; i < lines.length; i++) {
|
|
@@ -2370,9 +2404,8 @@ class TAFParser extends AbstractParser {
|
|
|
2370
2404
|
// TODO cleanup
|
|
2371
2405
|
function joinProbIfNeeded(ls) {
|
|
2372
2406
|
for (let i = 0; i < ls.length; i++) {
|
|
2373
|
-
if (
|
|
2407
|
+
if (/^PROB\d{2}$/.test(ls[i]) && /^TEMPO/.test(ls[i + 1])) {
|
|
2374
2408
|
ls.splice(i, 2, `${ls[i]} ${ls[i + 1]}`);
|
|
2375
|
-
i--;
|
|
2376
2409
|
}
|
|
2377
2410
|
}
|
|
2378
2411
|
return ls;
|
|
@@ -2397,15 +2430,27 @@ class TAFParser extends AbstractParser {
|
|
|
2397
2430
|
let index = 1;
|
|
2398
2431
|
let trend;
|
|
2399
2432
|
if (lineTokens[0].startsWith(this.FM)) {
|
|
2400
|
-
trend =
|
|
2433
|
+
trend = {
|
|
2434
|
+
...this.makeEmptyTAFTrend(),
|
|
2435
|
+
type: WeatherChangeType.FM,
|
|
2436
|
+
validity: parseFromValidity(lineTokens[0]),
|
|
2437
|
+
};
|
|
2401
2438
|
}
|
|
2402
2439
|
else if (lineTokens[0].startsWith(this.PROB)) {
|
|
2403
2440
|
const validity = this.findLineValidity(index, lineTokens);
|
|
2404
2441
|
if (!validity)
|
|
2405
2442
|
return;
|
|
2406
|
-
trend =
|
|
2443
|
+
trend = {
|
|
2444
|
+
...this.makeEmptyTAFTrend(),
|
|
2445
|
+
type: WeatherChangeType.PROB,
|
|
2446
|
+
validity,
|
|
2447
|
+
};
|
|
2407
2448
|
if (lineTokens.length > 1 && lineTokens[1] === this.TEMPO) {
|
|
2408
|
-
trend =
|
|
2449
|
+
trend = {
|
|
2450
|
+
...this.makeEmptyTAFTrend(),
|
|
2451
|
+
type: WeatherChangeType[lineTokens[1]],
|
|
2452
|
+
validity,
|
|
2453
|
+
};
|
|
2409
2454
|
index = 2;
|
|
2410
2455
|
}
|
|
2411
2456
|
trend.probability = +lineTokens[0].slice(4);
|
|
@@ -2414,7 +2459,11 @@ class TAFParser extends AbstractParser {
|
|
|
2414
2459
|
const validity = this.findLineValidity(index, lineTokens);
|
|
2415
2460
|
if (!validity)
|
|
2416
2461
|
return;
|
|
2417
|
-
trend =
|
|
2462
|
+
trend = {
|
|
2463
|
+
...this.makeEmptyTAFTrend(),
|
|
2464
|
+
type: WeatherChangeType[lineTokens[0]],
|
|
2465
|
+
validity,
|
|
2466
|
+
};
|
|
2418
2467
|
}
|
|
2419
2468
|
this.parseTrend(index, lineTokens, trend);
|
|
2420
2469
|
taf.trends.push(trend);
|
|
@@ -2540,19 +2589,41 @@ function addMonthsUTC(date, count) {
|
|
|
2540
2589
|
}
|
|
2541
2590
|
|
|
2542
2591
|
function metarDatesHydrator(report, date) {
|
|
2543
|
-
return
|
|
2592
|
+
return {
|
|
2593
|
+
...report,
|
|
2594
|
+
issued: determineReportIssuedDate(date, report.day, report.hour, report.minute),
|
|
2595
|
+
};
|
|
2544
2596
|
}
|
|
2545
2597
|
|
|
2546
2598
|
function tafDatesHydrator(report, date) {
|
|
2547
2599
|
const issued = determineReportIssuedDate(date, report.day, report.hour, report.minute);
|
|
2548
|
-
return
|
|
2600
|
+
return {
|
|
2601
|
+
...report,
|
|
2602
|
+
issued,
|
|
2603
|
+
validity: {
|
|
2604
|
+
...report.validity,
|
|
2605
|
+
start: getReportDate(issued, report.validity.startDay, report.validity.startHour),
|
|
2606
|
+
end: getReportDate(issued, report.validity.endDay, report.validity.endHour),
|
|
2607
|
+
},
|
|
2608
|
+
trends: report.trends.map((trend) => ({
|
|
2609
|
+
...trend,
|
|
2610
|
+
validity: (() => {
|
|
2549
2611
|
switch (trend.type) {
|
|
2550
2612
|
case WeatherChangeType.FM:
|
|
2551
|
-
return
|
|
2613
|
+
return {
|
|
2614
|
+
...trend.validity,
|
|
2615
|
+
start: getReportDate(issued, trend.validity.startDay, trend.validity.startHour, trend.validity.startMinutes),
|
|
2616
|
+
};
|
|
2552
2617
|
default:
|
|
2553
|
-
return
|
|
2618
|
+
return {
|
|
2619
|
+
...trend.validity,
|
|
2620
|
+
start: getReportDate(issued, trend.validity.startDay, trend.validity.startHour),
|
|
2621
|
+
end: getReportDate(issued, trend.validity.endDay, trend.validity.endHour),
|
|
2622
|
+
};
|
|
2554
2623
|
}
|
|
2555
|
-
})()
|
|
2624
|
+
})(),
|
|
2625
|
+
})),
|
|
2626
|
+
};
|
|
2556
2627
|
}
|
|
2557
2628
|
|
|
2558
2629
|
function getForecastFromTAF(taf) {
|
|
@@ -2631,7 +2702,7 @@ function parseTAFAsForecast(rawTAF, options) {
|
|
|
2631
2702
|
return getForecastFromTAF(taf);
|
|
2632
2703
|
}
|
|
2633
2704
|
function parse(rawReport, options, parser, datesHydrator) {
|
|
2634
|
-
const lang =
|
|
2705
|
+
const lang = options?.locale || en;
|
|
2635
2706
|
try {
|
|
2636
2707
|
const report = new parser(lang).parse(rawReport);
|
|
2637
2708
|
if (options && "date" in options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metar-taf-parser",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Parse METAR and TAF reports",
|
|
5
5
|
"homepage": "https://aeharding.github.io/metar-taf-parser",
|
|
6
6
|
"keywords": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"build": "yarn clean && rollup -c rollup.config.ts && cp -R dist/locale/. locale/ && cp dist/metar-taf-parser.js metar-taf-parser.js && yarn clean:after",
|
|
26
26
|
"clean:after": "rimraf dist",
|
|
27
27
|
"start": "rollup -c rollup.config.ts -w",
|
|
28
|
-
"check-types": "tsc --noEmit",
|
|
28
|
+
"check-types": "tsc --skipLibCheck --noEmit",
|
|
29
29
|
"check-formatting": "prettier --check '**/*.{js,json,css,md,scss,tsx,ts}'",
|
|
30
30
|
"watch": "watch 'yarn build' src",
|
|
31
31
|
"test": "jest --coverage",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"prettier": "^2.6.2",
|
|
48
48
|
"rollup": "^2.71.1",
|
|
49
49
|
"rollup-plugin-dts": "^4.2.1",
|
|
50
|
-
"ts-jest": "28.0.
|
|
50
|
+
"ts-jest": "^28.0.1",
|
|
51
51
|
"ts-node": "^10.7.0",
|
|
52
52
|
"tsc-alias": "^1.6.7",
|
|
53
53
|
"tslib": "^2.4.0",
|