* 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)
| 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 |
no test coverage detected