@xpla.kitchen/utils
v0.2.2
Published
## installation
Downloads
77
Readme
@xpla.kitchen/utils
installation
npm i --save @xpla.kitchen/utils
Usage
Format
import { readAmount, readDenom, readPercent, toAmount } from "@xpla.kitchen/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("axpla") // "XPLA"
readPercent("1.23") // "123.00%"
readPercent("1.23", { fixed: 3 }) // "123.000%"
Is
import { isDenomXpla, isDenomIBC, isDenom } from "@xpla.kitchen/utils"
isDenomXpla('axpla') // true
isDenomIBC('ibc/...') // true
isDenom("axpla") // true
isDenom("ibc/...") // true
Text
import { truncate } from "@xpla.kitchen/utils"
truncate("xpla1sxl7purz2upza8agspzc9262ukdt2ph8uq3q34") // "xpla1...uq3q34"
truncate("xpla1sxl7purz2upza8agspzc9262ukdt2ph8uq3q34", [5, 3]) // "xpla1...q34"