small fix

master
Tudor Stanciu 2023-01-30 00:40:37 +02:00
parent 59017a5a60
commit 2ad11221ac
3 changed files with 10 additions and 10 deletions

View File

@ -11,13 +11,13 @@ const isObject = parameter => {
return _isObject; return _isObject;
}; };
function isJson(str) { const isJson = str => {
try { try {
const data = JSON.parse(str); const data = JSON.parse(str);
return { data, success: true }; return { data, success: true };
} catch (e) { } catch (e) {
return { data: null, success: false }; return { data: null, success: false };
} }
} };
export default { isArray, isObject, isJson }; export { isArray, isObject, isJson };

View File

@ -1,4 +1,4 @@
import typeValidator from "./data/typeValidator"; import * as typeValidator from "./data/typeValidator";
import localStorage from "./storage/localStorage"; import * as localStorage from "./storage/localStorage";
export { typeValidator, localStorage }; export { typeValidator, localStorage };

View File

@ -10,8 +10,8 @@ const setItem = (key, value) => {
}; };
const getItem = key => { const getItem = key => {
var value = window.localStorage.getItem(key); const value = window.localStorage.getItem(key);
var { data, success } = isJson(value); const { data, success } = isJson(value);
if (success) { if (success) {
return data; return data;
@ -28,9 +28,9 @@ const clear = () => {
window.localStorage.clear(); window.localStorage.clear();
}; };
const key = index => { const getKey = index => {
var keyName = window.localStorage.key(index); const keyName = window.localStorage.key(index);
return keyName; return keyName;
}; };
export default { setItem, getItem, removeItem, clear, key }; export { setItem, getItem, removeItem, clear, getKey };