0.0.3 • Published 8 months ago

@xutil/math v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

Math 数学

x-math数学

📦 安装

  • 使用 npm 安装

    npm install @xutil/math -S
  • HTML直接引入

    <!DOCTYPE html>
       <html lang="en">
       <body>
          <script src="/dist/index-umd.js"></script>
          <script>
             console.log(XMath.average(1,2,3,5,10))
          </script>
       </body>
    </html>

🎨 使用

  • ESM导入使用

    // 全部引入
    import { average } from "@xutil/math"
     console.log(average(1,2,3,5,10))
    
    // 按需引入
    import XMath from "@xutil/math"
     console.log(XMath.average(1,2,3,5,10))
  • RequireJS导入使用

    // 全部引入
    const XMath = require('@xutil/math')
    console.log(XMath.average(1,2,3,5,10))
    
    // 按需引入
    const { average } = require('@xutil/math')
    console.log(average(1,2,3,5,10))

方法

    average                 求平均数
    averageBy               根据条件求平均数
    digitize                转化为整数
    sum                     求和
    toSafeInteger           安全整数
    pascal                  帕斯卡三角
    randomNumberInRange     生成数字范围内的随机数
    distance                两点之间的距离
    isEven                  给定的数字为偶数, 则返回true, 否则为false。
0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago