x-weather
Version:
A collection of web components implementing portions of the OpenWeatherMap API.
2 lines (1 loc) • 485 B
JavaScript
var t=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"cToF",e=t=>t+273.15,a=t=>t-273.15,o=t=>1.8*t+32,c=t=>5*(t-32)/9;return{cToK:e,kToC:a,cToF:o,fToC:c,kToF:t=>o(a(t)),fToK:t=>e(c(t))}[r](t)},r=()=>{try{var t=localStorage.getItem("x-weather-state");if(null===t)return;return JSON.parse(t)}catch(t){return}},e=t=>{try{var r=JSON.stringify(t);localStorage.setItem("x-weather-state",r)}catch(t){}};export{t as convertTemperature,r as loadState,e as saveState};