Catalog npm
Back to packageRELEASE DETAILS

3.2.10

npm

5ex-financial-arithmetic-functions

A set of functions for doing math on numbers without floating point numbers

arithmeticbigintbignumberfinancialmathmoneynumber
Published24 Mar 2023
Direct dependencies10
Transitive dependenciesNot calculated

README

Current package documentation

A set of functions for doing financial arithmetic. This is a library you could use to build a friendlier money-math library, like the financial-number library.

  1. Takes strings only
  2. Does all math with the native BigInt implementation (use 1.x release if you want a version that works in older browsers)
  3. Multiplication results have a precision that is twice the precision of their inputs. 9.55 * 1.50 = 14.3250
  4. Addition and subtraction results have a precision as great as the highest precision of the two inputs. 1.5 + 1.00 = 2.50

Require with const math = require('financial-arithmetic-functions')

validate(str)

Can you pass it in to any of the other functions?

math.validate('123') // => true
math.validate('123.444') // => true
math.validate('123.') // => false
math.validate(123) // => false

add(a, b)

math.add('+123', '9.999') // => '132.999'
math.add('1.1', '1.234') // => '2.334'
math.add('5', '987876765654543432321') // => '987876765654543432326'

subtract(a, b)

math.subtract('123', '100') // => '23'
math.subtract('44', '-11') // => '55'
math.subtract('1.0000', '0.004') // => '0.9960'

multiply(a, b)

math.multiply('123', '0.0001') // => '0.0123'
math.multiply('99.99', '14') // => '1399.86'

getPrecision(str)

math.getPrecision('12.666') // => 3
math.getPrecision('999') // => 0

modulo(dividend, divisor)

math.modulo('10', '2') // => '0'
math.modulo('10.0', '2') // => '0.0'
math.modulo('12.33', '1') // => '0.33'
math.modulo('12.33', '1.00') // => '0.33'

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 10

Native requirements
10 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@types/tape
Environment
{
  "local_name": "@types/tape",
  "alias": false,
  "peer_metadata": null
}
^4.13.2development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^5.16.0development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^5.16.0development
esbuild
Environment
{
  "local_name": "esbuild",
  "alias": false,
  "peer_metadata": null
}
^0.14.39development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^8.11.0development
faucet
Environment
{
  "local_name": "faucet",
  "alias": false,
  "peer_metadata": null
}
0.0.1development
jsmd
Environment
{
  "local_name": "jsmd",
  "alias": false,
  "peer_metadata": null
}
^1.0.2development
npm-run-all
Environment
{
  "local_name": "npm-run-all",
  "alias": false,
  "peer_metadata": null
}
^4.1.5development
tape
Environment
{
  "local_name": "tape",
  "alias": false,
  "peer_metadata": null
}
4.9.1development
tsm
Environment
{
  "local_name": "tsm",
  "alias": false,
  "peer_metadata": null
}
^2.2.1development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-C0O/aasxCwUAko2S4M8tRu2VMlcRc7NeM6Bfje0yVdWwp/qFTVdWaOeHJtEK+o4dUrM71andBv+7MSCXntEiiQ==",
  "shasum": "642fbc8bfcde747baa2eae69bef1b91cd0bd0b70",
  "tarball": "https://registry.npmjs.org/5ex-financial-arithmetic-functions/-/5ex-financial-arithmetic-functions-3.2.10.tgz",
  "fileCount": 11,
  "unpackedSize": 31804,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEQCIFq5OCiDUnrsyZ1xS8a6dIgoxiWQKvk0ZA2aODqDC0OKAiAwaC4ZcNRsiUJHzWheCZ8c0td+X49Ggcu5R/sq569k/g=="
    }
  ],
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkHXSmACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo1Mw//bMXnnOkIyhbYClWb5a5w0DStL47MjrbWvWU2zoVs4XmPPoNh\r\nQHFKswimcUSwC3rCWWDxTTF+F3kfEboRKSQZFCn/0qmJgZRhrheIA2tENQfH\r\nr+ulnqf/CkkxC8PBhRO7CjbezJWF+DIGL6YfGUZnRp8RCqw8J5A2oGfUBRIy\r\ntIcm4p5mxqshgcGTARpWvtnBmRU+DnUAhzo6H9jqvVv7cgChNS+XO/R6mvaj\r\nSGi/9KjzUtQ/Ygjdk4+9BU8HPJha7ThzbZjqA9UDrM5fThGae3pa6MYyQfN4\r\noKhyDhFhIugih964DIMMj5Np7jHqo4vVv5ph3Yy2m8fjxsft7dBYahtEaQBp\r\ngqsA3xFDYYogK17hC0Pu6mvIwYNVdYxgau30cGiwC5cIUZ1SW9fnY1PGTLlj\r\nvKLf1U0iDdD88maSybyfUfocAop9zfuPcJzWSlhmBhSJjjZcfHGpewi0mDdC\r\nmTHC9WKjTn00u7OyamcvV4vUaTW08gbQzmWtXSGlGTEir61fiizkE6dS28Mi\r\n/NZ3WwUx1y/qlIf18dhOwE8R1Ps+qCq/Iufk0wVbasvgTb5zYIYPx3yAOKsh\r\nnyy9O9u1gqLgcF9zTmImaI21gsDDeJxuaVPpi7aSDg8QuPUBzMacbKI1Lq+U\r\nCtTcUgxSrml21Jb99YKLtRdjjQvisCt1QwE=\r\n=8j1e\r\n-----END PGP SIGNATURE-----\r\n"
}

Repository

PENDING
rohit-5ex/financial-arithmetic-functions

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:34 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:8693f6fc77a35da6f96363d7d0f4dd8b3651bbddf6beccddf9997fdb4fd6a535

Other collected versions

3.2.1224 Mar3.2.1124 Mar3.2.924 Mar3.2.824 Mar3.2.724 Mar3.2.624 MarView all collected versions →