1.0.1 • Published 2 years ago

@initia/format v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago
import { formatAmount, formatDenom, formatPercent, toAmount, truncate } from "@initia/format"

formatAmount("1234567890") // "1,234.56789"
formatAmount("1234567890", { decimals: 0 }) // "1,234,567,890"
formatAmount("1234567890", { fixed: 6 }) // "1,234.567890"
formatAmount("1234567890", { comma: false }) // "1234.56789"
formatAmount("1234567890", { integer: true }) // "1,234"
formatAmount("1234567890", { suffix: true }) // "1.23K"

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

formatDenom("uini") // "INI"

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

truncate("ini1wlvk4e083pd3nddlfe5quy56e68atra33gzv8h") // "ini1wl...3gzv8h"
truncate("ini1wlvk4e083pd3nddlfe5quy56e68atra33gzv8h", [3, 3]) // "ini...v8h"