cart-localstorage
Advanced tools
Comparing version 1.0.7 to 1.0.8
{ | ||
"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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17146
9
246
123