MCPcopy
hub / github.com/jashkenas/underscore / min

Function min

underscore-node-f.cjs:1520–1542  ·  view source on GitHub ↗
(obj, iteratee, context)

Source from the content-addressed store, hash-verified

1518
1519// Return the minimum element (or element-based computation).
1520function min(obj, iteratee, context) {
1521 var result = Infinity, lastComputed = Infinity,
1522 value, computed;
1523 if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null)) {
1524 obj = isArrayLike(obj) ? obj : values(obj);
1525 for (var i = 0, length = obj.length; i < length; i++) {
1526 value = obj[i];
1527 if (value != null && value < result) {
1528 result = value;
1529 }
1530 }
1531 } else {
1532 iteratee = cb(iteratee, context);
1533 each(obj, function(v, index, list) {
1534 computed = iteratee(v, index, list);
1535 if (computed < lastComputed || (computed === Infinity && result === Infinity)) {
1536 result = v;
1537 lastComputed = computed;
1538 }
1539 });
1540 }
1541 return result;
1542}
1543
1544// Safely create a real, live array from anything iterable.
1545var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;

Callers

nothing calls this directly

Calls 4

valuesFunction · 0.70
cbFunction · 0.70
eachFunction · 0.70
iterateeFunction · 0.70

Tested by

no test coverage detected