Socket
Book a DemoInstallSign in
Socket

@touch4it/currency-format

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@touch4it/currency-format

Currency formatter

1.1.0
latest
Source
npmnpm
Version published
Maintainers
3
Created
Source

Format currency output

GitHub license npm version node version vulnerabilities last commit

Installation

$ npm install --save @touch4it/currency-format

API

constructor(amount, [currency='USD'])

Object constructor

Options:

  • amount (required) - Price amount
  • currency (optional, default: USD) - Price currency

toString([decimals])

Print string with correct number of decimal places

Options:

  • decimals (optional, default: calculated from currency) - Decimal places in output

Return:

Formatted string

add(amount)

Add amount to previous amount

Options:

  • amount (required) - Amount to be added

Return:

Object (this)

subtract(amount)

Subtract amount from previous amount

Options:

  • amount (required) - Amount to be subtracted

Return:

Object (this)

vat(vatPercent)

Calculate VAT amount

Options:

  • vatPercent (required) - Percent of VAT as number (e.g. 40 for 40%)

Return:

VAT amount as string with correct number of decimal places

addVat(vatPercent)

Add VAT amount to previous amount

Options:

  • vatPercent (required) - Percent of VAT as number (e.g. 40 for 40%)

Return:

Object (this)

Example

See tests

License

MIT

Authors

Keywords

currency

FAQs

Package last updated on 23 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.