UNPKG

epd

Version:

Enhanced peer dependency resolution for npm, yarn, and pnpm

36 lines 977 B
import fs from 'fs/promises'; const CACHE_FILE = '.epd-cache.json'; const CACHE_TTL = 24 * 60 * 60 * 1000; // 24 hours export async function getCachedResolution(pkg) { try { const cache = await loadCache(); const cached = cache[pkg]; if (cached && Date.now() - cached.timestamp < CACHE_TTL) { return cached.version; } return null; } catch { return null; } } export async function setCachedResolution(pkg, version) { try { const cache = await loadCache(); cache[pkg] = { package: pkg, version, timestamp: Date.now() }; await fs.writeFile(CACHE_FILE, JSON.stringify(cache, null, 2)); } catch { // Ignore cache write errors } } async function loadCache() { try { const content = await fs.readFile(CACHE_FILE, 'utf-8'); return JSON.parse(content); } catch { return {}; } } //# sourceMappingURL=resolution-cache.js.map