|
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:
954 bytes
|
| Line | |
|---|
| 1 | import isArrayLike from './_isArrayLike.js';
|
|---|
| 2 | import values from './values.js';
|
|---|
| 3 | import cb from './_cb.js';
|
|---|
| 4 | import each from './each.js';
|
|---|
| 5 |
|
|---|
| 6 | // Return the minimum element (or element-based computation).
|
|---|
| 7 | export default function min(obj, iteratee, context) {
|
|---|
| 8 | var result = Infinity, lastComputed = Infinity,
|
|---|
| 9 | value, computed;
|
|---|
| 10 | if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null)) {
|
|---|
| 11 | obj = isArrayLike(obj) ? obj : values(obj);
|
|---|
| 12 | for (var i = 0, length = obj.length; i < length; i++) {
|
|---|
| 13 | value = obj[i];
|
|---|
| 14 | if (value != null && value < result) {
|
|---|
| 15 | result = value;
|
|---|
| 16 | }
|
|---|
| 17 | }
|
|---|
| 18 | } else {
|
|---|
| 19 | iteratee = cb(iteratee, context);
|
|---|
| 20 | each(obj, function(v, index, list) {
|
|---|
| 21 | computed = iteratee(v, index, list);
|
|---|
| 22 | if (computed < lastComputed || (computed === Infinity && result === Infinity)) {
|
|---|
| 23 | result = v;
|
|---|
| 24 | lastComputed = computed;
|
|---|
| 25 | }
|
|---|
| 26 | });
|
|---|
| 27 | }
|
|---|
| 28 | return result;
|
|---|
| 29 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.