Installations
npm install localstorage-idb-keyval
Releases
Unable to fetch releases
Developer
BeaveArony
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
9.8.0
NPM Version
5.6.0
Statistics
2 Stars
47 Commits
2 Watching
4 Branches
1 Contributors
Updated on 13 Mar 2024
Languages
TypeScript (87.02%)
JavaScript (12.98%)
Total Downloads
Cumulative downloads
Total Downloads
24,913
Last day
-37.9%
18
Compared to previous day
Last week
-76.9%
61
Compared to previous week
Last month
54.5%
731
Compared to previous month
Last year
71%
7,244
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
2
IDB-Keyval
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 ~550 bytes. Also, it's tree-shaking friendly, so you'll probably end up using fewer than 450 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.
Usage
set:
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));
get:
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
.
keys:
1import { keys } from 'idb-keyval'; 2 3// logs: ["hello", "foo"] 4keys().then(keys => console.log(keys));
del:
1import { del } from 'idb-keyval'; 2 3del('hello');
clear:
1import { clear } from 'idb-keyval'; 2 3clear();
Custom stores:
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!
Installing
Via npm + webpack/rollup
1npm install idb-keyval
Now you can require/import idb-keyval
:
1import { get, set } from 'idb-keyval';
Via <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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENCE:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
18 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx
- Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-hr2v-3952-633q
- Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
Score
1.7
/10
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 MoreOther packages similar to localstorage-idb-keyval
idb-keyval
A super-simple-small keyval store built on top of IndexedDB
@isomorphic-git/idb-keyval
A super-simple-small keyval store built on top of IndexedDB
ngrx-store-idb
https://github.com/radacovsky/ngrx-store-idb#readme
@vueuse/integrations
Integration wrappers for utility libraries