From f80807eebde7c094c2c965d8b26be65cfa10aaae Mon Sep 17 00:00:00 2001 From: Ayo Date: Tue, 26 Aug 2025 00:47:00 +0200 Subject: [PATCH] chore(sw): add jsdoc --- src/sw.mjs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/sw.mjs b/src/sw.mjs index c1d7a0c..6e68b0b 100644 --- a/src/sw.mjs +++ b/src/sw.mjs @@ -31,6 +31,13 @@ const cleanOldCaches = async () => { }) } +/** + * Adds resources to the service worker cache. + * @async + * @function addResourcesToCache + * @param {string[]} resources - An array of resource URLs to be cached. + * @returns {Promise} A promise that resolves when all resources have been added to the cache. + */ const addResourcesToCache = async (resources) => { const cache = await caches.open(cacheName) console.info('adding resources to cache...', { @@ -48,6 +55,14 @@ const addResourcesToCache = async (resources) => { } } +/** + * Puts a response in the cache. + * @async + * @function putInCache + * @param {Request} request - The request to be cached. + * @param {Response} response - The response to be cached. + * @returns {Promise} A promise that resolves when the response has been added to the cache. + */ const putInCache = async (request, response) => { const cache = await caches.open(cacheName)