fix readme description

This commit is contained in:
Fabrice Lamant
2025-11-30 15:58:48 +01:00
parent bc4359c937
commit 3073a396fe
8 changed files with 1760 additions and 2 deletions

30
scraper/cache.ts Normal file
View File

@ -0,0 +1,30 @@
import Debug from "debug";
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs"
const debug = Debug(`olympics-calendar:cache`);
const cachePath = (key: string): string => {
return `../cache/${key}`;
}
export const get = (key: string): string | null => {
debug(`get: key=${key}`);
const path = cachePath(key);
if (existsSync(path)) {
return readFileSync(path, "utf-8");
}
return null;
}
export const has = (key: string): boolean => {
debug(`has: key=${key}`);
const path = cachePath(key);
return existsSync(path);
}
export const set = (key: string, data: string): void => {
debug(`set: key=${key}`);
const path = cachePath(key);
mkdirSync(path.split("/").slice(0, -1).join("/"), { recursive: true });
writeFileSync(path, data);
}