Skip to content

Commit

Permalink
taf update
Browse files Browse the repository at this point in the history
  • Loading branch information
oceanroleplay committed Sep 15, 2021
1 parent b72da35 commit b382d43
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
23 changes: 19 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
15 changes: 12 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit b382d43

Please sign in to comment.