npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bkv

v1.0.3

Published

Browser key/value storage with simple interface

Downloads

4

Readme

bkv - simple KV storage for browsers

CI NPM version

bkv is browser persistent key/value storage with simple interface. It supports actual IndexedDB / localStorage. With silent fallback to memory store for error-less work (optional).

Install

npm install bkv --save

Examples

const bkv = new window.BKV()

await bkv.set('dolorem', { lorem: 'ipsum' })

const data = await bkv.get('dolorem')
console.log(`Loaded: ${data}`)

await bkv.remove('dolorem'));

API

Note, all methods with optional callbacks will return promises if callback is not set.

new BKV([options])

Options:

  • prefix - Data namespace. Default - bkv. Used to separate data for multiple instances, if required.
  • stores - Array of storage names to use, ordered by preference. Default ['indexeddb', 'localstorage', 'zero']. Set to ['indexeddb', 'localstorage'] if no fallback to memory required.

* zero is simple memory store for silent fallback when no persistent storages available.

.get(key [, default]) => Promise

Load data by key name. If not exists - returns default (if passed) or undefined.

.getAll() => Promise

Load all data from storage as [ { key, value }, { key, value }, ... ].

.set(key, data [, ttl]) => Promise

Put data into storage under key name.

  • key - String to address data.
  • data - serializable JS object to store.
  • ttl - Expiration time in seconds. Default = 0 (don't expire).

.remove(key | [keys]) => Promise

Remove key data from store. If Array passed - remove all listed keys.

.clear([expiredOnly]) => Promise

Clear all storage data (in your namespace), or just expired objects when called with true param.

.init() => Promise

Auto-executed on first call of any method. Usually not needed. But may be used, if you need exact info about availability of persistent storage, prior to start.

.create(options)

Alias of new BKV(options)

.shared(options)

Similar to .create() but returns the same (cached) instance for the same options. Useful if you need BKV in multiple modules, and don't wish to initialize it every time.