npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

l2-module-cart-and-discounts

v1.0.3

Published

Webshop-utils

Readme

Shopping Cart module

HEADS UP

This is a basic modul that is written by me, Casper a student at linnaeus university. Bugs may occur.


The shopping cart is a simplel tool for building a webb store. It manages the cart functionality, handles shipping costs, and applies discount rules.

Installation

This is a Node.js module available through the npm registry.

Before installing, make sure you have Node.js installed.

If this is a brand new project, initialize it with:

npm init -y

Install the package using npm:

npm i l2-module-cart-and-discounts

Example Usage

A full test script is included with the package to demonstrate all features of the shopping cart and discount system. You can find it in the test folder:

Here’s a short example from the test script:

import { Cart } from "l2-module-cart-and-discounts"

const cart = new Cart()

const productA = { id: 1, name: "T-shirt", price: 299 }
const productB = { id: 2, name: "Sneakers", price: 1200 }
const productC = { id: 3, name: "Hoodie", price: 600 }

cart.discountManager.setFreeShippingThreshold(1000)
cart.discountManager.shippingCost = 49

cart.addProductToCart(productA, 1)
console.log("Cart:", cart.items)
console.log("Total price:", cart.getTotalPriceafterDiscounts())
console.log("Shipping fee:", cart.getShippingCost())
console.log("Total prrice to pay:", cart.getFinalPrice())

For a complete demonstration including discounts, “Buy X Pay for Y” rules, and free shipping, run the full test script included in the package.

Dependencies, Language and Versions

Language & Runtime

  • The module is implemented in JavaScrip
  • Requires Node.js

Dependencies

All dependencies are managed with npm and defined in package.json.

DevDependencies:

  • jest - used for unit testing
  • babel-jest – integrates Babel with Jest for ES module support.
  • @babel/core and @babel/preset-env – ensure compatibility with modern JavaScript features.

There are currently no runtime dependencies, meaning the module can be used without extra installations apart from Node.js itself.

Versioning

  • This project follows Semantic Versioning (SemVer):
  • MAJOR – Breaking changes
  • MINOR – Backwards-compatible new features
  • PATCH – Bug fixes

The current version is 1.0.1.

Installation of Dependencies

To install all dependencies, run:

npm install

Contributing

Contributions are welcome!

If you want to help improve this project, here’s how you can get started:

developer guide

TEST

Test report

License

MIT