/
githubmirror
/
hexo
Обзор
Документация
Войти
/
githubmirror
/
hexo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
lib/plugins/helper/fragment_cache.ts
18 строк
405 B
D-Sketon
refactor: refactor types (#5398)
23 янв 2024, 08:57
Не верифицирован
23 янв 2024, 08:57
ee4bc8e
Код
Авторство
О чём код?
import { Cache } from 'hexo-util'; import type Hexo from '../../hexo'; export = (ctx: Hexo) => { const cache = new Cache(); // reset cache for watch mode ctx.on('generateBefore', () => { cache.flush(); }); return function fragmentCache(id: string, fn: () => any) { if (this.cache) return cache.apply(id, fn); const result = fn(); cache.set(id, result); return result; }; };