aewx-metar-parser 1.0.0 → 2.0.1

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.
@@ -0,0 +1,359 @@
1
+ import { convert } from "./convert.js";
2
+
3
+ export interface MetarCode {
4
+ code: string;
5
+ }
6
+
7
+ export interface MetarWind {
8
+ degrees: number | null;
9
+ speed_kts: number;
10
+ speed_mps: number;
11
+ gust_kts: number | null;
12
+ gust_mps: number | null;
13
+ degrees_from: number | null;
14
+ degrees_to: number | null;
15
+ }
16
+
17
+ export interface MetarVisibility {
18
+ miles: number;
19
+ miles_text: string;
20
+ meters: number;
21
+ meters_text: string;
22
+ }
23
+
24
+ export type MetarCloudCode = "FEW" | "SCT" | "BKN" | "OVC";
25
+
26
+ export interface MetarCloud {
27
+ code: MetarCloudCode;
28
+ feet: number;
29
+ meters: number;
30
+ }
31
+
32
+ export interface MetarCeiling {
33
+ feet: number | null;
34
+ meters: number | null;
35
+ }
36
+
37
+ export interface MetarTemperature {
38
+ celsius: number | null;
39
+ fahrenheit: number | null;
40
+ }
41
+
42
+ export interface MetarHumidity {
43
+ percent: number | null;
44
+ }
45
+
46
+ export interface MetarPressure {
47
+ hg: number | null;
48
+ kpa: number | null;
49
+ mb: number | null;
50
+ }
51
+
52
+ export type MetarIcaoFlightCategory = "VFR" | "IFR";
53
+
54
+ export type MetarFlightCategory = MetarIcaoFlightCategory | "MVFR" | "LIFR";
55
+
56
+ export interface Metar {
57
+ raw_text: string;
58
+ raw_parts: string[];
59
+ icao: string;
60
+ observed: Date;
61
+ wind: MetarWind;
62
+ visibility: MetarVisibility;
63
+ conditions: MetarCode[];
64
+ clouds: MetarCloud[];
65
+ ceiling: MetarCeiling;
66
+ temperature: MetarTemperature;
67
+ dewpoint: MetarTemperature;
68
+ humidity: MetarHumidity;
69
+ barometer: MetarPressure;
70
+ flight_category: MetarFlightCategory | null;
71
+ icao_flight_category: MetarIcaoFlightCategory | null;
72
+ }
73
+
74
+ class MetarParserHelpers {
75
+ /**
76
+ * @param {Number} value dito
77
+ * @param {Number} toNext round to next full xxxx
78
+ * @returns {Number} rounded value
79
+ */
80
+ static round(value: number, toNext: number = 500): number {
81
+ return Math.round(value / toNext) * toNext;
82
+ }
83
+
84
+ static getVisibility(visibility_miles: number, visibility_meters: number): MetarVisibility {
85
+ return {
86
+ miles: visibility_miles,
87
+ miles_text: String(MetarParserHelpers.round(visibility_miles, 0.5)),
88
+ meters: visibility_meters,
89
+ meters_text: String(MetarParserHelpers.round(visibility_meters, 500)),
90
+ };
91
+ }
92
+
93
+ static getCloud(code: MetarCloudCode, hundredFeet: string): MetarCloud {
94
+ const feet = Number(hundredFeet) * 100;
95
+ return {
96
+ code: code,
97
+ feet: feet,
98
+ meters: convert.feetToMeters(feet),
99
+ };
100
+ }
101
+
102
+ static getTemperature(temperatureString: string): MetarTemperature {
103
+ const temperature = Number(temperatureString.replace("M", "-"));
104
+ return {
105
+ celsius: temperature,
106
+ fahrenheit: convert.celsiusToFahrenheit(temperature),
107
+ };
108
+ }
109
+
110
+ /**
111
+ * @see http://andrew.rsmas.miami.edu/bmcnoldy/Humidity.html
112
+ */
113
+ static getHumidity(temp: MetarTemperature, dew: MetarTemperature): number | null {
114
+ if (dew.celsius === null || temp.celsius === null) {
115
+ return null;
116
+ }
117
+ return (
118
+ (Math.exp((17.625 * dew.celsius) / (243.04 + dew.celsius)) /
119
+ Math.exp((17.625 * temp.celsius) / (243.04 + temp.celsius))) *
120
+ 100
121
+ );
122
+ }
123
+
124
+ static getFlightCategory(visibility: MetarVisibility, ceiling: MetarCeiling): MetarFlightCategory {
125
+ if (visibility.miles > 5 && (!ceiling.feet || ceiling.feet > 3000)) {
126
+ return "VFR";
127
+ } else if (visibility.miles >= 3 && (!ceiling.feet || ceiling.feet >= 1000)) {
128
+ return "MVFR";
129
+ } else if (visibility.miles >= 1 && (!ceiling.feet || ceiling.feet >= 500)) {
130
+ return "IFR";
131
+ }
132
+ return "LIFR";
133
+ }
134
+
135
+ static getIcaoFLightCategory(visibility: MetarVisibility, ceiling: MetarCeiling): MetarIcaoFlightCategory {
136
+ return visibility.meters >= 5000 && (!ceiling.feet || ceiling.feet >= 1500) ? "VFR" : "IFR";
137
+ }
138
+
139
+ static getCeiling(clouds: MetarCloud[]): MetarCloud | undefined {
140
+ return clouds.find((c) => {
141
+ return c.code === "BKN" || c.code === "OVC";
142
+ });
143
+ }
144
+
145
+ static metarSplit(metarString: string): string[] {
146
+ return metarString
147
+ .trim()
148
+ .replace(/^METAR\S*?\s/, "")
149
+ .replace(/(\s)(\d)\s(\d)\/(\d)(SM)/, function (all, a, b, c, d, e) {
150
+ // convert visbility range like `1 1/2 SM`
151
+ return a + (Number(b) * Number(d) + Number(c)) + "/" + d + e;
152
+ })
153
+ .split(" ");
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Convert METAR string into structured object.
159
+ * @see https://api.checkwx.com/#31-single
160
+ * @see https://www.skybrary.aero/index.php/Meteorological_Terminal_Air_Report_(METAR)
161
+ * @param {String} metarString raw
162
+ * @returns {Metar} with structured information. The object resembles the API
163
+ * reponse of the data property of https://www.checkwxapi.com/metar
164
+ */
165
+ export const metarParser = (metarString: string): Metar => {
166
+ const metarObject: Metar = {
167
+ raw_text: metarString,
168
+ raw_parts: MetarParserHelpers.metarSplit(metarString),
169
+ icao: "",
170
+ observed: new Date(),
171
+ wind: {
172
+ degrees: null,
173
+ speed_kts: 0,
174
+ speed_mps: 0,
175
+ gust_kts: null,
176
+ gust_mps: null,
177
+ degrees_from: null,
178
+ degrees_to: null,
179
+ },
180
+ visibility: {
181
+ miles: 10,
182
+ miles_text: "",
183
+ meters: 9999,
184
+ meters_text: "",
185
+ },
186
+ conditions: [],
187
+ clouds: [],
188
+ ceiling: {
189
+ feet: null,
190
+ meters: null,
191
+ },
192
+ temperature: {
193
+ celsius: null,
194
+ fahrenheit: null,
195
+ },
196
+ dewpoint: {
197
+ celsius: null,
198
+ fahrenheit: null,
199
+ },
200
+ humidity: {
201
+ percent: null,
202
+ },
203
+ barometer: {
204
+ hg: null,
205
+ kpa: null,
206
+ mb: null,
207
+ },
208
+ flight_category: null,
209
+ icao_flight_category: null,
210
+ };
211
+
212
+ let mode = 0;
213
+ metarObject.raw_parts.forEach((metarPart) => {
214
+ let match;
215
+ if (mode < 3 && metarPart.match(/^(\d+)(?:\/(\d+))?(SM)?$/)) {
216
+ mode = 3; // no wind reported
217
+ }
218
+ if (mode < 5 && metarPart.match(/^(FEW|SCT|BKN|OVC)(\d+)?/)) {
219
+ mode = 5; // no visibility / conditions reported
220
+ }
221
+ if (mode < 6 && metarPart.match(/(^M?\d+\/M?\d+$)|(^\/\/\/\/\/)/)) {
222
+ mode = 6; // end of clouds
223
+ }
224
+ switch (mode) {
225
+ case 0:
226
+ // ICAO Code
227
+ metarObject.icao = metarPart;
228
+ mode = 1;
229
+ break;
230
+ case 1:
231
+ // Observed Date
232
+ match = metarPart.match(/^(\d\d)(\d\d)(\d\d)Z$/);
233
+ if (match) {
234
+ metarObject.observed = new Date();
235
+ metarObject.observed.setUTCDate(Number(match[1]));
236
+ metarObject.observed.setUTCHours(Number(match[2]));
237
+ metarObject.observed.setUTCMinutes(Number(match[3]));
238
+ mode = 2;
239
+ }
240
+ break;
241
+ case 2:
242
+ // Wind
243
+ match = metarPart.match(/^(\d\d\d|VRB)P?(\d+)(?:G(\d+))?(KT|MPS|KPH)/);
244
+ if (match) {
245
+ let speed_kts = Number(match[2]);
246
+ let gust_kts = match[3] ? Number(match[3]) : null;
247
+ if (match[4] === "KPH") {
248
+ speed_kts = convert.kphToMps(speed_kts);
249
+ gust_kts = gust_kts ? convert.kphToMps(gust_kts) : null;
250
+ match[4] = "MPS";
251
+ }
252
+ const degrees = match[1] === "VRB" ? null : Number(match[1]);
253
+
254
+ metarObject.wind = {
255
+ degrees: degrees,
256
+ speed_kts: match[4] === "MPS" ? convert.mpsToKts(speed_kts) : speed_kts,
257
+ speed_mps: match[4] === "MPS" ? speed_kts : convert.ktsToMps(speed_kts),
258
+ gust_kts: gust_kts ? (match[4] === "MPS" ? convert.mpsToKts(gust_kts) : gust_kts) : null,
259
+ gust_mps: gust_kts ? (match[4] === "MPS" ? gust_kts : convert.ktsToMps(gust_kts)) : null,
260
+ degrees_from: null,
261
+ degrees_to: null,
262
+ };
263
+ if (match[1] === "VRB") {
264
+ metarObject.wind.degrees_from = 0;
265
+ metarObject.wind.degrees_to = 359;
266
+ }
267
+ mode = 3;
268
+ }
269
+ break;
270
+ case 3:
271
+ // Visibility
272
+ match = metarPart.match(/^(\d+)(?:\/(\d+))?(SM)?$/);
273
+ if (match) {
274
+ const visibility = match[2] ? Number(match[1]) / Number(match[2]) : Number(match[1]);
275
+ metarObject.visibility = MetarParserHelpers.getVisibility(
276
+ match[3] && match[3] === "SM" ? visibility : convert.metersToMiles(visibility),
277
+ match[3] && match[3] === "SM" ? convert.milesToMeters(visibility) : visibility,
278
+ );
279
+
280
+ mode = 4;
281
+ } else if (metarPart === "CAVOK" || metarPart === "CLR") {
282
+ metarObject.visibility = MetarParserHelpers.getVisibility(10, convert.milesToMeters(10));
283
+ mode = 5; // no clouds & conditions reported
284
+ } else if (metarObject.wind) {
285
+ // Variable wind direction
286
+ match = metarPart.match(/^(\d+)V(\d+)$/);
287
+ if (match) {
288
+ metarObject.wind.degrees_from = Number(match[1]);
289
+ metarObject.wind.degrees_to = Number(match[2]);
290
+ }
291
+ }
292
+ break;
293
+ case 4:
294
+ // Conditions
295
+ match = metarPart.match(/^(\+|-|VC|RE)?([A-Z][A-Z])([A-Z][A-Z])?([A-Z][A-Z])?$/);
296
+ if (match) {
297
+ if (!metarObject.conditions) {
298
+ metarObject.conditions = [];
299
+ }
300
+ match
301
+ .filter((m, index) => {
302
+ return index !== 0 && m;
303
+ })
304
+ .forEach((m) => {
305
+ metarObject.conditions.push({ code: m });
306
+ });
307
+ // may occur multiple times
308
+ }
309
+ break;
310
+ case 5:
311
+ // Clouds
312
+ match = metarPart.match(/^(FEW|SCT|BKN|OVC)(\d+)/);
313
+ if (match) {
314
+ metarObject.clouds.push(MetarParserHelpers.getCloud(match[1] as MetarCloudCode, match[2]));
315
+ }
316
+ // may occur multiple times
317
+ break;
318
+ case 6:
319
+ // Temperature
320
+ match = metarPart.match(/^(M?\d+)\/(M?\d+)$/);
321
+ if (match === null && metarPart.match(/^\/\/\/\/\/$/)) {
322
+ mode = 7;
323
+ break;
324
+ }
325
+ if (match) {
326
+ metarObject.temperature = MetarParserHelpers.getTemperature(match[1]);
327
+ metarObject.dewpoint = MetarParserHelpers.getTemperature(match[2]);
328
+ metarObject.humidity.percent = MetarParserHelpers.getHumidity(metarObject.temperature, metarObject.dewpoint);
329
+ mode = 7;
330
+ }
331
+ break;
332
+ case 7:
333
+ // Pressure
334
+ match = metarPart.match(/^(Q|A)(\d+)/);
335
+ if (match) {
336
+ let hg = Number(match[2]);
337
+ hg /= match[1] === "Q" ? 10 : 100;
338
+ metarObject.barometer = {
339
+ hg: match[1] === "Q" ? convert.kpaToInhg(hg) : hg,
340
+ kpa: match[1] === "Q" ? hg : convert.inhgToKpa(hg),
341
+ mb: match[1] === "Q" ? hg * 10 : convert.inhgToKpa(hg * 10),
342
+ };
343
+ mode = 8;
344
+ }
345
+ break;
346
+ }
347
+ });
348
+
349
+ const ceilingCloud: MetarCloud | undefined = MetarParserHelpers.getCeiling(metarObject.clouds);
350
+ metarObject.ceiling.feet = ceilingCloud?.feet ?? null;
351
+ metarObject.ceiling.meters = ceilingCloud?.meters ?? null;
352
+ metarObject.flight_category = MetarParserHelpers.getFlightCategory(metarObject.visibility, metarObject.ceiling);
353
+ metarObject.icao_flight_category = MetarParserHelpers.getIcaoFLightCategory(
354
+ metarObject.visibility,
355
+ metarObject.ceiling,
356
+ );
357
+
358
+ return metarObject;
359
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "./dist",
4
+ "target": "es2021",
5
+ "module": "es2022",
6
+ "rootDir": "./src",
7
+ "moduleResolution": "node",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "sourceMap": false,
11
+ "newLine": "LF",
12
+ "forceConsistentCasingInFileNames": true,
13
+ "skipLibCheck": true,
14
+ "declarationMap": true,
15
+ "declaration": true,
16
+ "declarationDir": "./types"
17
+ },
18
+ "include": ["./src/**/*"]
19
+ }
@@ -0,0 +1 @@
1
+ {"root":["./src/convert.test.ts","./src/convert.ts","./src/metar-parser.test.ts","./src/metar-parser.ts"],"version":"5.7.3"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Convert units
3
+ */
4
+ export declare const convert: {
5
+ celsiusToFahrenheit: (celsius: number) => number;
6
+ feetToMeters: (feet: number) => number;
7
+ milesToMeters: (miles: number) => number;
8
+ metersToMiles: (meters: number) => number;
9
+ inhgToKpa: (inHg: number) => number;
10
+ kpaToInhg: (kpa: number) => number;
11
+ kphToMps: (kph: number) => number;
12
+ mpsToKts: (mps: number) => number;
13
+ ktsToMps: (kts: number) => number;
14
+ };
15
+ //# sourceMappingURL=convert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,OAAO;mCACsB,MAAM;yBAIhB,MAAM;2BAIJ,MAAM;4BAIL,MAAM;sBAIZ,MAAM;qBAIP,MAAM;oBAIP,MAAM;oBAIN,MAAM;oBAIN,MAAM;CAGhC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=convert.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.test.d.ts","sourceRoot":"","sources":["../src/convert.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,69 @@
1
+ export interface MetarCode {
2
+ code: string;
3
+ }
4
+ export interface MetarWind {
5
+ degrees: number | null;
6
+ speed_kts: number;
7
+ speed_mps: number;
8
+ gust_kts: number | null;
9
+ gust_mps: number | null;
10
+ degrees_from: number | null;
11
+ degrees_to: number | null;
12
+ }
13
+ export interface MetarVisibility {
14
+ miles: number;
15
+ miles_text: string;
16
+ meters: number;
17
+ meters_text: string;
18
+ }
19
+ export type MetarCloudCode = "FEW" | "SCT" | "BKN" | "OVC";
20
+ export interface MetarCloud {
21
+ code: MetarCloudCode;
22
+ feet: number;
23
+ meters: number;
24
+ }
25
+ export interface MetarCeiling {
26
+ feet: number | null;
27
+ meters: number | null;
28
+ }
29
+ export interface MetarTemperature {
30
+ celsius: number | null;
31
+ fahrenheit: number | null;
32
+ }
33
+ export interface MetarHumidity {
34
+ percent: number | null;
35
+ }
36
+ export interface MetarPressure {
37
+ hg: number | null;
38
+ kpa: number | null;
39
+ mb: number | null;
40
+ }
41
+ export type MetarIcaoFlightCategory = "VFR" | "IFR";
42
+ export type MetarFlightCategory = MetarIcaoFlightCategory | "MVFR" | "LIFR";
43
+ export interface Metar {
44
+ raw_text: string;
45
+ raw_parts: string[];
46
+ icao: string;
47
+ observed: Date;
48
+ wind: MetarWind;
49
+ visibility: MetarVisibility;
50
+ conditions: MetarCode[];
51
+ clouds: MetarCloud[];
52
+ ceiling: MetarCeiling;
53
+ temperature: MetarTemperature;
54
+ dewpoint: MetarTemperature;
55
+ humidity: MetarHumidity;
56
+ barometer: MetarPressure;
57
+ flight_category: MetarFlightCategory | null;
58
+ icao_flight_category: MetarIcaoFlightCategory | null;
59
+ }
60
+ /**
61
+ * Convert METAR string into structured object.
62
+ * @see https://api.checkwx.com/#31-single
63
+ * @see https://www.skybrary.aero/index.php/Meteorological_Terminal_Air_Report_(METAR)
64
+ * @param {String} metarString raw
65
+ * @returns {Metar} with structured information. The object resembles the API
66
+ * reponse of the data property of https://www.checkwxapi.com/metar
67
+ */
68
+ export declare const metarParser: (metarString: string) => Metar;
69
+ //# sourceMappingURL=metar-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metar-parser.d.ts","sourceRoot":"","sources":["../src/metar-parser.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAE3D,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CACnB;AAED,MAAM,MAAM,uBAAuB,GAAG,KAAK,GAAG,KAAK,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5E,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,IAAI,CAAC;IACf,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,eAAe,CAAC;IAC5B,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,OAAO,EAAE,YAAY,CAAC;IACtB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,aAAa,CAAC;IACxB,SAAS,EAAE,aAAa,CAAC;IACzB,eAAe,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC5C,oBAAoB,EAAE,uBAAuB,GAAG,IAAI,CAAC;CACtD;AAqFD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,gBAAiB,MAAM,KAAG,KAkMjD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=metar-parser.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metar-parser.test.d.ts","sourceRoot":"","sources":["../src/metar-parser.test.ts"],"names":[],"mappings":""}
package/.eslintrc.js DELETED
@@ -1,26 +0,0 @@
1
- module.exports = {
2
- env: {
3
- browser: true,
4
- commonjs: true,
5
- es2021: true
6
- },
7
- extends: [
8
- 'standard'
9
- ],
10
- parserOptions: {
11
- ecmaVersion: 'latest'
12
- },
13
- rules: {
14
- semi: ['error', 'always']
15
- },
16
- overrides: [
17
- {
18
- files: [
19
- "test/*.js"
20
- ],
21
- env: {
22
- mocha: true
23
- }
24
- }
25
- ]
26
- }
package/.husky/pre-commit DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
- npm test
package/lib/convert.js DELETED
@@ -1,44 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Convert units
5
- */
6
- const convert = {
7
- celsiusToFahrenheit: function (celsius) {
8
- return celsius * 1.8 + 32;
9
- },
10
-
11
- feetToMeters: function (feet) {
12
- return feet * 0.3048;
13
- },
14
-
15
- milesToMeters: function (miles) {
16
- return miles * 1609.344;
17
- },
18
-
19
- metersToMiles: function (meters) {
20
- return meters / 1609.344;
21
- },
22
-
23
- inhgToKpa: function (inHg) {
24
- return inHg / 0.29529988;
25
- },
26
-
27
- kpaToInhg: function (kpa) {
28
- return kpa * 0.29529988;
29
- },
30
-
31
- kphToMps: function (kph) {
32
- return kph / 3600 * 1000;
33
- },
34
-
35
- mpsToKts: function (mps) {
36
- return mps * 1.9438445;
37
- },
38
-
39
- ktsToMps: function (kts) {
40
- return kts / 1.9438445;
41
- }
42
- };
43
-
44
- module.exports = convert;