@hakit/components
Version:
A series of components to work with @hakit/core
66 lines (65 loc) • 1.76 kB
JavaScript
const v = (n, t) => {
switch (t) {
case "ft/s":
return n * 0.3048;
case "km/h":
return n / 3.6;
case "kn":
return n * 0.514444;
case "m/s":
return n;
case "mph":
return n * 0.44704;
default:
throw new Error("Unsupported wind speed unit");
}
}, f = (n, t) => {
switch (t) {
case "°C":
return n;
case "°F":
return (n - 32) * 0.5555555555555556;
default:
throw new Error("Unsupported temperature unit");
}
}, i = (n, t) => {
switch (t) {
case "°C":
return n;
case "°F":
return n * 9 / 5 + 32;
default:
throw new Error("Unsupported target temperature unit");
}
};
function k(n, t, c) {
if (c > 100 || c < 0) return null;
const e = f(n, t), r = c, o = -8.78469475556, s = 1.61139411, u = 2.33854883889, h = -0.14611605, T = -0.012308094, w = -0.0164248277778, C = 2211732e-9, x = 72546e-8, I = -3582e-9, l = e ** 2, a = r ** 2, d = o + s * e + u * r + h * e * r + T * l + w * a + C * l * r + x * e * a + I * l * a;
return i(d, t);
}
function p(n, t, c, e) {
const r = m(v(c, e)), o = f(n, t), s = r ** 0.16, u = 13.12 + 0.6215 * o - 11.37 * s + 0.3965 * o * s;
return i(u, t);
}
function m(n) {
return n * 3.6;
}
function E(n, t, c, e, r) {
if (!n || !t || !c || !e || !r) return null;
const o = f(n, t), s = k(n, t, r), u = p(n, t, c, e);
return {
feelsLike: o >= 27 ? s : o <= 10 ? u : n,
heatIndex: s,
windChill: u
};
}
export {
i as convertTemperatureFromCelsius,
f as convertTemperatureToCelsius,
v as convertWindSpeedToMS,
E as getAdditionalWeatherInformation,
k as heatIndex,
m as meterPerSecondToKilometerPerHour,
p as windChillIndex
};
//# sourceMappingURL=helpers.js.map