- JS浮点数计算全家桶
- 数组对象去重
- 深拷贝
- 防抖截流
- ...
npm i sauron-library
npm i sauron-library@latest
let calc = require('sauron-library')
// console.log(calc)
// handlingDecimals, // 获取小数点长度
// addition, // 加
// subtraction, // 减
// multiply, // 乘
// division, // 除
cd ~/Documents
mkdir demo && cd demo
3.文件夹 demo 下创建 main.js, bundle.js 和 n.html 三个文件
touch main.js && touch bundle.js && touch n.html
npm i sauron-library
npm i browserify
zsh: command not found: browserify
npm i browserify -g
const Smath = require('sauron-library')
window.Smath = Smath
<html>
<head>
<script src="bundle.js"></script>
</head>
<body>
npm html test
</body>
</html>
<script>
const Smath = window.Smath
const resAddition = Smath.addition(0.1, 0.2) // 0.3
const resSubtraction = Smath.subtraction(0.4, 0.1) // 0.3
const resMultiply = Smath.multiply(35.41, 100) // 3541
const resDivision = Smath.division(1.02, 5) // 0.204
// console.log(0.1 + 0.2) // 0.30000000000000004
// console.log(0.4 - 0.1) // 0.30000000000000004
// console.log(35.41 * 100) // 3540.9999999999995
// console.log(1.02 / 5) // 0.20400000000000001
</script>
1.打包main.js并输出到bundle.js,终端执行命令:
browserify main.js -o bundle.js