# sp-math

> Common Math Functions

Latest version **1.0.5** (published 2019-03-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install sp-math
pnpm add sp-math
yarn add sp-math
bun add sp-math
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2019-03-27 |
| First published | 2018-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | requesttimeout |
| Keywords | math |

## Links

- npm: https://www.npmjs.com/package/sp-math
- Repository: https://github.com/z41z/sp-math
- Homepage: https://github.com/z41z/sp-math#readme
- Issues: https://github.com/z41z/sp-math/issues
- npm.io page: https://npm.io/package/sp-math

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2019-03-27
- 1.0.4 — 2019-03-27
- 1.0.3 — 2019-03-21
- 1.0.2 — 2018-12-13
- 1.0.1 — 2018-12-13
- 1.0.0 — 2018-12-12

## README

# sp-math

Common Math Functions

## Install

``` node
  npm i sp-math //or yarn add sp-math
```

## CDN

``` js
  <script src="https://unpkg.com/sp-math/dist/index.min.js"></script>
  <script>

  </script>
```

### Usage

``` js
  const {
    abs,
    acos,
    asin,
    atan,
    ceil,
    degreeToRotate,
    devideFloat,
    isFloat,
    rotateToDegree,
    cos,
    distance,
    floor,
    comma,
    rotateByDegree,
    pow,
    round,
    sin,
    sqrt,
    tan
  } = require("sp-math")
```

* abs(val)
  * {Number} val

  ``` js
    abs(-10);
    // return 10
  ```

* ceil(val)
  * {Number} val

  ``` js
    ceil(1.25);
    // return 2
  ```

* cos(val)
  * {Number} val

  ``` js
    cos(60);
    // return 0.5000000000000001
  ```

* sin(val)
  * {Number} val

  ``` js
    sin(30);
    // return 0.49999999999999994
  ```

* tan(val)
  * {Number} val

  ``` js
    sin(45);
    // return 0.9999999999999999
  ```

* acos(val)
  * {Number} val

  ``` js
    acos(0.5);
    // return 60.00000000000001
  ```

* asin(val)
  * {Number} val

  ``` js
    asin(0.5);
    // return 30.000000000000004
  ```

* atan(val)
  * {Number} val

  ``` js
    atan(1);
    // return 45
  ```

* degreeToRotate(val)
  * {Number} val

  ``` js
    degreeToRotate(180);
    // return 3.141592653589793 Math.PI
  ```

* rotateToDegree(val)
  * {Number} val

  ``` js
    rotateToDegree(Math.PI);
    // return 180
  ```

* distance(p1, p2)
  * {Array} p1 = [0, 0]
  * {Array} p2 = [0, 0]

  ``` js
    distance([1, 1], [2, 2]);
    // return 1.41
  ```

* floor(val)
  * {Number} val

  ``` js
    floor(1.25);
    // return 1
  ```

* pow(x, y, isDeep = false)
  * {Number} x
  * {Number} y
  * {Boolean} isDeep

  ``` js
    pow(2, 5);
    // return 32
    pow(-2, 5);
    // return -32
    pow(4, 0.5, true);
    // return [2, -2]
  ```

* round(val)
  * {Number} val

  ``` js
    round(2.53)
    // return 3
    round(2.15);
    // return 2
  ```

* sqrt(val)
  * {Number} val
  * {Boolean} isDeep

  ``` js
    sqrt(4)
    // return 2
    sqrt(4, true);
    // return [2, -2]
  ```

* devideFloat(val)
  * {Number} val

  ``` js
    devideFloat(4)
    // return [ 4, 1 ] 4/1 = 4
    devideFloat(1.8);
    // return [ 9, 5 ] 9/5 = 1.8
  ```

* comma(val, obj = {fixed:2, hasComma = false})
  * {Number} val
  * {Object} obj
  * {Number} obj.fixed
  * {Boolean} obj.hasComma

  ``` js
    comma('12345.33',{
      fixed: 3
    });
    // return '12345.330'
    comma('12345.33',{
      fixed: 3,
      hasComma: true
    });
    // return '12,345.330'
    comma('12,345.330',{
      fixed: 4,
      hasComma: false
    });
    // return '12345.3300'
  ```

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