🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@jokerwang/format-util

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jokerwang/format-util

格式化工具类

1.0.4
latest
Source
npm
Version published
Maintainers
1
Created
Source

示例

  • 格式化保留指定小数位数。
  • 可用来格式化金额,手机号,银行卡等
formatDecimal(1.555, 2, 'round') // 1.56
formatDecimal(1.554, 2, 'round') // 1.55

formatDecimal(1.554, 2, 'ceil') // 1.56
formatDecimal(1.551, 2, 'ceil') // 1.56

formatDecimal(1.556, 2, 'floor') // 1.55
formatDecimal(1.553, 2, 'floor') // 1.55


formatNumber(18300000000, {type: ' ', splitLength: 4}) // 183 0000 0000
formatNumber(100000000.1, {type: ',', splitLength: 3}) // 100,000,000.1
formatNumber('6222600260001072444', {type: ' ', splitLength: 4, leftToRight: true}) // 6222 6002 6000 1072 444

Keywords

format

FAQs

Package last updated on 13 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts