Socket
Socket
Sign inDemoInstall

cart-localstorage

Package Overview
Dependencies
37
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.3 to 1.1.4

2

dist/cart-localstorage.min.js

@@ -1,1 +0,1 @@

var cartLS=function(a){'use strict';function b(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function c(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function d(a){for(var b,d=1;d<arguments.length;d++)b=null==arguments[d]?{}:arguments[d],d%2?c(b,!0).forEach(function(c){f(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):c(b).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}var e=function(a,b){return b={exports:{}},a(b,b.exports),b.exports}(function(a){function b(a){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},b(a)}function c(d){return a.exports="function"==typeof Symbol&&"symbol"===b(Symbol.iterator)?c=function(a){return b(a)}:c=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":b(a)},c(d)}a.exports=c}),f=b,g="__cart",h=null,i=function(a){h=a},j=function(a){return JSON.parse(localStorage.getItem(a||g))||[]},k=function(a,b){localStorage.setItem(b||g,JSON.stringify(a)),h&&h(j(b||g))},l=function(a){localStorage.removeItem(a||g),h&&h(j(a||g))},m=function(a){return j().find(function(b){return b.id===a})},n=function(a){return!!m(a)},o=function(a){return k(j().filter(function(b){return b.id!==a}))},p=function(a,b,c){return k(j().map(function(e){return e.id===a?d({},e,f({},b,c)):e}))},q=function(a){return a.id&&a.price},r=function(a){return s(a)?a.price*a.quantity:0},s=function(a){return a&&a.price&&a.quantity},t=function(a){return a&&"function"==typeof a};return a.add=function(a,b){return q(a)?n(a.id)?p(a.id,"quantity",m(a.id).quantity+(b||1)):k(j().concat(d({},a,{quantity:b||1}))):null},a.destroy=function(){return l()},a.exists=n,a.get=m,a.list=j,a.onChange=function(a){return t(a)?i(a):console.log(e(a))},a.quantity=function(a,b){return n(a)&&0<=m(a).quantity+b?p(a,"quantity",m(a).quantity+b):o(a)},a.remove=o,a.subtotal=r,a.total=function(a){return j().reduce(function(b,c){return t(a)?a(b,c):b+=r(c)},0)},a.update=p,a}({});//# sourceMappingURL=cart-localstorage.min.js.map
var cartLS=function(a){'use strict';function b(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function c(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function d(a){for(var b,d=1;d<arguments.length;d++)b=null==arguments[d]?{}:arguments[d],d%2?c(b,!0).forEach(function(c){f(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):c(b).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}var e=function(a,b){return b={exports:{}},a(b,b.exports),b.exports}(function(a){function b(a){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},b(a)}function c(d){return a.exports="function"==typeof Symbol&&"symbol"===b(Symbol.iterator)?c=function(a){return b(a)}:c=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":b(a)},c(d)}a.exports=c}),f=b,g="__cart",h=null,i=function(a){h=a},j=function(a){return JSON.parse(localStorage.getItem(a||g))||[]},k=function(a,b){localStorage.setItem(b||g,JSON.stringify(a)),h&&h(j(b||g))},l=function(a){localStorage.removeItem(a||g),h&&h(j(a||g))},m=function(a){return j().find(function(b){return b.id===a})},n=function(a){return!!m(a)},o=function(a){return k(j().filter(function(b){return b.id!==a}))},p=function(a,b,c){return k(j().map(function(e){return e.id===a?d({},e,f({},b,c)):e}))},q=function(a){return a.id&&a.price},r=function(a){return s(a)?a.price*a.quantity:0},s=function(a){return a&&a.price&&a.quantity},t=function(a){return a&&"function"==typeof a};return a.add=function(a,b){return q(a)?n(a.id)?p(a.id,"quantity",m(a.id).quantity+(b||1)):k(j().concat(d({},a,{quantity:b||1}))):null},a.destroy=function(){return l()},a.exists=n,a.get=m,a.list=j,a.onChange=function(a){return t(a)?i(a):console.log(e(a))},a.quantity=function(a,b){return n(a)&&0<m(a).quantity+b?p(a,"quantity",m(a).quantity+b):o(a)},a.remove=o,a.subtotal=r,a.total=function(a){return j().reduce(function(b,c){return t(a)?a(b,c):b+=r(c)},0)},a.update=p,a}({});//# sourceMappingURL=cart-localstorage.min.js.map

@@ -11,3 +11,3 @@ import { list, save, clear, listen } from './utils/localstorage'

const quantity = (id, diff) => exists(id) && get(id).quantity + diff >= 0 ? update(id, 'quantity', get(id).quantity + diff) : remove(id);
const quantity = (id, diff) => exists(id) && get(id).quantity + diff > 0 ? update(id, 'quantity', get(id).quantity + diff) : remove(id);

@@ -14,0 +14,0 @@ const update = (id, field, value) => save(list().map((product) => product.id === id ? ({ ...product, [field]: value }) : product))

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc