Socket
Socket
Sign inDemoInstall

ts-cash

Package Overview
Dependencies
0
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ts-cash

- Format numbers into currency format ๐Ÿ‘Š - Auto rounding โšช - Flexible settings ๐Ÿ’ช - Unformatting ๐ŸŒป - Convenient methods for calculation ๐Ÿฆพ - Contains 51 currencies, including 41 fiat currencies and 10 cryptocurrencies ๐Ÿ˜ˆ


Version published
Weekly downloads
129
increased by168.75%
Maintainers
1
Install size
16.2 kB
Created
Weekly downloads
ย 

Readme

Source

ts-cash

  • Format numbers into currency format ๐Ÿ‘Š
  • Auto rounding โšช
  • Flexible settings ๐Ÿ’ช
  • Unformatting ๐ŸŒป
  • Convenient methods for calculation ๐Ÿฆพ
  • Contains 51 currencies, including 41 fiat currencies and 10 cryptocurrencies ๐Ÿ˜ˆ

Installation

pnpm add ts-cash

Usage example

import { tsCash } from "ts-cash"

const amount1 = tsCash.format(10.01, "EUR");

console.log(amount1.val());
// โœ… result: โ‚ฌ 10.01

const amount2 = tsCash.format(10.01, "EUR", {
  mathSymbol: {
    show: true,
  },
  currencySymbol: {
    show: true,
    place: "after",
    space: true,
  },
  decimals: {
    separator: ",",
    max: 4,
    fixed: true,
  },
});

amount2.add(20.02);
amount2.sub(10);
amount2.custom((value) => value / 2);

console.log(amount2.val());
// โœ… result: +10,0150 โ‚ฌ

console.log(tsCash.unformat("$ 100 000 00. 6"));
// โœ… result: 10000000.6

const amount3 = tsCash.format(0.123456789123456789, "ETH", {
  decimals: {
    max: 6,
  },
});

console.log(amount3.val());
// โœ… result: ฮž 0.123457

Author

Vladislav Yemelyanov

Released under the MIT License.

FAQs

Last updated on 15 Apr 2024

Did you know?

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc