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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@obs-hq/money

v0.0.4

Published

A simple library to operate with monetary values

Downloads

6

Readme

Description

A simple and tiny library with no dependencies for monetary operations. Solves javascript rounding problems and guarantees proper rounding to cents.

Instalation

npm -i @obs-hq/money

Use

const money = require(`@obs-hq/money`)

const value = money.value(10.000001)
console.log(value) // prints 10.01

Methods

  • value: return currency value
  • sum: sum two amounts,
  • subtract: substract two amonts,
  • multiply: multiply an amount by a factor
  • divide: divide an amount by a factor
  • percent: compute a percent from an amount
  • applyDiscount: apply a percent discount to base amount
  • maxTax:compute tax from base amount, follow max policy from percent value and fee value
  • applyTax:apply a percent tax to base amount
  • applyMaxTax: apply tax to base amount, follow max policy from percent value and fee value
  • applySumTax: apply tax to base amount, follow sum policy from percent value and fee value

Quick Examples

const money = require(`@obs-hq/money`)

money.value(0.0000001) // 0.01
money.sum(9.999, 0.001) // 10
money.sum(9.999, 0.01) // 10.01
money.subtract(1.01, 0.99) // 0.02
money.multiply(165, 1.40) // 231
money.divide(123.45, 2) // 61.73
money.percent(100, 50.000001452) // 50.01
money.percent(999.99, 50) // 500
money.maxTax(100, 10, 20.021) // 20.03
money.applyDiscount(100, 10) // 90
money.applyTax(100, 10) // 110
money.applyMaxTax(100, 10, 20) // 120
money.applySumTax(100, 10, 20) // 130

Tests

npm run test