1.0.13 • Published 1 year ago

lhw-tools v1.0.13

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

安装方法

  npm install lhw-tools

使用方法

  // 在node中使用
  const lhwTools = require('lhw-tools')

  console.log(lhwTools.toThousand(1000000))
  // 1,000,000

  console.log(lhwTools.repairZero(1000,3))
  // 1000.000

  // 保留指定位数的小数-默认保留四位小数
  console.log(lhwTools.keepDecimal(1000))
  // 1000.0000
  
  // 超过指定位数,四舍五入
  console.log(lhwTools.keepDecimal(1000.1234567, 2))
  // 1000.12

  // 不足指定位数-补零
  console.log(lhwTools.keepDecimal(1000.12, 5))
  // 1000.12000

  console.log(lhwTools.compareNum(1.1, '1.2'))
  // '<'

  console.log(lhwTools.compareNum(1.1, '1.1'))
  // '='

  console.log(lhwTools.compareNum(-1.1, '-1.2'))
  // '>'


  // 在es6语法中使用
  import { toThousand, repairZero, keepDecimal, compareNum } from 'lhw-tools'
    console.log(toThousand(1000000))
  // 1,000,000

  console.log(repairZero(1000,3))
  // 1000.000

  // 保留指定位数的小数-默认保留四位小数
  console.log(keepDecimal(1000))
  // 1000.0000
  
  // 超过指定位数,四舍五入
  console.log(keepDecimal(1000.1234567, 2))
  // 1000.12

  // 不足指定位数-补零
  console.log(keepDecimal(1000.12, 5))
  // 1000.12000

  console.log(compareNum(1.1, '1.2'))
  // '<'

  console.log(compareNum(1.1, '1.1'))
  // '='

  console.log(compareNum(-1.1, '-1.2'))
  // '>'
1.0.13

1 year ago

1.0.12

1 year ago

1.0.2

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.0

2 years ago