renaming files
This commit is contained in:
parent
8f15578bb4
commit
609ba4ef71
11 changed files with 14 additions and 14 deletions
|
|
@ -1,60 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var imports = require('soop').imports();
|
||||
|
||||
function Storage() {
|
||||
}
|
||||
|
||||
Storage.prototype._read = function(k) {
|
||||
var ret;
|
||||
try {
|
||||
ret = JSON.parse(localStorage.getItem(k));
|
||||
} catch (e) {};
|
||||
return ret;
|
||||
};
|
||||
|
||||
Storage.prototype._write = function(k,v) {
|
||||
localStorage.setItem(k, JSON.stringify(v));
|
||||
};
|
||||
|
||||
// get value by key
|
||||
Storage.prototype.getGlobal = function(k) {
|
||||
return this._read(k);
|
||||
};
|
||||
|
||||
// set value for key
|
||||
Storage.prototype.setGlobal = function(k,v) {
|
||||
this._write(k,v);
|
||||
};
|
||||
|
||||
// remove value for key
|
||||
Storage.prototype.removeGlobal = function(k) {
|
||||
localStorage.removeItem(k);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Storage.prototype._key = function(walletId, k) {
|
||||
return walletId + '::' + k;
|
||||
};
|
||||
// get value by key
|
||||
Storage.prototype.get = function(walletId, k) {
|
||||
return this.getGlobal(this._key(walletId,k));
|
||||
};
|
||||
|
||||
// set value for key
|
||||
Storage.prototype.set = function(walletId, k,v) {
|
||||
this.setGlobal(this._key(walletId,k), v);
|
||||
};
|
||||
|
||||
// remove value for key
|
||||
Storage.prototype.remove = function(walletId, k) {
|
||||
this.removeGlobal(this._key(walletId,k));
|
||||
};
|
||||
|
||||
// remove all values
|
||||
Storage.prototype.clearAll = function() {
|
||||
localStorage.clear();
|
||||
};
|
||||
|
||||
module.exports = require('soop')(Storage);
|
||||
Loading…
Add table
Add a link
Reference in a new issue