metar-taf-parser 8.0.5 → 9.0.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/README.md CHANGED
@@ -19,7 +19,7 @@ Features:
19
19
  ## Installation
20
20
 
21
21
  ```sh
22
- yarn add metar-taf-parser
22
+ pnpm i metar-taf-parser
23
23
  # or
24
24
  npm i --save metar-taf-parser
25
25
  ```
@@ -1564,4 +1564,4 @@ declare function parseTAF(rawTAF: string, options?: IMetarTAFParserOptions): ITA
1564
1564
  declare function parseTAF(rawTAF: string, options?: IMetarTAFParserOptionsDated): ITAFDated;
1565
1565
  declare function parseTAFAsForecast(rawTAF: string, options: IMetarTAFParserOptionsDated): IForecastContainer;
1566
1566
 
1567
- export { AltimeterUnit, CloudQuantity, CloudType, CommandExecutionError, DepositCoverage, DepositType, Descriptive, Direction, Distance, DistanceUnit, Forecast, IAbstractTrend, IAbstractValidity, IAbstractWeatherCode, IAbstractWeatherCodeDated, IAbstractWeatherContainer, IAltimeter, IBaseRemark, IBaseRunwayInfo, IBaseTAFTrend, ICeilingHeightRemark, ICeilingSecondLocationRemark, ICloud, ICompositeForecast, IEndValidity, IFMValidity, IFlags, IForecastContainer, IHourlyMaximumMinimumTemperatureRemark, IHourlyMaximumTemperatureRemark, IHourlyMinimumTemperatureRemark, IHourlyPrecipitationAmountRemark, IHourlyPressureRemark, IHourlyTemperatureDewPointRemark, IIceAccretionRemark, IIcing, IMetar, IMetarDated, IMetarTAFParserOptions, IMetarTAFParserOptionsDated, IMetarTrend, IMetarTrendTime, IObscurationRemark, IPrecipitationAmount24HourRemark, IPrecipitationAmount36HourRemark, IPrecipitationBegEndRemark, IPrevailingVisibilityRemark, IRunwayInfoDeposit, IRunwayInfoRange, ISeaLevelPressureRemark, ISecondLocationVisibilityRemark, ISectorVisibilityRemark, ISmallHailSizeRemark, ISnowIncreaseRemark, ISnowPelletsRemark, ISunshineDurationRemark, ISurfaceVisibilityRemark, ITAF, ITAFDated, ITafGroups, ITemperature, ITemperatureDated, IThunderStormLocationMovingRemark, IThunderStormLocationRemark, ITime, ITornadicActivityBegEndRemark, ITornadicActivityBegRemark, ITornadicActivityEndRemark, ITowerVisibilityRemark, ITurbulence, IUnknownRemark, IValidity, IValidityDated, IVariableSkyHeightRemark, IVariableSkyRemark, IVirgaDirectionRemark, IWaterEquivalentSnowRemark, IWeatherCondition, IWind, IWindPeakCommandRemark, IWindShear, IWindShiftFropaRemark, IcingIntensity, Intensity, InvalidWeatherStatementError, Locale, MetarType, ParseError, PartialWeatherStatementError, Phenomenon, Remark, RemarkType, RunwayInfo, RunwayInfoTrend, RunwayInfoUnit, SpeedUnit, TAFTrend, TAFTrendDated, TimeIndicator, TimestampOutOfBoundsError, TurbulenceIntensity, UnexpectedParseError, ValueIndicator, Visibility, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
1567
+ 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 };
@@ -14,12 +14,26 @@ 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 */
18
+
17
19
 
18
20
  function __classPrivateFieldGet(receiver, state, kind, f) {
19
21
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
20
22
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
21
23
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
22
- }
24
+ }
25
+
26
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
27
+ if (kind === "m") throw new TypeError("Private method is not writable");
28
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
29
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
30
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
31
+ }
32
+
33
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
34
+ var e = new Error(message);
35
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
36
+ };
23
37
 
24
38
  class ParseError extends Error {
25
39
  constructor(message) {
@@ -2029,7 +2043,7 @@ class MainVisibilityNauticalMilesCommand {
2029
2043
  }
2030
2044
  }
2031
2045
  _MainVisibilityNauticalMilesCommand_regex = new WeakMap();
2032
- class CommandSupplier$2 {
2046
+ let CommandSupplier$2 = class CommandSupplier {
2033
2047
  constructor() {
2034
2048
  _CommandSupplier_commands$2.set(this, [
2035
2049
  new WindShearCommand(),
@@ -2048,7 +2062,7 @@ class CommandSupplier$2 {
2048
2062
  return command;
2049
2063
  }
2050
2064
  }
2051
- }
2065
+ };
2052
2066
  _CommandSupplier_commands$2 = new WeakMap();
2053
2067
 
2054
2068
  var _AltimeterCommand_regex;
@@ -2174,7 +2188,7 @@ class TemperatureCommand {
2174
2188
  _TemperatureCommand_regex = new WeakMap();
2175
2189
 
2176
2190
  var _CommandSupplier_commands$1;
2177
- class CommandSupplier$1 {
2191
+ let CommandSupplier$1 = class CommandSupplier {
2178
2192
  constructor() {
2179
2193
  _CommandSupplier_commands$1.set(this, [
2180
2194
  new RunwayCommand(),
@@ -2189,7 +2203,7 @@ class CommandSupplier$1 {
2189
2203
  return command;
2190
2204
  }
2191
2205
  }
2192
- }
2206
+ };
2193
2207
  _CommandSupplier_commands$1 = new WeakMap();
2194
2208
 
2195
2209
  var _IcingCommand_regex;
@@ -2252,7 +2266,7 @@ class CommandSupplier {
2252
2266
  }
2253
2267
  _CommandSupplier_commands = new WeakMap();
2254
2268
 
2255
- var _AbstractParser_INTENSITY_REGEX, _AbstractParser_CAVOK, _AbstractParser_commonSupplier, _MetarParser_commandSupplier, _TAFParser_commandSupplier, _TAFParser_validityPattern, _TAFParser_partialPattern, _RemarkParser_supplier;
2269
+ var _a, _AbstractParser_TOKENIZE_REGEX, _AbstractParser_INTENSITY_REGEX, _AbstractParser_CAVOK, _AbstractParser_commonSupplier, _MetarParser_commandSupplier, _TAFParser_commandSupplier, _TAFParser_validityPattern, _TAFParser_partialPattern, _RemarkParser_supplier;
2256
2270
  function isStation(stationString) {
2257
2271
  return stationString.length === 4;
2258
2272
  }
@@ -2355,16 +2369,11 @@ class AbstractParser {
2355
2369
  this.INTER = "INTER";
2356
2370
  this.BECMG = "BECMG";
2357
2371
  this.RMK = "RMK";
2358
- // Safari does not currently support negative lookbehind
2359
- // #TOKENIZE_REGEX = /\s((?=\d\/\dSM)(?<!\s\d\s)|(?!\d\/\dSM))|=/;
2360
- _AbstractParser_INTENSITY_REGEX.set(this, /^(-|\+|VC)/);
2361
- _AbstractParser_CAVOK.set(this, "CAVOK");
2362
- _AbstractParser_commonSupplier.set(this, new CommandSupplier$2());
2363
2372
  }
2364
2373
  parseWeatherCondition(input) {
2365
2374
  let intensity;
2366
- if (input.match(__classPrivateFieldGet(this, _AbstractParser_INTENSITY_REGEX, "f"))) {
2367
- const match = input.match(__classPrivateFieldGet(this, _AbstractParser_INTENSITY_REGEX, "f"))?.[0];
2375
+ if (input.match(__classPrivateFieldGet(_a, _a, "f", _AbstractParser_INTENSITY_REGEX))) {
2376
+ const match = input.match(__classPrivateFieldGet(_a, _a, "f", _AbstractParser_INTENSITY_REGEX))?.[0];
2368
2377
  if (match) {
2369
2378
  intensity = match;
2370
2379
  input = input.slice(match.length);
@@ -2413,22 +2422,7 @@ class AbstractParser {
2413
2422
  * @returns List of tokens
2414
2423
  */
2415
2424
  tokenize(input) {
2416
- // Missing safari support. If added in the future, put this back
2417
- // return input.split(this.#TOKENIZE_REGEX).filter((v) => v);
2418
- // Hack for safari below...
2419
- const splitRegex = /\s|=/;
2420
- const smRegex = /^\d\/\dSM$/;
2421
- const digitRegex = /^(P|M)?\d$/;
2422
- // return input.split(this.#TOKENIZE_REGEX).filter((v) => v);
2423
- const splitted = input.split(splitRegex);
2424
- for (let i = 0; i < splitted.length; i++) {
2425
- if (digitRegex.test(splitted[i])) {
2426
- if (splitted[i + 1] && smRegex.test(splitted[i + 1])) {
2427
- splitted.splice(i, 2, `${splitted[i]} ${splitted[i + 1]}`);
2428
- }
2429
- }
2430
- }
2431
- return splitted.filter((t) => t);
2425
+ return input.split(__classPrivateFieldGet(_a, _a, "f", _AbstractParser_TOKENIZE_REGEX)).filter((v) => v);
2432
2426
  }
2433
2427
  /**
2434
2428
  * Common parse method for METAR, TAF and trends object
@@ -2437,7 +2431,7 @@ class AbstractParser {
2437
2431
  * @returns True if the token was parsed false otherwise
2438
2432
  */
2439
2433
  generalParse(abstractWeatherContainer, input) {
2440
- if (input === __classPrivateFieldGet(this, _AbstractParser_CAVOK, "f")) {
2434
+ if (input === __classPrivateFieldGet(_a, _a, "f", _AbstractParser_CAVOK)) {
2441
2435
  abstractWeatherContainer.cavok = true;
2442
2436
  abstractWeatherContainer.visibility = {
2443
2437
  indicator: ValueIndicator.GreaterThan,
@@ -2451,7 +2445,7 @@ class AbstractParser {
2451
2445
  abstractWeatherContainer.weatherConditions.push(weatherCondition);
2452
2446
  return true;
2453
2447
  }
2454
- const command = __classPrivateFieldGet(this, _AbstractParser_commonSupplier, "f").get(input);
2448
+ const command = __classPrivateFieldGet(_a, _a, "f", _AbstractParser_commonSupplier).get(input);
2455
2449
  if (command) {
2456
2450
  try {
2457
2451
  return command.execute(abstractWeatherContainer, input);
@@ -2465,7 +2459,11 @@ class AbstractParser {
2465
2459
  return false;
2466
2460
  }
2467
2461
  }
2468
- _AbstractParser_INTENSITY_REGEX = new WeakMap(), _AbstractParser_CAVOK = new WeakMap(), _AbstractParser_commonSupplier = new WeakMap();
2462
+ _a = AbstractParser;
2463
+ _AbstractParser_TOKENIZE_REGEX = { value: /\s((?=\d\/\dSM)(?<!\s(P|M)?\d\s)|(?!\d\/\dSM))|=/ };
2464
+ _AbstractParser_INTENSITY_REGEX = { value: /^(-|\+|VC)/ };
2465
+ _AbstractParser_CAVOK = { value: "CAVOK" };
2466
+ _AbstractParser_commonSupplier = { value: new CommandSupplier$2() };
2469
2467
  class MetarParser extends AbstractParser {
2470
2468
  constructor() {
2471
2469
  super(...arguments);
@@ -2820,7 +2818,8 @@ _TAFParser_commandSupplier = new WeakMap(), _TAFParser_validityPattern = new Wea
2820
2818
  class RemarkParser {
2821
2819
  constructor(locale) {
2822
2820
  this.locale = locale;
2823
- _RemarkParser_supplier.set(this, new RemarkCommandSupplier(this.locale));
2821
+ _RemarkParser_supplier.set(this, void 0);
2822
+ __classPrivateFieldSet(this, _RemarkParser_supplier, new RemarkCommandSupplier(this.locale), "f");
2824
2823
  }
2825
2824
  parse(code) {
2826
2825
  let rmkStr = code;
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "metar-taf-parser",
3
- "version": "8.0.5",
3
+ "version": "9.0.0",
4
4
  "description": "Parse METAR and TAF reports",
5
5
  "homepage": "https://aeharding.github.io/metar-taf-parser",
6
+ "packageManager": "pnpm@9.0.6+sha256.0624e30eff866cdeb363b15061bdb7fd9425b17bc1bb42c22f5f4efdea21f6b3",
6
7
  "keywords": [
7
8
  "aviation",
8
9
  "weather",
@@ -22,36 +23,39 @@
22
23
  },
23
24
  "scripts": {
24
25
  "clean": "rimraf dist locale metar-taf-parser.*",
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
+ "build": "pnpm clean && rollup -c rollup.config.ts --configPlugin typescript && cp -R dist/locale/. locale/ && cp dist/metar-taf-parser.js metar-taf-parser.js && pnpm clean:after",
26
27
  "clean:after": "rimraf dist",
27
- "start": "rollup -c rollup.config.ts -w",
28
+ "start": "rollup -c rollup.config.ts -w --configPlugin typescript",
28
29
  "check-types": "tsc --skipLibCheck --noEmit",
29
30
  "check-formatting": "prettier --check '**/*.{js,json,css,md,scss,tsx,ts}'",
30
- "watch": "watch 'yarn build' src",
31
+ "watch": "watch 'pnpm build' src",
31
32
  "test": "jest --coverage",
32
33
  "test-watch": "jest --watch --coverage",
33
- "prepublishOnly": "yarn clean && yarn build"
34
+ "prepublishOnly": "pnpm clean && pnpm build",
35
+ "upgrade:packageManager": "corepack use pnpm@latest"
34
36
  },
35
37
  "files": [
36
38
  "locale",
37
39
  "metar-taf-parser.*"
38
40
  ],
39
41
  "devDependencies": {
40
- "@babel/preset-env": "^7.17.10",
41
- "@babel/preset-typescript": "^7.16.7",
42
- "@rollup/plugin-typescript": "^8.3.2",
43
- "@types/jest": "^27.5.0",
44
- "@types/lodash": "^4.14.182",
45
- "jest": "^28",
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",
48
+ "jest": "^29.7.0",
46
49
  "lodash": "^4.17.21",
47
- "prettier": "^2.6.2",
48
- "rollup": "^2.71.1",
49
- "rollup-plugin-dts": "^4.2.1",
50
- "ts-jest": "^28.0.1",
51
- "ts-node": "^10.7.0",
52
- "tsc-alias": "^1.6.7",
53
- "tslib": "^2.4.0",
54
- "typescript": "^4.6.4",
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",
55
+ "ts-node": "^10.9.2",
56
+ "tsc-alias": "^1.8.8",
57
+ "tslib": "^2.6.2",
58
+ "typescript": "^5.4.5",
55
59
  "watch": "^1.0.2"
56
60
  }
57
61
  }