2.0.3 • Published 8 years ago

quartz-storage v2.0.3

Weekly downloads
7
License
-
Repository
github
Last release
8 years ago

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');

s === 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
2.0.3

8 years ago

2.0.2

8 years ago