Socket
Socket
Sign inDemoInstall

cart-localstorage

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cart-localstorage - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

17

dist/cart-localstorage.js

@@ -9,3 +9,3 @@ var cartLS = (function (exports) {

const get = (key) => JSON.parse(localStorage.getItem(key || STORAGE_KEY)) || [];
const list = (key) => JSON.parse(localStorage.getItem(key || STORAGE_KEY)) || [];

@@ -22,16 +22,16 @@ const save = (data, key) => {

const list = () => get();
const get$1 = (id) => list().find((product) => product.id === id);
const get$1 = (id) => get().find((product) => product.id === id);
const exists = (id) => !!get$1(id);
const add = (product, quantity) => isValid(product) ? exists(product.id) ? update(product.id, 'quantity', get$1(product.id).quantity + (quantity || 1)) : save(get().concat({ ...product, quantity: quantity || 1 })) : null;
const add = (product, quantity) => isValid(product) ? exists(product.id) ? update(product.id, 'quantity', get$1(product.id).quantity + (quantity || 1)) : save(list().concat({ ...product, quantity: quantity || 1 })) : null;
const remove = (id) => save(get().filter((product) => product.id !== id));
const remove = (id) => save(list().filter((product) => product.id !== id));
const update = (id, field, value) => save(get().map((product) => product.id === id ? ({ ...product, [field]: value }) : product));
const quantity = (id, diff) => exists(id) && get$1(id).quantity + diff >= 0 ? update(id, 'quantity', get$1(id).quantity + diff) : remove(id);
const total = (cb) => get().reduce((sum, product) => isCallback(cb) ? cb(sum, product) : (sum += subtotal(product)), 0);
const update = (id, field, value) => save(list().map((product) => product.id === id ? ({ ...product, [field]: value }) : product));
const total = (cb) => list().reduce((sum, product) => isCallback(cb) ? cb(sum, product) : (sum += subtotal(product)), 0);
const destroy = () => clear();

@@ -56,2 +56,3 @@

exports.onChange = onChange;
exports.quantity = quantity;
exports.remove = remove;

@@ -58,0 +59,0 @@ exports.subtotal = subtotal;

{
"name": "cart-localstorage",
"version": "1.1.0",
"version": "1.1.1",
"description": "Tiny shopping cart on top of LolcalStorage - ES6, < 1Kb, test coverage",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc