mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Split out every into everyValue.
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* A specialized version of `every` for arrays.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} [array] The array to iterate over.
|
||||
* @param {Function} predicate The function invoked per iteration.
|
||||
* @returns {boolean} Returns `true` if all elements pass the predicate check,
|
||||
* else `false`.
|
||||
*/
|
||||
function arrayEvery(array, predicate) {
|
||||
let index = -1
|
||||
const length = array == null ? 0 : array.length
|
||||
|
||||
while (++index < length) {
|
||||
if (!predicate(array[index], index, array)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
export default arrayEvery
|
||||
@@ -1,21 +0,0 @@
|
||||
import baseEach from './baseEach.js'
|
||||
|
||||
/**
|
||||
* The base implementation of `every`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array|Object} collection The collection to iterate over.
|
||||
* @param {Function} predicate The function invoked per iteration.
|
||||
* @returns {boolean} Returns `true` if all elements pass the predicate check,
|
||||
* else `false`
|
||||
*/
|
||||
function baseEvery(collection, predicate) {
|
||||
let result = true
|
||||
baseEach(collection, (value, index, collection) => {
|
||||
result = !!predicate(value, index, collection)
|
||||
return result
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
export default baseEvery
|
||||
Reference in New Issue
Block a user