MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / filter

Function filter

MathBox/mathbox-bundle.js:38274–38296  ·  view source on GitHub ↗

* Iterates over elements of a collection, returning an array of all elements * 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 "_.p

(collection, callback, thisArg)

Source from the content-addressed store, hash-verified

38272 * // => [{ 'name': 'barney', 'age': 36, 'blocked': false }]
38273 */
38274 function filter(collection, callback, thisArg) {
38275 var result = [];
38276 callback = lodash.createCallback(callback, thisArg, 3);
38277
38278 var index = -1,
38279 length = collection ? collection.length : 0;
38280
38281 if (typeof length == 'number') {
38282 while (++index < length) {
38283 var value = collection[index];
38284 if (callback(value, index, collection)) {
38285 result.push(value);
38286 }
38287 }
38288 } else {
38289 forOwn(collection, function(value, index, collection) {
38290 if (callback(value, index, collection)) {
38291 result.push(value);
38292 }
38293 });
38294 }
38295 return result;
38296 }
38297
38298 /**
38299 * Iterates over elements of a collection, returning the first element that

Callers 4

mathbox-core.jsFile · 0.85
rejectFunction · 0.85
mathbox-bundle.jsFile · 0.85
condenseFunction · 0.85

Calls 2

forOwnFunction · 0.85
callbackFunction · 0.70

Tested by

no test coverage detected