UNPKG

778 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var is_array_1 = (0, tslib_1.__importDefault)(require("./is-array"));
5/**
6 * @param {Array} arr The array to iterate over.
7 * @return {*} Returns the minimum value.
8 * @example
9 *
10 * min([1, 2]);
11 * // => 1
12 *
13 * min([]);
14 * // => undefined
15 *
16 * const data = new Array(1250010).fill(1).map((d,idx) => idx);
17 *
18 * min(data);
19 * // => 1250010
20 * // Math.min(...data) will encounter "Maximum call stack size exceeded" error
21 */
22exports.default = (function (arr) {
23 if (!(0, is_array_1.default)(arr)) {
24 return undefined;
25 }
26 return arr.reduce(function (prev, curr) {
27 return Math.min(prev, curr);
28 }, arr[0]);
29});
30//# sourceMappingURL=min.js.map
\No newline at end of file