1.0.24 • Published 23 days ago

ts-cash v1.0.24

Weekly downloads
-
License
MIT
Repository
-
Last release
23 days ago

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.

1.0.24

23 days ago

1.0.19

9 months ago

1.0.18

10 months ago

1.0.17

11 months ago

1.0.22

9 months ago

1.0.21

9 months ago

1.0.20

9 months ago

1.0.23

8 months ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago