quartz-storage

2.0.3 • Public • Published

Quartz Storage Build Status

Quartz Storage is meant to be a simple and safe cross browser/platform storage for games. It makes use of localStorage when possible and falls back to cookies when localStorage is not accesible.

Storage can be namespaced so you can use same key values amonst different games/pages on the same site

Getting Started

First you'd want to include the library in your page by doing the following:

    <script src="path/to/your/external/libs/QuartzStorage.min.js"></script> 

Setup a namespace

The storage objects in Quartz Storage are by default all grouped in a Quartz: namespace. If you would like a different (game specific) namespace, you can just get an instance and set the namespace.

Quartz.Storage.getInstance()
    .setNamespace('myGameName');

Set/Get an item

Setting and getting of items is as straightforward as ever:

Quartz.Storage.getInstance()
    .set('foo', 'bar')
    .get('foo'); //bar

Keep in mind that due to localStorage all keys and values should be string!

var s = Quartz.Storage.getInstance();
 
s.set('number', 9*18);
 
var num = s.get('number');
 
=== 162; //false
parseInt(s, 10) === 162; //true

Changelog

2.0.2

  • Fixed an issue with the CookieStorage where values would have ';' appended to them

2.0.1

  • Added noImplicitAny
  • package rename to match npm's requirements

/quartz-storage/

    Package Sidebar

    Install

    npm i quartz-storage

    Weekly Downloads

    3

    Version

    2.0.3

    License

    none

    Last publish

    Collaborators

    • alebles