From 2ad11221ac1d31111e934f20ebfbccabf856c060 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Mon, 30 Jan 2023 00:40:37 +0200 Subject: [PATCH] small fix --- src/data/typeValidator.js | 6 +++--- src/index.js | 4 ++-- src/storage/localStorage.js | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/data/typeValidator.js b/src/data/typeValidator.js index 6492b98..28d7f75 100644 --- a/src/data/typeValidator.js +++ b/src/data/typeValidator.js @@ -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 }; diff --git a/src/index.js b/src/index.js index b14ca17..25297f6 100644 --- a/src/index.js +++ b/src/index.js @@ -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 }; diff --git a/src/storage/localStorage.js b/src/storage/localStorage.js index b75a66d..28b6f35 100644 --- a/src/storage/localStorage.js +++ b/src/storage/localStorage.js @@ -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 };