all files / src/init/ ve.init.SafeStorage.js

85.71% Statements 6/7
100% Branches 0/0
0% Functions 0/1
85.71% Lines 6/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63                                                                                                                 
/**
 * A wrapper for an HTML5 Storage interface (`localStorage` or `sessionStorage`)
 * that is safe to call on all browsers.
 *
 * @abstract
 * @class ve.init.SafeStorage
 *
 * @constructor
 * @param {Storage|undefined} store The Storage instance to wrap around
 */
ve.init.SafeStorage = function ( store ) {
	this.store = store;
};
 
/**
 * Retrieve value from device storage.
 *
 * @abstract
 * @param {string} key Key of item to retrieve
 * @return {string|null|boolean} String value, null if no value exists, or false
 *  if storage is not available.
 */
ve.init.SafeStorage.prototype.get = null;
 
/**
 * Set a value in device storage.
 *
 * @abstract
 * @param {string} key Key name to store under
 * @param {string} value Value to be stored
 * @return {boolean} The value was set
 */
ve.init.SafeStorage.prototype.set = null;
 
/**
 * Remove a value from device storage.
 *
 * @abstract
 * @param {string} key Key of item to remove
 * @return {boolean} Whether the save succeeded or not
 */
ve.init.SafeStorage.prototype.remove = null;
 
/**
 * Retrieve JSON object from device storage.
 *
 * @abstract
 * @param {string} key Key of item to retrieve
 * @return {Object|null|boolean} Object, null if no value exists or value
 *  is not JSON-parseable, or false if storage is not available.
 */
ve.init.SafeStorage.prototype.getObject = null;
 
/**
 * Set an object value in device storage by JSON encoding
 *
 * @abstract
 * @param {string} key Key name to store under
 * @param {Object} value Object value to be stored
 * @return {boolean} The value was set
 */
ve.init.SafeStorage.prototype.setObject = null;