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

sklad2

v0.0.2

Published

Simplest-possible async-await/promises wrapper on top of IndexedDB

Downloads

13

Readme

sklad2

This is a simplest-possible async-await/promises wrapper on top of IndexedDB. It's a successor to sklad library.

API

import { open, deleteDatabase } from 'sklad2';

// open connection to the database
const sklad = await open('databaseName', [...migrations]);

// insert records into the object store(s)
const insertIds = await sklad.insertIntoOneStore('storeName', [...records]);
const insertIdsMultiple = await sklad.insertIntoMultiple({
  storeName1: [...records1],
  storeName2: [...records2],
});

// upsert records in the object store(s)
const upsertIds = await sklad.upsertIntoOneStore('storeName', [...records]);
const upsertIdsMultiple = await sklad.upsertIntoMultiple({
  storeName1: [...records1],
  storeName2: [...records2],
});

// delete records in the object store(s)
await sklad.deleteFromStore('storeName', 'key');
await sklad.deleteFromStores({
  storeName1: 'key',
  storeName2: IDBKeyRange.lowerBound('key'),
});

// count records in the object store(s)
const total = await sklad.countOneStore('storeName');
const totalMultiple = await sklad.countMultipleStores({
  storeName1: {}, // count all records in the object store
  storeName2: {
    indexName: 'index',
    range: IDBKeyRange.only('something'),
  }, // all options are optional
});

// get records from the object store(s)
const records = await sklad.getOneStore('storeName');
const recordsMultiple = await sklad.getMultipleStores({
  storeName1: {}, // get all records from the object store
  storeName2, {
    indexName: 'index',
    range: IDBKeyRange.upperBound('key'),
    direction: 'nextunique',
    offset: 10,
    limit: 10,
  }, // all options are optional
});

// clear records in the object store(s)
await sklad.clearStore('storeName');
await sklad.clearStores(['storeName1', 'storeName2']);

// delete the database
await deleteDatabase('databaseName');

Differences with sklad

Browsers support

sklad was designed to work in almost all browsers which had some IndexedDB support. sklad2 is designed to work in the browsers which don't have IndexedDB implementation bugs which are the latest desktop Chrome, Firefox, Safari, mobile Chrome and Safari.

Testing

sklad was heavily tested in different real browsers which had different IndexedDB implementation support. sklad2 has only a couple end-to-end tests that you can run in your browser and see if it works or not. If you want to test your mobile browser you can consider running ngrok to open the test page in the browser.

Types

sklad2 is written in Typescript which means it has built-in types support.

API

sklad2 takes inspiration from sklad but still has slightly different method names: get in sklad has getOneStore and getMultipleStores in sklad2. See API section above for examples.

Bundle format

sklad2 NPM package has "module" support which is ES6 modules code, UMD code as "unpkg" and "main" which is CommonJS. It doesn't contain any polyfills for IndexedDB or Promises.