UNPKG

eslint-plugin-better-tailwindcss

Version:

auto-wraps tailwind classes after a certain print width or class count into multiple lines to improve readability.

25 lines 848 B
import { env } from "node:process"; import { getModifiedDate } from "./fs.js"; const CACHE = new Map(); export function invalidateByModifiedDate(cacheDate, path) { const modified = getModifiedDate(path); return !modified || modified > cacheDate; } export function withCache(key, callback, invalidate = invalidateByModifiedDate) { const cached = CACHE.get(key); if (env.NODE_ENV !== "test" && cached && !invalidate(cached.date, key)) { return cached.value; } const value = callback(); if (value instanceof Promise) { return value.then(resolvedValue => { CACHE.set(key, { date: new Date(), value: resolvedValue }); return resolvedValue; }); } else { CACHE.set(key, { date: new Date(), value }); return value; } } //# sourceMappingURL=cache.js.map