UNPKG

eslint-plugin-better-tailwindcss

Version:

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

29 lines 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.invalidateByModifiedDate = invalidateByModifiedDate; exports.withCache = withCache; const node_process_1 = require("node:process"); const fs_js_1 = require("./fs.js"); const CACHE = new Map(); function invalidateByModifiedDate(cacheDate, path) { const modified = (0, fs_js_1.getModifiedDate)(path); return !modified || modified > cacheDate; } function withCache(key, callback, invalidate = invalidateByModifiedDate) { const cached = CACHE.get(key); if (node_process_1.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