feature(storage) rm unused removeMatch

This commit is contained in:
coderaiser 2020-08-19 18:14:30 +03:00
parent c8d2098e5b
commit aeb5906de3
2 changed files with 1 additions and 36 deletions

View file

@ -1,6 +1,5 @@
'use strict';
const tryCatch = require('try-catch');
const {parse, stringify} = JSON;
module.exports.set = async (name, data) => {
@ -17,9 +16,7 @@ module.exports.get = async (name) => {
module.exports.getJson = async (name) => {
const data = localStorage.getItem(name);
const [, result = data] = tryCatch(parse, data);
return result;
return parse(data);
};
module.exports.clear = () => {
@ -30,13 +27,3 @@ module.exports.remove = (item) => {
localStorage.removeItem(item);
};
module.exports.removeMatch = (string) => {
const reg = RegExp('^' + string + '.*$');
const test = (a) => reg.test(a);
const remove = (a) => localStorage.removeItem(a);
Object.keys(localStorage)
.filter(test)
.forEach(remove);
};

View file

@ -104,25 +104,3 @@ test('cloudcmd: client: storage: clear', async (t) => {
t.end();
});
test('cloudcmd: client: storage: removeMatch', async (t) => {
const {localStorage} = global;
const removeItem = stub();
global.localStorage = {
removeItem,
fileA: 1,
fileB: 2,
};
await storage.removeMatch('file');
global.localStorage = localStorage;
const {args} = removeItem;
const expected = [
['fileA'],
['fileB'],
];
t.deepEqual(args, expected);
t.end();
});