small fix
parent
59017a5a60
commit
2ad11221ac
|
@ -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 };
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Reference in New Issue