idb-keyval
- Version 6.2.2
- Published
- 928 kB
- No dependencies
- Apache-2.0 license
Install
npm i idb-keyval
yarn add idb-keyval
pnpm add idb-keyval
Overview
A super-simple-small keyval store built on top of IndexedDB
Index
Functions
function clear
clear: (customStore?: UseStore) => Promise<void>;
Clear all values in the store.
Parameter customStore
Method to get a custom store. Use with caution (see the docs).
function createStore
createStore: (dbName: string, storeName: string) => UseStore;
function del
del: (key: IDBValidKey, customStore?: UseStore) => Promise<void>;
Delete a particular key from the store.
Parameter key
Parameter customStore
Method to get a custom store. Use with caution (see the docs).
function delMany
delMany: (keys: IDBValidKey[], customStore?: UseStore) => Promise<void>;
Delete multiple keys at once.
Parameter keys
List of keys to delete.
Parameter customStore
Method to get a custom store. Use with caution (see the docs).
function entries
entries: <KeyType extends IDBValidKey, ValueType = any>( customStore?: UseStore) => Promise<[KeyType, ValueType][]>;
Get all entries in the store. Each entry is an array of
[key, value]
.Parameter customStore
Method to get a custom store. Use with caution (see the docs).
function get
get: <T = any>( key: IDBValidKey, customStore?: UseStore) => Promise<T | undefined>;
Get a value by its key.
Parameter key
Parameter customStore
Method to get a custom store. Use with caution (see the docs).
function getMany
getMany: <T = any>(keys: IDBValidKey[], customStore?: UseStore) => Promise<T[]>;
Get multiple values by their keys
Parameter keys
Parameter customStore
Method to get a custom store. Use with caution (see the docs).
function keys
keys: <KeyType extends IDBValidKey>( customStore?: UseStore) => Promise<KeyType[]>;
Get all keys in the store.
Parameter customStore
Method to get a custom store. Use with caution (see the docs).
function promisifyRequest
promisifyRequest: <T = undefined>( request: IDBRequest<T> | IDBTransaction) => Promise<T>;
function set
set: (key: IDBValidKey, value: any, customStore?: UseStore) => Promise<void>;
Set a value with a key.
Parameter key
Parameter value
Parameter customStore
Method to get a custom store. Use with caution (see the docs).
function setMany
setMany: ( entries: [IDBValidKey, any][], customStore?: UseStore) => Promise<void>;
Set multiple values at once. This is faster than calling set() multiple times. It's also atomic – if one of the pairs can't be added, none will be added.
Parameter entries
Array of entries, where each entry is an array of
[key, value]
.Parameter customStore
Method to get a custom store. Use with caution (see the docs).
function update
update: <T = any>( key: IDBValidKey, updater: (oldValue: T | undefined) => T, customStore?: UseStore) => Promise<void>;
Update a value. This lets you see the old value and update it as an atomic operation.
Parameter key
Parameter updater
A callback that takes the old value and returns a new value.
Parameter customStore
Method to get a custom store. Use with caution (see the docs).
function values
values: <T = any>(customStore?: UseStore) => Promise<T[]>;
Get all values in the store.
Parameter customStore
Method to get a custom store. Use with caution (see the docs).
Type Aliases
type UseStore
type UseStore = <T>( txMode: IDBTransactionMode, callback: (store: IDBObjectStore) => T | PromiseLike<T>) => Promise<T>;
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (25)
- @babel/core
- @babel/plugin-external-helpers
- @babel/plugin-transform-runtime
- @babel/preset-env
- @babel/runtime
- @rollup/plugin-babel
- @rollup/plugin-commonjs
- @rollup/plugin-node-resolve
- @rollup/plugin-terser
- @rollup/plugin-typescript
- @types/chai
- @types/mocha
- chai
- conditional-type-checks
- del
- filesize
- glob
- husky
- lint-staged
- mocha
- prettier
- rollup
- serve
- tslib
- typescript
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/idb-keyval
.
- Markdown[](https://www.jsdocs.io/package/idb-keyval)
- HTML<a href="https://www.jsdocs.io/package/idb-keyval"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2630 ms. - Missing or incorrect documentation? Open an issue for this package.