6 * Library for storing device specific information. It should be used for storing simple
7 * strings and is not suitable for storing large chunks of data.
12 isLocalStorageSupported
: false,
14 * Retrieve value from device storage.
16 * @param {String} key of item to retrieve
17 * @returns {String|Boolean} false when localStorage not available, otherwise string
19 get: function ( key
) {
20 if ( this.isLocalStorageSupported
) {
21 return localStorage
.getItem( key
);
28 * Set a value in device storage.
30 * @param {String} key key name to store under.
31 * @param {String} value to be stored.
32 * @returns {Boolean} whether the save succeeded or not.
34 set: function ( key
, value
) {
36 localStorage
.setItem( key
, value
);
44 * Remove a value from device storage.
46 * @param {String} key of item to remove.
47 * @returns {Boolean} whether the save succeeded or not.
49 remove: function ( key
) {
50 if ( this.isLocalStorageSupported
) {
51 localStorage
.removeItem( key
);
60 // See if local storage is supported
62 localStorage
.setItem( 'localStorageTest', 'localStorageTest' );
63 localStorage
.removeItem( 'localStorageTest' );
64 storage
.isLocalStorageSupported
= true;
66 // Already set. No body needed.