Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
cart-localstorage
Advanced tools
Tiny shopping cart on top of LolcalStorage - ES6, < 1Kb, full test coverage
This micro library utilizes the browser's localStorage to create a persistent shopping cart instance
Use npm or yarn to add it to your ES6 project:
npm install cart-localstorage
yarn add cart-localstorage
OR use the bundled version (via CDN):
<script src="https://unpkg.com/cart-localstorage@1.1.2/dist/cart-localstorage.min.js" type="text/javascript"></script>
import { add, total } from 'cart-localstorage'
add({id: 1, name: "Product 1", price: 100})
add({id: 2, name: "Product 2", price: 100}, 2)
console.log(total())
// output: 300
Adds product to the cart. If the product already exists it increases the quantity with 1. The product object structure is flexible, only "id" and "price" are mandatory properties.
const myproduct = {id: 3, name: "Vans", price: 75}
add(myproduct, 2)
Get product from the cart by id
get(1)
// {id: 1, name: "Nike Air", price: 100, quantity: 1}
Checks if the product already exists in the cart
exists(21)
// true or false
Get the content of the cart as an array of products.
list()
// [{id: 1, name: "Nike Air", price: 100, quantity: 1}, {id: 2, name: "Adidas Superstar", price: 120, quantity: 2}]
Removes the product from the cart
remove(1)
Updates the product's property with a certain value.
update(1,'price',200)
Increase / decrease product's quantity with a positive or negative value.
quantity(22,-1) // will decrease the quantity of product [id:22] with 1.
By default returns with the total price:
total()
// 220
or you can pass a custom reducer function to have full control over the calculation.
Deletes the cart array from the browser's localStorage.
destroy()
This plugin is available under Apache 2.0 license.
FAQs
Tiny shopping cart on top of LolcalStorage - ES6, < 1Kb, full test coverage
The npm package cart-localstorage receives a total of 272 weekly downloads. As such, cart-localstorage popularity was classified as not popular.
We found that cart-localstorage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.