Giter Site home page Giter Site logo

plainweaver / humble-localstorage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gr2m/humble-localstorage

0.0 1.0 0.0 30.73 MB

wraps localStorage and adds .getObject(), .setObject(), .isPersistent

Home Page: http://gr2m.github.io/humble-localstorage/

JavaScript 100.00%

humble-localstorage's Introduction

humble-localstorage

wraps localStorage and adds .getObject(), .setObject(), .isPersistent

Build Status Dependencies Status devDependency Status

localStorage is a simple key/value store API for browsers, perfectly suited to store little amount of data like configurations.

humbleLocalStorage provides additional APIs to store / retrieve JSON objects, and also handles several circumstances in which Browsers do not support or persist localStorage (e.g. private modes, Cookies disabled, etc).

In case data cannot be persisted in localStorage, humbleLocalStorage falls back to in-memory storage. To determine if data is being persisted, use humbleLocalStorage.isPersistent property.

Installation

Usage

humbleLocalStorage.getItem('mykey') // string value or null
humbleLocalStorage.setItem('mykey', 123) // stored as '123'
humbleLocalStorage.removeItem('mykey')
humbleLocalStorage.clear() // removes all data
humbleLocalStorage.key(0) // name of key by numeric index, or null
humbleLocalStorage.length // number of stored keys

humbleLocalStorage.getObject('mykey') // JSON value or null
humbleLocalStorage.setObject('mykey', {foo: 'bar'}) // stored as '{"foo": "bar"}'
humbleLocalStorage.isPersistent // true if data persists page reload, false if not

Run tests

# see all available tasks
npm run

# run unit & integration tests
# note: selenium must be running
npm test

License

MIT

humble-localstorage's People

Contributors

gr2m avatar traviscibot avatar greenkeeperio-bot avatar

Watchers

plainweaver avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.