@immutabl3/mini-forage

2.0.0 • Public • Published

mini-forage

mini-forage is a fast and simple storage library for indexeddb with an asyncronous localStorage-esque API

Install

npm install @immutabl3/mini-forage

How to use

Async

Because miniforage uses async storage, all methods return an promise. It's otherwise exactly the same as the localStorage API.

import miniforage from '@immutabl3/mini-forage';

await miniforage.setItem('key', 'value');

const result = await miniforage.getItem('key');
// result === 'value'

Storing Blobs, TypedArrays, and other JS objects

You can store JSON, ArrayBuffers, Blobs and TypedArrays in miniforage. miniforage automatically JSON.parse() and JSON.stringify() values when getting/setting

Multiple instances

You can create multiple instances of miniforage that point to different stores

import { MiniForage } from '@immutabl3/mini-forage';
const store = MiniForage({
  name: "nameHere"
});

const otherStore = MiniForage({
  name: "otherName"
});

// Setting the key on one of these doesn't affect the other.
store.setItem('key', 'value');
otherStore.setItem('key', 'value2');

Library Size

As of version 1.0.0 the payload added to your app is rather small. Served using gzip compression, miniforage will add less than 1.5k to your total bundle size:

minified
`~3.9kB`
gzipped
`~1.3kB`
brotli'd
`~1.1kB`

License

MITå

Readme

Keywords

none

Package Sidebar

Install

npm i @immutabl3/mini-forage

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

11.5 kB

Total Files

11

Last publish

Collaborators

  • immutabl3