Gathering detailed insights and metrics for webext-storage-cache
Gathering detailed insights and metrics for webext-storage-cache
npm install webext-storage-cache
Typescript
Module System
Min. Node Version
Node Version
NPM Version
71.2
Supply Chain
99.5
Quality
77.8
Maintenance
100
Vulnerability
99.6
License
JavaScript (55.94%)
TypeScript (44.06%)
Total Downloads
112,910
Last Day
58
Last Week
301
Last Month
1,757
Last Year
39,513
81 Stars
101 Commits
4 Forks
4 Watching
3 Branches
4 Contributors
Latest Version
6.0.3
Package Id
webext-storage-cache@6.0.3
Unpacked Size
18.10 kB
Size
5.98 kB
File Count
11
NPM Version
10.8.1
Node Version
22.3.0
Publised On
01 Jul 2024
Cumulative downloads
Total Downloads
Last day
-71.6%
58
Compared to previous day
Last week
-71%
301
Compared to previous week
Last month
-63.7%
1,757
Compared to previous month
Last year
201.8%
39,513
Compared to previous year
Cache values in your Web Extension and clear them on expiration. Also includes a memoize-like API to cache any function results automatically.
chrome.storage
APIsstorage
: "The extension caches some values into the local storage"alarms
: "The extension automatically clears its expired storage at certain intervals"You can download the standalone bundle and include it in your manifest.json
.
Or use npm
:
1npm install webext-storage-cache
This module requires the storage
permission and it’s suggested to also use alarms
to safely schedule cache purging:
1/* manifest.json */ 2{ 3 "permissions": [ 4 "storage", 5 "alarms" 6 ], 7 "background": { 8 "scripts": [ 9 /* Remember to include/import it in the background to enable expired cache purging */ 10 "webext-storage-cache.js" 11 ] 12 } 13}
1import {CachedValue} from 'webext-storage-cache'; 2 3const item = new CachedValue('unique', { 4 maxAge: { 5 days: 3, 6 }, 7}); 8 9(async () => { 10 if (!(await item.isCached())) { 11 const cachableItem = await someFunction(); 12 await item.set(cachableItem); 13 } 14 15 console.log(await item.get()); 16})();
The same code could also be written more effectively with CachedFunction
:
1import {CachedFunction} from 'webext-storage-cache'; 2 3const cachedFunction = new CachedFunction('unique', { 4 updater: someFunction, 5 maxAge: { 6 days: 3, 7 }, 8}); 9 10(async () => { 11 console.log(await cachedFunction()); 12})();
isCached
/get
/set
globalCache
- Global helpers, documented belowlegacy
- The previous Map-like API, documented below, deprecatedClears the cache. This is a special method that acts on the entire cache of the extension.
1import {globalCache} from 'webext-storage-cache'; 2 3document.querySelector('.options .clear-cache').addEventListener('click', async () => { 4 await globalCache.clear() 5})
The API used until v5 has been deprecated and you should migrate to:
CachedValue
for simple cache.get
/cache.set
calls. This API makes more sense in a typed context because the type is preserved/enforced across calls.CachedFunction
for cache.function
. It behaves in a similar fashion, but it also has extra methods like getCached
and getFresh
You can:
cache.function
) by importing webext-storage-cache/legacy.js
(until v7 is published)1import cache from "webext-storage-cache/legacy.js"; 2 3await cache.get('my-url'); 4await cache.set('my-url', 'https://example.com');
The documentation for the legacy API can be found on the v5 version of this readme.
MIT © Federico Brigante
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
2 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 4
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-06
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More