- Notifications
You must be signed in to change notification settings - Fork0
JavaScript number commonly used number conversion
License
NotificationsYou must be signed in to change notification settings
atwill007/number-magic
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A useful number utils library
English |简体中文
npm install number-magic
or
pnpm install number-magic
or
yarn add number-magic
import{comma,toFixed,percentage,idxList,randomInt,capital,precise,isNumber,}from'number-magic'comma(1234567.123)// 1,234,567.123toFixed(1234567.123)// 1234567.12toFixed(123.123,4)// 123.1230toFixed(12345.12345,4)// 12345.1235percentage(0.6666,3)// 66.660%percentage(0.555555,3)// 55.556%idxList(6,1)// [ 1, 2, 3, 4, 5, 6 ]randomInt(1.1,2.1)// 2capital(123123.12)// 拾贰万叁千壹百贰拾叁元壹角贰分constnumb=0.1+0.2// 0.30000000000000004precise(numb)// 0.3isNumber('hi')// falseisNumber(NaN)// falseisNumber(Math.PI)// trueisNumber(2**53)// trueisNumber(2**53,true)// false// ...// See unit tests for more
About
JavaScript number commonly used number conversion