1.0.2 • Published 2 years ago

thousandth-division v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

thousandth-division

千分位分割,保留n位小数(默认保留两位小数),科学计数法转成小数

安装依赖

# install dependencies
npm install thousandth-division --save
# or with yarn
yarn add thousandth-division

方法使用说明

numberFormat(value, digit)

千分位分割,保留n位小数。

import { numberFormat } from 'thousandth-division';

numberFormat(10000.123123,2); // 10,000.12
numberFormat(-10000.123123,2); // -10,000.12
numberFormat(0.000000111,7); // 0.0000001
numberFormat(-0.000000111,7); // -0.0000001

toNumber(value)

将千分位分割的数据还原成数值

import { numberFormat, toNumber } from 'thousandth-division';
let format = numberFormat(10000.123123,2); // 10,000.12
toNumber(format); // 10000.12