collection/some.jsjavascript
import { entries, toIteratee } from '../_internal/iteratee'
/**
* 判断集合中是否存在至少一个满足条件的元素。
* @function some
* @memberof module:collection
* @param {Array|Object} collection 要遍历的集合
* @param {Function|string|number|Array|Object} [predicate] 判断函数或简写
* @returns {boolean} 存在匹配元素时为 true
* @throws {TypeError} 集合或 predicate 类型不正确时抛出
*/
function some(collection, predicate) {
const fn = toIteratee(predicate)
return entries(collection).some(([key, value]) => fn(value, key, collection))
}
export default some