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

idb-lite

v0.1.0

Published

Light weight indexed-db key value library matching the API of https://www.npmjs.com/package/idb-keyval"

Downloads

6

Readme

:sparkles: PSA - this is an alpha version. Not tested in older browsers yet. File issues at will... :sparkles:

idb-lite

Implementation of @jakearchibald's excellent idb-keyval API. See https://github.com/jakearchibald/idb-keyval for the original.

Purpose

The intent of this version is to add some functionality not included in Jake's version, including:

  1. Allows multiple stores within the same browser session
  2. Reuse connection to same underlying store (helps in older versions of IE)
  3. Allow explicit closing of database connections
  4. TBD Allow multiple stores per database (https://github.com/goofballLogic/idb-lite/issues/1)

It also includes tests which can easily be executed in various different browsers

Important differences

Private API

Care has been taken to replicate the API of the original library. However, note that certain "private" properties are not currently exposed (e.g. the _dbp property of a Store object). Feel free to suggest additions if you need these.

Closing database connections

Because this library reuses the same underlying connection when database and store match, they will not be automatically closed when references are released. You should use the closeAll method to close connections if you are worried about releasing this memory. Although this could be achieved automatically using a WeakMap, we have chosen not to do so at this time (as it would create a breaking change between older and newer browsers).

Implementation

The original library is written in typescript and compiled down to ES6 and ES5. This version is written in ES5, with a manually written typescript definition file. It also avoids class constructs and the original's "private" API, producing a slightly smaller output.

File sizes

The tiny size of idb-keyval, as well as support for treeshaking, are important characteristics of the original library, so care has been taken to produce assets which are at least no bigger than the originals.

Some notes on the comparison:

  1. In each case "idb-keyval" has been replaced with "index".
  2. These files contain the extract function "closeAll" which closes connections to open databases
  3. File sizes are as reported when viewed in GitHub on 2019-08-27

| file | size | idb-keyval size | | ----------------- | ---------- | --------------- | | index-cjs.js | 1.79 KB | 2.38 KB | | index-iife.js | 1.88 KB | 2.38 KB | | index-iife.min.js | 1000 Bytes | 1.06 KB | | index.mjs | 1.77 KB | 2.38 KB |

Building

npm run build or npm run build_watch

Building tests

N.B. You only need to "build" the typescript tests - all others are written by hand. npm run build_ts_tests or npm run build_ts_tests_watch

Running tests

Tests are deliberately manually executed by loading a browser page to ease with testing in legacy browsers.

npm run test then navigate to http://localhost:8080/tests

Documentation

As this is an implementation of a pre-defined API, please use the documentation found at https://github.com/jakearchibald/idb-keyval.

Extended functionality

closeAll

This function returns a promise to close all the database connections that have been opened in this session