From b9ae3e72577a857938fe5727bb87ee2249c76473 Mon Sep 17 00:00:00 2001 From: Alessio Vanni Date: Wed, 24 Jul 2019 13:06:10 +0200 Subject: Add missing function --- js/assets.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/js/assets.js b/js/assets.js index e62bb5d..6e9c1f6 100644 --- a/js/assets.js +++ b/js/assets.js @@ -224,6 +224,47 @@ getCacheRegistry(onReady); }; + let cacheRemove = function (pattern, callback) { + let onReady = function (cache) { + let entries = []; + + for (let key in cache) { + if (pattern instanceof RegExp && !pattern.test(key)) { + continue; + } + + if (typeof pattern === 'string' && key !== pattern) { + continue; + } + + entries.push(key); + + delete cache[key]; + } + + if (entries.length !== 0) { + vAPI.cacheStorage.remove(content); + + let bin = { + assetCacheRegistry: cache, + }; + vAPI.cacheStorage.set(bin); + } + + if (typeof callback === 'function') { + callback(); + } + + for (let i=0; i