JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 38
  • Score
    100M100P100Q89224F
  • License ISC

Tiny shopping cart on top of LolcalStorage - ES6, < 1Kb, test coverage

Package Exports

  • cart-localstorage

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cart-localstorage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

cart-localstorage

Super Simple Shopping Cart on top of browser localStorage with a very small footprint (~1Kb, 0 dependencies)

Demo

//todo add codepen demo

INSTALL:

This is a JavaScript ES6 library. Use npm or yarn to add it to your project:

npm install cart-localstorage

or 

yarn install cart-localstorage

How to start?

import Cart from 'cart-localstorage' 

Cart.add({id: 1, name: "Product 1", price: 100},1)

console.log(Cart.total()) 
// output: 100

...

API

list()

Array of products in the cart.

list()
// output:  [{id: 1, name: "Nike Air", price: 100, quantity: 1}, {id: 1, name: "Adidas Superstar", price: 120, quantity: 2}]

get()

Get product by id

get(1)
// output:  [{id: 1, name: "Nike Air", price: 100, quantity: 1}]

add()

Adds product into the cart. If a product exists with the same increases the quantity only.

add({id: 3, name: "Vans", price: 75, quantity: 2})

remove()

Removes product by id

remove(1)

update(,)

Updates the product quantity on a specific product

update(1,5)

total()

detroy()




## License

This plugin is available under Apache 2.0 license.