Download src/config/cache-utils.ts from shimen/shinclaw: direct link, hf CLI and curl.
- Browser
- Download file 601 Bytes
-
https://huggingface.co/spaces/shimen/shinclaw/resolve/main/src/config/cache-utils.ts
- Command line
-
hf download hf://spaces/shimen/shinclaw/src/config/cache-utils.ts
-
curl -L -o cache-utils.ts https://huggingface.co/spaces/shimen/shinclaw/resolve/main/src/config/cache-utils.ts
601 Bytes
| import fs from "node:fs"; | |
| export function resolveCacheTtlMs(params: { | |
| envValue: string | undefined; | |
| defaultTtlMs: number; | |
| }): number { | |
| const { envValue, defaultTtlMs } = params; | |
| if (envValue) { | |
| const parsed = Number.parseInt(envValue, 10); | |
| if (Number.isFinite(parsed) && parsed >= 0) { | |
| return parsed; | |
| } | |
| } | |
| return defaultTtlMs; | |
| } | |
| export function isCacheEnabled(ttlMs: number): boolean { | |
| return ttlMs > 0; | |
| } | |
| export function getFileMtimeMs(filePath: string): number | undefined { | |
| try { | |
| return fs.statSync(filePath).mtimeMs; | |
| } catch { | |
| return undefined; | |
| } | |
| } | |