# @xutil/math

> `x-math`数学

Latest version **0.0.3** (published 2023-09-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @xutil/math
pnpm add @xutil/math
yarn add @xutil/math
bun add @xutil/math
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-09-21 |
| First published | 2023-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | veserise |

## Links

- npm: https://www.npmjs.com/package/@xutil/math
- npm.io page: https://npm.io/package/@xutil/math

## Recent versions

- 0.0.3 (latest) — 2023-09-21
- 0.0.2 — 2023-09-20
- 0.0.1 — 2023-09-19

## README

# Math 数学

`x-math`数学

## 📦 安装

* 使用 npm 安装

   ```js
   npm install @xutil/math -S
   ```

* HTML直接引入

   ```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导入使用

   ```js
   // 全部引入
   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导入使用

   ```js
   // 全部引入
   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))
   ```

## 方法

```js

    average                 求平均数
    averageBy               根据条件求平均数
    digitize                转化为整数
    sum                     求和
    toSafeInteger           安全整数
    pascal                  帕斯卡三角
    randomNumberInRange     生成数字范围内的随机数
    distance                两点之间的距离
    isEven                  给定的数字为偶数, 则返回true, 否则为false。
```

---
_Source: https://npm.io/package/@xutil/math · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
