return JSON.parse(val);
}
+ service.getSessionItem = function(key) {
+ var val = $window.sessionStorage.getItem(key);
+ if (val == null) return;
+ return JSON.parse(val);
+ }
+
service.setItem = function(key, value) {
var str = JSON.stringify(value);
return service.setRemoteItem(key, str)['catch'](
$window.localStorage.setItem(key, jsonified);
}
+ service.setSessionItem = function(key, value, jsonified) {
+ if (jsonified === undefined )
+ jsonified = JSON.stringify(value);
+ $window.sessionStorage.setItem(key, jsonified);
+ }
+
// appends the value to the existing item stored at key.
// If not item is found at key, this behaves just like setItem()
service.appendItem = function(key, value) {
$window.localStorage.removeItem(key);
}
+ service.removeSessionItem = function(key) {
+ $window.sessionStorage.removeItem(key);
+ }
+
// if set, prefix limits the return set to keys starting with 'prefix'
service.getKeys = function(prefix) {
return service.getRemoteKeys(prefix)['catch'](