|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
976 bytes
|
| Line | |
|---|
| 1 | define(['./_isArrayLike', './values', './_cb', './each'], function (_isArrayLike, values, _cb, each) {
|
|---|
| 2 |
|
|---|
| 3 | // Return the minimum element (or element-based computation).
|
|---|
| 4 | function min(obj, iteratee, context) {
|
|---|
| 5 | var result = Infinity, lastComputed = Infinity,
|
|---|
| 6 | value, computed;
|
|---|
| 7 | if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null)) {
|
|---|
| 8 | obj = _isArrayLike(obj) ? obj : values(obj);
|
|---|
| 9 | for (var i = 0, length = obj.length; i < length; i++) {
|
|---|
| 10 | value = obj[i];
|
|---|
| 11 | if (value != null && value < result) {
|
|---|
| 12 | result = value;
|
|---|
| 13 | }
|
|---|
| 14 | }
|
|---|
| 15 | } else {
|
|---|
| 16 | iteratee = _cb(iteratee, context);
|
|---|
| 17 | each(obj, function(v, index, list) {
|
|---|
| 18 | computed = iteratee(v, index, list);
|
|---|
| 19 | if (computed < lastComputed || (computed === Infinity && result === Infinity)) {
|
|---|
| 20 | result = v;
|
|---|
| 21 | lastComputed = computed;
|
|---|
| 22 | }
|
|---|
| 23 | });
|
|---|
| 24 | }
|
|---|
| 25 | return result;
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | return min;
|
|---|
| 29 |
|
|---|
| 30 | });
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.