MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / min

Function min

MathBox/mathbox-bundle.js:38768–38801  ·  view source on GitHub ↗

* Retrieves the minimum value of a collection. If the collection is empty or * falsey `Infinity` is returned. If a callback is provided it will be executed * for each value in the collection to generate the criterion by which the value * is ranked. The callback is bound to `thisArg` a

(collection, callback, thisArg)

Source from the content-addressed store, hash-verified

38766 * // => { 'name': 'barney', 'age': 36 };
38767 */
38768 function min(collection, callback, thisArg) {
38769 var computed = Infinity,
38770 result = computed;
38771
38772 // allows working with functions like `_.map` without using
38773 // their `index` argument as a callback
38774 if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) {
38775 callback = null;
38776 }
38777 if (callback == null && isArray(collection)) {
38778 var index = -1,
38779 length = collection.length;
38780
38781 while (++index < length) {
38782 var value = collection[index];
38783 if (value < result) {
38784 result = value;
38785 }
38786 }
38787 } else {
38788 callback = (callback == null && isString(collection))
38789 ? charAtCallback
38790 : lodash.createCallback(callback, thisArg, 3);
38791
38792 forEach(collection, function(value, index, collection) {
38793 var current = callback(value, index, collection);
38794 if (current < computed) {
38795 computed = current;
38796 result = value;
38797 }
38798 });
38799 }
38800 return result;
38801 }
38802
38803 /**
38804 * Retrieves the value of a specified property from all elements in the collection.

Callers

nothing calls this directly

Calls 4

isStringFunction · 0.85
isArrayFunction · 0.70
forEachFunction · 0.70
callbackFunction · 0.70

Tested by

no test coverage detected