MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / find

Function find

MathBox/mathbox-bundle.js:38341–38364  ·  view source on GitHub ↗

* Iterates over elements of a collection, returning the first element that * the callback returns truey for. The callback is bound to `thisArg` and * invoked with three arguments; (value, index|key, collection). * * If a property name is provided for `callback` the created "_.plu

(collection, callback, thisArg)

Source from the content-addressed store, hash-verified

38339 * // => { 'name': 'fred', 'age': 40, 'blocked': true }
38340 */
38341 function find(collection, callback, thisArg) {
38342 callback = lodash.createCallback(callback, thisArg, 3);
38343
38344 var index = -1,
38345 length = collection ? collection.length : 0;
38346
38347 if (typeof length == 'number') {
38348 while (++index < length) {
38349 var value = collection[index];
38350 if (callback(value, index, collection)) {
38351 return value;
38352 }
38353 }
38354 } else {
38355 var result;
38356 forOwn(collection, function(value, index, collection) {
38357 if (callback(value, index, collection)) {
38358 result = value;
38359 return false;
38360 }
38361 });
38362 return result;
38363 }
38364 }
38365
38366 /**
38367 * This method is like `_.find` except that it iterates over elements

Callers 3

mathbox-core.jsFile · 0.85
mathbox-bundle.jsFile · 0.85
selectFunction · 0.85

Calls 2

forOwnFunction · 0.85
callbackFunction · 0.70

Tested by

no test coverage detected