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, test coverage
Super simple shopping cart library
This library utilizes the browser's localStorage and creates a persistent shopping cart instance during the first add(product) call.
This is a JavaScript ES6 library. Use npm or yarn to add it to your project:
npm install cart-localstorage
yarn add cart-localstorage
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
//todo
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.
const myproduct = {id: 3, name: "Vans", price: 75}
add(myproduct, 2)
Get product by id
get(1)
// {id: 1, name: "Nike Air", price: 100, quantity: 1}
Checks if the product is already exists in the cart
exists(21)
// true or false
Dumps the cart as an array of products.
list()
// [{id: 1, name: "Nike Air", price: 100, quantity: 1}, {id: 1, name: "Adidas Superstar", price: 120, quantity: 2}]
Removes the product from the cart
remove(1)
Updates product's field with a certain value.
update(1,'price',200)
By default it returns with the total price:
total()
// 220
or you can pass a custom reducer function as first argument and return with a custom field's total value.
Deletes the cart array from localStorage.
detroy()
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.