# @terra-money/terra-utils

> ### Format

Latest version **1.2.0-beta.12** (published 2024-02-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @terra-money/terra-utils
pnpm add @terra-money/terra-utils
yarn add @terra-money/terra-utils
bun add @terra-money/terra-utils
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0-beta.12 |
| Published | 2024-02-13 |
| First published | 2023-03-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 9 |
| Unpacked size | 966.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Terra |
| Maintainers | terra-engineering, simke9445, alecande, mwmerz, terra-devops |

## Links

- npm: https://www.npmjs.com/package/@terra-money/terra-utils
- Repository: https://github.com/terra-money/terra-utils
- Homepage: https://github.com/terra-money/terra-utils#readme
- Issues: https://github.com/terra-money/terra-utils/issues
- npm.io page: https://npm.io/package/@terra-money/terra-utils

## Dependencies (9)

- [ramda](https://npm.io/package/ramda.md) ^0.27.1
- [react](https://npm.io/package/react.md) ^18.2.0
- [numeral](https://npm.io/package/numeral.md) ^2.0.6
- [@types/ramda](https://npm.io/package/@types/ramda.md) ^0.27.57
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^9.0.1
- [tiny-warning](https://npm.io/package/tiny-warning.md) ^1.0.3
- [@types/numeral](https://npm.io/package/@types/numeral.md) ^2.0.2
- [@tanstack/react-query](https://npm.io/package/@tanstack/react-query.md) ^5.17.19
- [@terra-money/feather.js](https://npm.io/package/@terra-money/feather.js.md) ^2.0.0-beta.7

## Recent versions

- 1.2.0-beta.12 (latest) — 2024-02-13
- 2.2.0-beta.14 (beta) — 2024-05-16
- 1.2.0-beta.14 — 2024-03-27
- 1.2.0-beta.13 — 2024-02-15
- 1.2.0-beta.11 — 2024-02-09
- 1.2.0-beta.10 — 2024-02-05
- 1.2.0-beta.9 — 2024-02-05
- 1.2.0-beta.8 — 2024-02-05
- 1.2.0-beta.7 — 2024-01-09
- 1.2.0-beta.6 — 2024-01-03
- 1.2.0-beta.5 — 2024-01-03
- 1.2.0-beta.4 — 2024-01-02
- 1.2.0-beta.3 — 2023-12-30
- 1.2.0-beta.2 — 2023-12-29
- 1.2.0-beta.1 — 2023-12-18
- … 8 more at https://npm.io/package/@terra-money/terra-utils/versions

## README

## Usage

### Format

```ts
import { readAmount, readDenom, readPercent, toAmount } from "@terra-money/terra-utils"

readAmount("1234567890") // "1234.56789"
readAmount("1234567890", { decimals: 0 }) // "1234567890"
readAmount("1234567890", { fixed: 6 }) // "1234.567890"
readAmount("1234567890", { comma: true }) // "1,234.56789"
readAmount("1234567890", { integer: true }) // "1234"
readAmount("1234567890", { prefix: true }) // "1.23K"

toAmount("1234.56789") // "1234567890"
toAmount("1234", { decimals: 0 }) // "1234"

readDenom("uluna") // "Luna"
readDenom("uusd") // "UST"

readPercent("1.23") // "123.00%"
readPercent("1.23", { fixed: 3 }) // "123.000%"
```

### Is

```ts
import { isDenom, isDenomTerra } from "@terra-money/terra-utils"

isDenomTerra("uusd") // true
isDenomTerra("uluna") // false

isDenom("uusd") // true
isDenom("uluna") // true
```

### Text

```ts
import { truncate } from "@terra-money/terra-utils"

truncate("terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v") // "terra1...20k38v"
truncate("terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v", [6, 3]) // "terra1...38v"
```

---
_Source: https://npm.io/package/@terra-money/terra-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
