localstorify

0.2.2 • Public • Published

localStorage that avoids storage limit failures

Why?

Because localStorage is great, but extremely limited in functionality and robustness. This library adds:

  • automatic garbage collection and limit detection (no failures on persistence)

Installation

yarn add -D @kwhitley/localstorify

Usage

Simply replace references to localStorage with the the export of this library.

  import localstorify from '@kwhitley/localstorify'
 
  // replace
  localStorage.getItem('foo')
  // with
  localstorify.getItem('foo')
 
  ...
 
  // or
  localStorage.setItem('foo', JSON.stringify({ foo: 'bar' }))
  // with
  localstorify.setItem('foo', JSON.stringify({ foo: 'bar' }))

Package Sidebar

Install

npm i localstorify

Weekly Downloads

7

Version

0.2.2

License

MIT

Unpacked Size

6.87 kB

Total Files

4

Last publish

Collaborators

  • krwhitley