2014-07-08 20:05:41 -03:00
|
|
|
//localstorage Mock
|
|
|
|
|
|
2014-09-17 12:10:26 -03:00
|
|
|
function FakeLocalStorage() {
|
|
|
|
|
this.ls = {};
|
|
|
|
|
};
|
|
|
|
|
FakeLocalStorage.prototype.removeItem = function(key, cb) {
|
|
|
|
|
delete this.ls[key];
|
2014-09-08 10:46:57 -03:00
|
|
|
cb();
|
2014-07-08 20:05:41 -03:00
|
|
|
};
|
|
|
|
|
|
2014-09-17 12:10:26 -03:00
|
|
|
FakeLocalStorage.prototype.getItem = function(k, cb) {
|
|
|
|
|
return cb(this.ls[k]);
|
2014-07-08 20:05:41 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 12:10:26 -03:00
|
|
|
FakeLocalStorage.prototype.allKeys = function(cb) {
|
|
|
|
|
return cb(Object.keys(this.ls));
|
2014-07-08 20:05:41 -03:00
|
|
|
};
|
|
|
|
|
|
2014-09-17 12:10:26 -03:00
|
|
|
FakeLocalStorage.prototype.setItem = function(k, v, cb) {
|
|
|
|
|
this.ls[k] = v;
|
2014-09-04 18:07:09 -03:00
|
|
|
return cb();
|
2014-07-08 20:05:41 -03:00
|
|
|
};
|
2014-09-27 18:00:27 -03:00
|
|
|
FakeLocalStorage.prototype.clear = function(cb) {
|
2014-09-17 12:10:26 -03:00
|
|
|
this.ls = {};
|
2014-09-27 18:00:27 -03:00
|
|
|
if (cb) return cb();
|
2014-09-17 12:10:26 -03:00
|
|
|
}
|
2014-07-08 20:05:41 -03:00
|
|
|
|
2014-08-14 14:33:28 -04:00
|
|
|
module.exports = FakeLocalStorage;
|
2014-09-17 12:10:26 -03:00
|
|
|
|
|
|
|
|
module.exports.storageParams = {
|
2014-09-27 16:43:10 -03:00
|
|
|
password: '123',
|
2014-09-27 18:00:27 -03:00
|
|
|
db: new FakeLocalStorage(),
|
2014-09-17 12:10:26 -03:00
|
|
|
sessionStorage: new FakeLocalStorage(),
|
2014-09-30 21:16:46 -03:00
|
|
|
passphrase: {
|
|
|
|
|
iterations: 1,
|
|
|
|
|
},
|
2014-09-17 12:10:26 -03:00
|
|
|
};
|