metar-taf-parser 1.0.2 → 1.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/README.md +1 -1
- package/dist/commons/i18n.js +2 -2
- package/dist/helpers/helpers.d.ts +6 -0
- package/dist/helpers/helpers.js +11 -1
- package/package.json +1 -8
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ✈️ [metar-taf-parser](https://aeharding.github.io/metar-taf-parser)
|
|
2
2
|
|
|
3
|
-
This is a port of [python-metar-taf-parser](https://github.com/mivek/python-metar-taf-parser) to Typescript. It's fully typed
|
|
3
|
+
This is a port of [python-metar-taf-parser](https://github.com/mivek/python-metar-taf-parser) to Typescript. It's dependency-free, fully typed, tested, has i18n support, and can run on Node or the browser.
|
|
4
4
|
|
|
5
5
|
[Check out the demo here](https://aeharding.github.io/metar-taf-parser)
|
|
6
6
|
|
package/dist/commons/i18n.js
CHANGED
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.format = exports._ = void 0;
|
|
7
7
|
const en_1 = __importDefault(require("../locale/en"));
|
|
8
|
-
const
|
|
8
|
+
const helpers_1 = require("../helpers/helpers");
|
|
9
9
|
const errors_1 = require("./errors");
|
|
10
10
|
exports.default = en_1.default;
|
|
11
11
|
function _(path, lang) {
|
|
12
|
-
const translation = (0,
|
|
12
|
+
const translation = (0, helpers_1.resolve)(lang, path);
|
|
13
13
|
if (!translation || typeof translation !== "string")
|
|
14
14
|
throw new errors_1.TranslationError(path);
|
|
15
15
|
return translation;
|
|
@@ -2,3 +2,9 @@
|
|
|
2
2
|
* Split behaving similar to Python's implementation
|
|
3
3
|
*/
|
|
4
4
|
export declare function pySplit(string: string, separator: string, n?: number): string[];
|
|
5
|
+
/**
|
|
6
|
+
* Access nested object properties by string path
|
|
7
|
+
*
|
|
8
|
+
* https://stackoverflow.com/a/22129960
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolve(obj: any, path: string | string[], separator?: string): unknown;
|
package/dist/helpers/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pySplit = void 0;
|
|
3
|
+
exports.resolve = exports.pySplit = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Split behaving similar to Python's implementation
|
|
6
6
|
*/
|
|
@@ -21,3 +21,13 @@ function pySplit(string, separator, n) {
|
|
|
21
21
|
return out;
|
|
22
22
|
}
|
|
23
23
|
exports.pySplit = pySplit;
|
|
24
|
+
/**
|
|
25
|
+
* Access nested object properties by string path
|
|
26
|
+
*
|
|
27
|
+
* https://stackoverflow.com/a/22129960
|
|
28
|
+
*/
|
|
29
|
+
function resolve(obj, path, separator = ".") {
|
|
30
|
+
const properties = Array.isArray(path) ? path : path.split(separator);
|
|
31
|
+
return properties.reduce((prev, curr) => prev === null || prev === void 0 ? void 0 : prev[curr], obj);
|
|
32
|
+
}
|
|
33
|
+
exports.resolve = resolve;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metar-taf-parser",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Parse METAR and TAF reports",
|
|
5
5
|
"homepage": "https://aeharding.github.io/metar-taf-parser",
|
|
6
6
|
"keywords": [
|
|
@@ -37,10 +37,7 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@babel/preset-env": "^7.16.11",
|
|
39
39
|
"@babel/preset-typescript": "^7.16.7",
|
|
40
|
-
"@types/fs-extra": "^9.0.12",
|
|
41
40
|
"@types/jest": "^27.4.1",
|
|
42
|
-
"@types/lodash": "^4.14.181",
|
|
43
|
-
"fs-extra": "^10.0.0",
|
|
44
41
|
"jest": "^27.5.1",
|
|
45
42
|
"prettier": "^2.6.2",
|
|
46
43
|
"ts-jest": "^27.1.4",
|
|
@@ -48,9 +45,5 @@
|
|
|
48
45
|
"tsc-alias": "^1.6.6",
|
|
49
46
|
"typescript": "^4.4.2",
|
|
50
47
|
"watch": "^1.0.2"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"lodash": "^4.17.21",
|
|
54
|
-
"po2json": "^0.4.5"
|
|
55
48
|
}
|
|
56
49
|
}
|