cart-localstorage
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -7,2 +7,3 @@ var cartLS = (function (exports) { | ||
let saveListener = null; | ||
const listen = (cb) => { saveListener = cb; }; // ugly but storage listener is not working for the same window.. | ||
@@ -16,6 +17,7 @@ const get = (key) => JSON.parse(localStorage.getItem(key || STORAGE_KEY)) || []; | ||
const clear = () => localStorage.removeItem(STORAGE_KEY); | ||
const clear = () => { | ||
localStorage.removeItem(STORAGE_KEY); | ||
if(saveListener) saveListener(get(key || STORAGE_KEY)); | ||
}; | ||
const listen = (cb) => { saveListener = cb; }; // ugly but storage listener is not working for the same window.. | ||
const list = () => get(); | ||
@@ -22,0 +24,0 @@ |
{ | ||
"name": "cart-localstorage", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Tiny shopping cart on top of LolcalStorage - ES6, < 1Kb, test coverage", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,3 +13,5 @@ const STORAGE_KEY = '__cart' | ||
export const clear = () => localStorage.removeItem(STORAGE_KEY) | ||
export const clear = () => { | ||
localStorage.removeItem(STORAGE_KEY) | ||
if(saveListener) saveListener(get(key || STORAGE_KEY)) | ||
} |
Sorry, the diff of this file is not supported yet
13415
207