smath 1.1.5 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ![NPM Downloads](https://img.shields.io/npm/dt/smath)
6
6
  ![NPM Version](https://img.shields.io/npm/v/smath)
7
- ![Relative date](https://img.shields.io/date/1710870424)
7
+ ![Relative date](https://img.shields.io/date/1710877538)
8
8
  ![GitHub watchers](https://img.shields.io/github/watchers/nicfv/npm)
9
9
  ![GitHub forks](https://img.shields.io/github/forks/nicfv/npm)
10
10
  ![GitHub Repo stars](https://img.shields.io/github/stars/nicfv/npm)
@@ -14,7 +14,7 @@
14
14
  smath can be installed from the official [npm package repository](https://www.npmjs.com/package/smath). It is highly recommended to install the latest version, which is installed by default with the following command.
15
15
 
16
16
  ```shell
17
- npm i smath@1.1.5
17
+ npm i smath@1.1.6
18
18
  ```
19
19
 
20
20
  ## Bugs and Requests
package/dist/index.js CHANGED
@@ -4,6 +4,13 @@ exports.SMath = void 0;
4
4
  var SMath = (function () {
5
5
  function SMath() {
6
6
  }
7
+ SMath.avg = function () {
8
+ var n = [];
9
+ for (var _i = 0; _i < arguments.length; _i++) {
10
+ n[_i] = arguments[_i];
11
+ }
12
+ return n.reduce(function (prev, curr) { return prev + curr; }) / n.length;
13
+ };
7
14
  SMath.clamp = function (n, min, max) {
8
15
  if (n < min) {
9
16
  return min;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smath",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Small math function library",
5
5
  "homepage": "https://npm.nicfv.com/smath",
6
6
  "main": "dist/index.js",
@@ -24,6 +24,9 @@
24
24
  "library",
25
25
  "simple",
26
26
  "number",
27
+ "avg",
28
+ "average",
29
+ "mean",
27
30
  "interpolate",
28
31
  "interpolation",
29
32
  "extrapolate",
package/types/index.d.ts CHANGED
@@ -9,6 +9,16 @@
9
9
  * useful interpolation and extrapolation functions.
10
10
  */
11
11
  export declare abstract class SMath {
12
+ /**
13
+ * Compute the average, or mean, of a set of numbers.
14
+ * @param n Any amount of numeric inputs
15
+ * @returns The average, or mean
16
+ * @example
17
+ * ```js
18
+ * const mean = SMath.avg(1, 2, 3, 4); // 2.5
19
+ * ```
20
+ */
21
+ static avg(...n: Array<number>): number;
12
22
  /**
13
23
  * Clamp a number within a range.
14
24
  * @param n The number to clamp