New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

money-math

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

money-math - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

6

money.js

@@ -102,2 +102,8 @@ (function (exports) {

exports.subtract = function (a, b) {
return exports.centsToAmount(
bignum(exports.amountToCents(a)).sub(exports.amountToCents(b)).toString()
);
};
exports.mul = function (a, b) {

@@ -104,0 +110,0 @@ return exports.centsToAmount(

3

package.json
{
"name": "money-math",
"version": "0.1.0",
"version": "0.2.0",
"description": "bignum-based arbitrary precision operations on currency amounts \"XXX.YY\"; because floats are BAD for representing money",

@@ -25,2 +25,3 @@ "main": "money.js",

"bigint",
"bignum",
"arithmetic",

@@ -27,0 +28,0 @@ "arbitrary",

@@ -0,5 +1,7 @@

[![Build Status](https://secure.travis-ci.org/ikr/money-math.png)](http://travis-ci.org/ikr/money-math)
# What does it do?
Adds, multiplies the currency _amounts,_ and calculates percentages of _amounts._ The result of
each of those operations is also an _amount_: a string, strictly matching the `/^\-?\d+\.\d\d$/`
each of those operations is also an _amount:_ a string, strictly matching the `/^\-?\d+\.\d\d$/`
pattern, like "0.25", "1000.00", or "-42.10".

@@ -6,0 +8,0 @@

@@ -133,2 +133,14 @@ (function () {

describe("money.subtract()", function () {
it("calculates difference 1", function () {
expect(
money.subtract("700000000000000000000.00", "700000000000000000000.00")
).toBe("0.00");
});
it("calculates difference 2", function () {
expect(money.subtract("-10.00", "5.00")).toBe("-15.00");
});
});
describe("money.mul()", function () {

@@ -135,0 +147,0 @@ it("multiplies two decimals 1", function () {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc