Socket
Book a DemoInstallSign in
Socket

@jacobmarshall/kv

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jacobmarshall/kv

A super simple key value store backed by IndexedDB

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

kv

This is a fork of idk-kv.

A super simple key value store backed by IndexedDB.

Since it is backed by IndexedDB, you can store anything structured-clonable (numbers, arrays, objects, dates, blobs etc - but beware of browser support).

It's best used with a module loader (webpack, browserify, etc...) so that the global scope isn't poluted with kv.

Usage

kv(string name) kv

Creates a custom kv store with a given name.

const store = kv('sw-storage');
await store.set('hello', 'world');
console.log(await kv.get('hello'));
// -> undefined

kv.set(string key, * value) Promise

await kv.set('hello', 'world');
await kv.set('foo', 'bar');
try {
  await kv.set('hello', 'world')
  console.log('It worked!');
} catch(err) {
  console.log('It failed!', err);
}

kv.get(string key) Promise<*>

console.log(await kv.get('hello'));
// -> "world"

kv.keys() Promise<string>

console.log(await kv.keys());
// -> ["hello", "foo"]

kv.remove(string key) Promise

await kv.remove('hello');

kv.clear() Promise

await kv.clear();

That's it!

Keywords

idb

FAQs

Package last updated on 19 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts