/
lostSun
/
project-client-server-apps
Обзор
Документация
Войти
/
lostSun
/
project-client-server-apps
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
node_modules/workbox-recipes/src/warmStrategyCache.ts
34 строки
815 B
1lostsun
initial commit
05 май 2025, 11:35
05 май 2025, 11:35
fe8f535
Код
Авторство
О чём код?
import {Strategy} from 'workbox-strategies/Strategy.js'; import './_version.js'; export interface WarmStrategyCacheOptions { urls: Array<string>; strategy: Strategy; } // Give TypeScript the correct global. declare let self: ServiceWorkerGlobalScope; /** * @memberof workbox-recipes * @param {Object} options * @param {string[]} options.urls Paths to warm the strategy's cache with * @param {Strategy} options.strategy Strategy to use */ function warmStrategyCache(options: WarmStrategyCacheOptions): void { self.addEventListener('install', (event) => { const done = options.urls.map( (path) => options.strategy.handleAll({ event, request: new Request(path), })[1], ); event.waitUntil(Promise.all(done)); }); } export {warmStrategyCache};