Gathering detailed insights and metrics for @isomorphic-git/idb-keyval
Gathering detailed insights and metrics for @isomorphic-git/idb-keyval
Gathering detailed insights and metrics for @isomorphic-git/idb-keyval
Gathering detailed insights and metrics for @isomorphic-git/idb-keyval
npm install @isomorphic-git/idb-keyval
83.1
Supply Chain
100
Quality
79
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
6 Stars
75 Commits
2 Forks
4 Watching
5 Branches
6 Contributors
Updated on 15 Nov 2023
TypeScript (88.48%)
JavaScript (11.52%)
Cumulative downloads
Total Downloads
Last day
15.5%
900
Compared to previous day
Last week
9.9%
4,953
Compared to previous week
Last month
-0.1%
20,473
Compared to previous month
Last year
-28.7%
266,823
Compared to previous year
This is a super-simple-small promise-based keyval store implemented with IndexedDB, largely based on async-storage by Mozilla.
localForage offers similar functionality, but supports older browsers with broken/absent IDB implementations. Because of that, it's 7.4k, whereas idb-keyval is < 600 bytes. Also, it's tree-shaking friendly, so you'll probably end up using fewer than 500 bytes. Pick whichever works best for you!
This is only a keyval store. If you need to do more complex things like iteration & indexing, check out IDB on NPM (a little heavier at 1.7k). The first example in its README is how to recreate this library.
1import { set } from 'idb-keyval'; 2 3set('hello', 'world'); 4set('foo', 'bar');
Since this is IDB-backed, you can store anything structured-clonable (numbers, arrays, objects, dates, blobs etc).
All methods return promises:
1import { set } from 'idb-keyval'; 2 3set('hello', 'world') 4 .then(() => console.log('It worked!')) 5 .catch(err => console.log('It failed!', err));
1import { get } from 'idb-keyval'; 2 3// logs: "world" 4get('hello').then(val => console.log(val));
If there is no 'hello' key, then val
will be undefined
.
1import { keys } from 'idb-keyval'; 2 3// logs: ["hello", "foo"] 4keys().then(keys => console.log(keys));
1import { del } from 'idb-keyval'; 2 3del('hello');
1import { clear } from 'idb-keyval'; 2 3clear();
Closes the IDB connection. May be useful to handle when the page is frozen. The connection is reopened automatically the next time any other API is called.
1import { close } from 'idb-keyval'; 2 3close();
By default, the methods above use an IndexedDB database named keyval-store
and an object store named keyval
. You can create your own store, and pass it as an additional parameter to any of the above methods:
1import { Store, set } from 'idb-keyval'; 2 3const customStore = new Store('custom-db-name', 'custom-store-name'); 4set('foo', 'bar', customStore);
That's it!
1npm install idb-keyval
Now you can require/import idb-keyval
:
1import { get, set } from 'idb-keyval';
If you're targeting older versions of IE, you may have more luck with:
1const idb = require('idb-keyval/dist/idb-keyval-cjs-compat.min.js');
<script>
dist/idb-keyval.mjs
is a valid JS module.dist/idb-keyval-iife.js
can be used in browsers that don't support modules. idbKeyval
is created as a global.dist/idb-keyval-iife.min.js
As above, but minified.dist/idb-keyval-iife-compat.min.js
As above, but works in older browsers such as IE 10.dist/idb-keyval-amd.js
is an AMD module.dist/idb-keyval-amd.min.js
As above, but minified.These built versions are also available on jsDelivr, e.g.:
1<script src="https://cdn.jsdelivr.net/npm/idb-keyval@3/dist/idb-keyval-iife.min.js"></script> 2<!-- Or in modern browsers: --> 3<script type="module"> 4 import { get, set } from 'https://cdn.jsdelivr.net/npm/idb-keyval@3/dist/idb-keyval.mjs'; 5</script>
2.x exported an object with methods:
1// This no longer works in 3.x 2import idbKeyval from 'idb-keyval'; 3 4idbKeyval.set('foo', 'bar');
Whereas in 3.x you import the methods directly:
1import { set } from 'idb-keyval'; 2 3set('foo', 'bar');
This is better for minification, and allows tree shaking.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
51 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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