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

@munchi_oy/cart-engine

v0.1.7

Published

Headless settlement engine for Munchi POS, kiosk, and mobile flows

Readme

@munchi_oy/cart-engine

Headless cart engine for Munchi POS flows.

This package owns cart state, pricing, discount application, and tax summary calculation. It is designed for offline-first consumers and shared across app surfaces without depending on React, Zustand, Firebase, or UI code.

Scope

This package includes:

  • Cart aggregate for cart state mutations
  • Pure pricing helpers
  • Pure discount helpers
  • Pure tax helpers
  • Shared cart-oriented types

This package does not include:

  • Product mapping from app DTOs into cart items
  • UI formatting
  • Persistence
  • Network calls
  • Activity logs or staff audit logging
  • Payment settlement logic

Core Rules

  • All money is in minor units as integers
  • Use Math.floor() for percentage-derived money calculations
  • Tax rate may be decimal, such as 13.5
  • Cart owns state
  • Pricing, discount, and tax modules stay pure and stateless
  • The package relies on shared DTO contracts from @munchi_oy/core

Install

pnpm add @munchi_oy/cart-engine @munchi_oy/core

Peer dependency:

  • @munchi_oy/core

Bundled runtime dependencies:

  • dayjs
  • lodash
  • @paralleldrive/cuid2

Package Layout

src/
  cart/
    Cart.ts
  discount/
    calculator.ts
    modulo.ts
  pricing/
    calculator.ts
  tax/
    index.ts
  types/
    index.ts
  utils/
    index.ts
  version.ts
  index.ts

Public API

Main exports:

  • Cart
  • calculateItemPrice
  • calculateCartPriceSnapshot
  • calculateDiscountAmount
  • calculateSequentialDiscountTotal
  • allocateProportionalMinorUnits
  • splitTaxInclusiveAmount
  • calculateOrderTaxSummary
  • ApplyTo
  • VERSION

Cart Responsibilities

Cart is the aggregate root for cart state. It currently handles:

  • item add, update, remove, and status changes
  • item and cart discounts
  • customer, invoice company, loyalty, and order metadata
  • serialization through toJSON()
  • rehydration through fromData()
  • cloning through clone()

Cart delegates all math to the pure modules under discount, pricing, and tax.

Pricing, Discount, and Tax Boundaries

Pricing

Pricing helpers work on normalized cart data and produce DTO-safe totals. They do not parse raw user input.

Discount

calculateDiscountAmount expects normalized values:

  • percentage discount values are percentages
  • fixed discount values are already in minor units

If the app needs to parse user-entered strings such as "10.50", that parsing should happen outside this package before calling the engine.

Tax

Tax calculations:

  • use integer money math
  • support decimal tax rates
  • group tax summaries by rate
  • allocate cart-level discounts proportionally before tax splitting

Development

Install dependencies:

pnpm install

Useful commands:

pnpm typecheck
pnpm test
pnpm build
pnpm yalc:publish
pnpm yalc:push

Testing

Tests live under test/ and are organized by concern:

  • cart item behavior
  • cart pricing behavior
  • cart tax behavior
  • cart metadata behavior
  • cart serialization behavior
  • pure discount helpers
  • pure pricing helpers
  • pure tax helpers

Current expectations:

  • cart totals must be correct for no discount, item discount, cart discount, and combined discount cases
  • tax summaries must group by dynamic tax rate
  • runtime fallbacks must behave safely

Versioning

Package version is sourced from package.json and synced into src/version.ts.

Sync version constant:

pnpm version:sync

Build always runs version sync first.

Release

Release script:

pnpm release -- 0.1.1

Optional GitHub release modes:

pnpm release -- 0.1.1 --publish
pnpm release -- 0.1.1 --publish=custom
pnpm release -- 0.1.1 --publish=file

The release script:

  • updates package.json
  • syncs src/version.ts
  • runs typecheck, tests, and build
  • creates a commit
  • creates a v<version> tag
  • pushes branch and tag
  • optionally creates a GitHub release

Consumer Notes

  • Rebuild before publishing or pushing with yalc
  • If a consumer app still sees stale types, rebuild and refresh the installed package
  • One cart should use one CurrencyCode