* Checks if the given callback returns truey value for **all** elements of * a collection. 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 "_.pluck" style * c
(collection, callback, thisArg)
| 38211 | * // => false |
| 38212 | */ |
| 38213 | function every(collection, callback, thisArg) { |
| 38214 | var result = true; |
| 38215 | callback = lodash.createCallback(callback, thisArg, 3); |
| 38216 | |
| 38217 | var index = -1, |
| 38218 | length = collection ? collection.length : 0; |
| 38219 | |
| 38220 | if (typeof length == 'number') { |
| 38221 | while (++index < length) { |
| 38222 | if (!(result = !!callback(collection[index], index, collection))) { |
| 38223 | break; |
| 38224 | } |
| 38225 | } |
| 38226 | } else { |
| 38227 | forOwn(collection, function(value, index, collection) { |
| 38228 | return (result = !!callback(value, index, collection)); |
| 38229 | }); |
| 38230 | } |
| 38231 | return result; |
| 38232 | } |
| 38233 | |
| 38234 | /** |
| 38235 | * Iterates over elements of a collection, returning an array of all elements |