From c5f2bdaf597909f71a3ee551966daa0e47367baf Mon Sep 17 00:00:00 2001 From: Max Wan Date: Thu, 22 Oct 2020 19:20:45 +0900 Subject: [PATCH] feat: add del to storage --- src/storage.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/storage.ts b/src/storage.ts index f55e73c..5516ea6 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -26,7 +26,15 @@ export function set(key: string, value: string): void { sessionStorage.setItem(STORE_KEY, JSON.stringify(data)); } +export function del(key: string): void { + const data = getStorageObject(); + delete data[key]; + + sessionStorage.setItem(STORE_KEY, JSON.stringify(data)); +} + export default { set, get, + del, };