New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tickerowl-weather

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tickerowl-weather - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

50

dist/index.d.ts
import { App, AppInfo, AppSlide } from "tickerowl-app-base";
type Weather = {
coord: {
lon: number;
lat: number;
};
weather: [
{
id: number;
main: string;
description: string;
icon: string;
}
];
base: string;
main: {
temp: number;
feels_like: number;
temp_min: number;
temp_max: number;
pressure: number;
humidity: number;
sea_level: number;
grnd_level: number;
};
visibility: number;
wind: {
speed: number;
deg: number;
};
clouds: {
all: number;
};
dt: number;
sys: {
type: number;
id: number;
country: string;
sunrise: number;
sunset: number;
};
timezone: number;
id: number;
name: string;
cod: number;
};
export default class WeatherApp implements App {
getInfo(): AppInfo;
getSlides(): Record<string, AppSlide>;
getWeather(city: string, apiToken: string): Promise<{
weather: any;
}>;
getWeather(city: string, apiToken: string): Promise<Weather>;
}
export {};

61

dist/index.js

@@ -13,3 +13,2 @@ "use strict";

const tickerowl_app_base_1 = require("tickerowl-app-base");
const CACHE_KEY = "cache";
class WeatherApp {

@@ -56,3 +55,2 @@ getInfo() {

getData: (_a) => __awaiter(this, [_a], void 0, function* ({ inputs, store }) {
var _b;
const apiToken = inputs["api-token"];

@@ -66,49 +64,25 @@ const city = inputs["city"];

}
let weather = null;
let lastWeather;
let cachedWeather;
let updatedAt;
const cached = yield store.read(CACHE_KEY);
if (cached) {
const cachedJson = JSON.parse(cached);
lastWeather = cachedJson.lastWeather;
cachedWeather = cachedJson.weather;
updatedAt = cachedJson.updatedAt;
if (cachedJson.city === city.value.value &&
new Date(cachedJson.updatedAt) >
new Date(Date.now() - Number((_b = cacheDuration === null || cacheDuration === void 0 ? void 0 : cacheDuration.value.value) !== null && _b !== void 0 ? _b : 0) * 1000)) {
weather = cachedJson.weather;
}
}
if (!weather) {
const res = yield this.getWeather(city.value.value.toString(), apiToken.value.value.toString());
weather = res;
updatedAt = Date.now();
}
const currentWeather = weather;
yield store.write(CACHE_KEY, JSON.stringify({
city: city.value.value.toString(),
updatedAt,
weather,
lastWeather: cachedWeather !== currentWeather ? cachedWeather : lastWeather,
}));
const slides = [];
console.log(currentWeather);
let infos = [];
infos.push(currentWeather.main.temp);
if (infos.length > 0) {
slides.push(tickerowl_app_base_1.SlideMaker.text({ text: infos.join(" - ") }));
}
const weather = yield (0, tickerowl_app_base_1.getCached)({
store,
key: "weather",
asJson: true,
duration: cacheDuration.value.value
? Number(cacheDuration.value.value)
: undefined,
fetch: () => __awaiter(this, void 0, void 0, function* () {
return yield this.getWeather(city.value.value.toString(), apiToken.value.value.toString());
}),
});
return {
slides: [
...slides,
tickerowl_app_base_1.SlideMaker.keyValue({
key: "Temp",
value: currentWeather.main.temp,
value: weather.main.temp + "'C",
}),
tickerowl_app_base_1.SlideMaker.text({
text: `Feels like: ${currentWeather.main.feels_like}`,
tickerowl_app_base_1.SlideMaker.keyValue({
key: "Feels like",
value: weather.main.feels_like + "'C",
}),
tickerowl_app_base_1.SlideMaker.text({
text: `Weather: ${currentWeather.weather[0].description}`,
text: `Weather: ${weather.weather[0].description}`,
}),

@@ -129,4 +103,3 @@ ],

});
const fullWeather = yield weatherRes.json();
return fullWeather;
return yield weatherRes.json();
});

@@ -133,0 +106,0 @@ }

{
"name": "tickerowl-weather",
"version": "1.0.3",
"version": "1.0.4",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc