From b382d4337faf9a6632d5b7bc849c0eb692c03bc5 Mon Sep 17 00:00:00 2001 From: oceanroleplay Date: Wed, 15 Sep 2021 18:32:17 +0530 Subject: [PATCH] taf update --- .eslintrc | 23 +++++++++++++++++++---- package-lock.json | 4 ++-- package.json | 2 +- src/client.ts | 15 ++++++++++++--- tests/test.ts | 5 +++-- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/.eslintrc b/.eslintrc index ee5d750..38eb009 100644 --- a/.eslintrc +++ b/.eslintrc @@ -7,11 +7,26 @@ "plugin:@typescript-eslint/recommended" ], "rules": { - "semi": "error", - "quotes": "error", - "sort-imports": "error", - "@typescript-eslint/no-empty-function": "warn", + "no-return-await": "warn", + "no-unreachable-loop": "warn", + "no-promise-executor-return": "warn", + "no-unsafe-optional-chaining": "warn", + "no-useless-backreference": "warn", + "require-atomic-updates": "warn", + "require-await": "warn", + "no-await-in-loop": "warn", + "spaced-comment": "warn", + "sort-imports": "warn", + "no-unused-vars": "off", + "curly": "warn", + + // TypeScript + "@typescript-eslint/prefer-optional-chain": "warn", "@typescript-eslint/no-unused-vars": "warn", + "@typescript-eslint/semi": "warn", + "@typescript-eslint/no-loss-of-precision": "warn", + "@typescript-eslint/quotes": "warn", + "@typescript-eslint/no-empty-function": "warn", "@typescript-eslint/no-empty-interface": "warn", "@typescript-eslint/no-inferrable-types": "warn", "@typescript-eslint/no-non-null-asserted-optional-chain": "warn", diff --git a/package-lock.json b/package-lock.json index 1eec66e..6ccd606 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "aviationweather", - "version": "1.2.8", + "version": "1.2.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "aviationweather", - "version": "1.2.8", + "version": "1.2.9", "license": "MIT", "dependencies": { "axios": "^0.21.1", diff --git a/package.json b/package.json index 0017ca7..309629b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aviationweather", - "version": "1.2.8", + "version": "1.2.9", "description": "Node.js wrapper for aviation weather, written in TypeScript", "main": "build/index.js", "types": "build/index.d.ts", diff --git a/src/client.ts b/src/client.ts index 615e1c7..a79f9fd 100644 --- a/src/client.ts +++ b/src/client.ts @@ -34,7 +34,10 @@ export class Client { getSkyCondition(identifier: string): IMetaSkyCondition { const search = skyConditions.find((s) => s.code === identifier); - if (!search) return { code: identifier, description: "unknown" }; + if (!search) { + return { code: identifier, description: "unknown" }; + } + return search; } @@ -74,7 +77,10 @@ export class Client { case "TAFS": { return data.map((taf) => { - if (taf?.forecast && taf?.forecast instanceof Array) { + if (taf?.forecast) { + if (!(taf?.forecast instanceof Array)) { + taf.forecast = [taf?.forecast]; + } for (let index = 0; index < taf?.forecast.length; index++) { const item = taf?.forecast[index]; if ( @@ -155,7 +161,10 @@ export class Client { } // final output - if (!finalData) return []; + if (!finalData) { + return []; + } + const output = finalData instanceof Array ? finalData : [finalData]; return this.FormatOutput(options.datasource, output); } diff --git a/tests/test.ts b/tests/test.ts index f86e8bf..76d77c7 100644 --- a/tests/test.ts +++ b/tests/test.ts @@ -4,11 +4,12 @@ const myc = new Client({ debug: true }); myc .AW({ - datasource: "GAIRMETS", + datasource: "TAFS", + stationString: "WSSS", hoursBeforeNow: 1, }) .then((res) => { - console.log(res[0]); + console.log(res.length, res[0]); }); // myc.AVT7("ZJQH").then((res) => {