@hestia-earth/utils 0.13.23 → 0.13.25
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/dist/number.d.ts +4 -0
- package/dist/number.js +15 -1
- package/package.json +1 -1
package/dist/number.d.ts
CHANGED
|
@@ -74,3 +74,7 @@ export declare const converters: {
|
|
|
74
74
|
* @returns The converted value.
|
|
75
75
|
*/
|
|
76
76
|
export declare const convertValue: (n: number, fromUnit: ConvertUnits, toUnit: ConvertUnits, args?: IConvertArgs) => number;
|
|
77
|
+
export declare const sum: (values?: number[]) => number;
|
|
78
|
+
export declare const mean: (values?: number[]) => number;
|
|
79
|
+
export declare const min: (values: number[]) => any;
|
|
80
|
+
export declare const max: (values: number[]) => any;
|
package/dist/number.js
CHANGED
|
@@ -17,7 +17,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
17
17
|
};
|
|
18
18
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.convertValue = exports.converters = exports.ConvertUnits = exports.toComma = exports.toPrecision = exports.isNumber = void 0;
|
|
20
|
+
exports.max = exports.min = exports.mean = exports.sum = exports.convertValue = exports.converters = exports.ConvertUnits = exports.toComma = exports.toPrecision = exports.isNumber = void 0;
|
|
21
21
|
/**
|
|
22
22
|
* Check if the value is a number.
|
|
23
23
|
*
|
|
@@ -191,3 +191,17 @@ var convertValue = function (n, fromUnit, toUnit, args) {
|
|
|
191
191
|
return exports.converters[fromUnit][toUnit](n, args);
|
|
192
192
|
};
|
|
193
193
|
exports.convertValue = convertValue;
|
|
194
|
+
var sum = function (values) {
|
|
195
|
+
if (values === void 0) { values = []; }
|
|
196
|
+
return values.reduce(function (p, c) { return p + c; }, 0);
|
|
197
|
+
};
|
|
198
|
+
exports.sum = sum;
|
|
199
|
+
var mean = function (values) {
|
|
200
|
+
if (values === void 0) { values = []; }
|
|
201
|
+
return ((values === null || values === void 0 ? void 0 : values.length) ? exports.sum(values) / values.length : 0);
|
|
202
|
+
};
|
|
203
|
+
exports.mean = mean;
|
|
204
|
+
var min = function (values) { return Math.min.apply(Math.min, values); };
|
|
205
|
+
exports.min = min;
|
|
206
|
+
var max = function (values) { return Math.max.apply(Math.max, values); };
|
|
207
|
+
exports.max = max;
|