1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| define(['./_isArrayLike', './values', './_cb', './each'], function (_isArrayLike, values, _cb, each) {
|
| // Return the minimum element (or element-based computation).
| function min(obj, iteratee, context) {
| var result = Infinity, lastComputed = Infinity,
| value, computed;
| if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null)) {
| obj = _isArrayLike(obj) ? obj : values(obj);
| for (var i = 0, length = obj.length; i < length; i++) {
| value = obj[i];
| if (value != null && value < result) {
| result = value;
| }
| }
| } else {
| iteratee = _cb(iteratee, context);
| each(obj, function(v, index, list) {
| computed = iteratee(v, index, list);
| if (computed < lastComputed || (computed === Infinity && result === Infinity)) {
| result = v;
| lastComputed = computed;
| }
| });
| }
| return result;
| }
|
| return min;
|
| });
|
|