@xpla.kitchen/utils
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

@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"

Readme

Keywords

none

Package Sidebar

Install

npm i @xpla.kitchen/utils

Weekly Downloads

4

Version

0.2.2

License

MIT

Unpacked Size

59.9 kB

Total Files

22

Last publish

Collaborators

  • woosweb
  • zenaad