var localStorage = angular.module('localStorage', []);
localStorage.factory('localStorageService', function() {
var storageSupportedService;
function isLocalStorageSupported() {
var testKey = 'key', storage = window.localStorage;
try {
storage.setItem(testKey, '1');
storage.removeItem(testKey);
return localStorageName in window && window[localStorageName];
} catch (e) {
// return false;
if (e == QUOTA_EXCEEDED_ERR) {
//do obj storage
}
}
}
return storageSupportedService;
});
this.storageData = function () {
module.exports = {
name: 'memoryStorage',
read: read,
write: write,
each: each,
remove: remove,
clearAll: clearAll
};
var memoryStorage = {};
function read(key) {
return memoryStorage[key]
}
function write(key, data) {
memoryStorage[key] = data
}
function each(callback) {
for (var key in memoryStorage) {
if (memoryStorage.hasOwnProperty(key)) {
callback(memoryStorage[key], key)
}
}
}
function remove(key) {
delete memoryStorage[key]
}
function clearAll(key) {
memoryStorage = {}
}
};
что то такое пока что получается. гляньте кто то плз