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.0.7 to 1.0.8

dist/cart-localstorage.js

4

package.json
{
"name": "cart-localstorage",
"version": "1.0.7",
"version": "1.0.8",
"description": "Tiny shopping cart on top of LolcalStorage - ES6, < 1Kb, test coverage",

@@ -8,3 +8,3 @@ "main": "index.js",

"test": "jest",
"build": "rollup index.js --file dist/index.js --format iife --name cartLS"
"build": "rollup index.js --file dist/cart-localstorage.js --format iife --name cartLS"
},

@@ -11,0 +11,0 @@ "repository": {

@@ -5,8 +5,13 @@ # cart-localstorage

This library utilizes the browser's localStorage and creates a persistent shopping cart instance during the first add(product) call.
This micro library utilizes the browser's localStorage to create a persistent shopping cart instance.
## Demo
[Cart demo](http://peet86.github.io/cart-localstorage)
## Install:
This is a JavaScript ES6 library. Use npm or yarn to add it to your project:
Use npm or yarn to add it to your ES6 project:

@@ -21,4 +26,11 @@ ```

## Example
OR use the bundled version:
```
<script src="cart-localstorage.js"></script>
```
## Example
```

@@ -34,7 +46,4 @@ import { add, total } from 'cart-localstorage'

## Demo
//todo
## API

@@ -44,4 +53,4 @@

Adds a product into the cart. If the product is already exists (same id) it increases the quantity with +1.
"Product" should be a JavaScript object with "id" and "price" properties.
Adds a product into the cart. If the product is already exists (same id) it increases the quantity of the product with 1.
"Product" always should be a JavaScript object with "id" and "price" mandatory properties.

@@ -77,3 +86,3 @@ ```

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

@@ -83,3 +92,3 @@

Removes the product from the cart
Removes product from the cart

@@ -90,5 +99,5 @@ ```

#### update(id, field, value)
#### update(id, property, value)
Updates product's field with a certain value.
Updates product's property with a certain value.
```

@@ -106,3 +115,3 @@ update(1,'price',200)

```
or you can pass a custom reducer function as first argument and return with a custom field's total value.
or you can pass a custom reducer function as the first argument and have full control over the calculation.

@@ -116,3 +125,2 @@

detroy()
```

@@ -119,0 +127,0 @@

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