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;
};
function isJson(str) {
const isJson = str => {
try {
const data = JSON.parse(str);
return { data, success: true };
} catch (e) {
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 localStorage from "./storage/localStorage";
import * as typeValidator from "./data/typeValidator";
import * as localStorage from "./storage/localStorage";
export { typeValidator, localStorage };

View File

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