Sha256: bc9c185dbf6563baadaf71ad6d68fed628219781543e3156f841ac5fb394e353
Contents?: true
Size: 843 Bytes
Versions: 153
Compression:
Stored size: 843 Bytes
Contents
var baseCallback = require('./baseCallback'), baseFind = require('./baseFind'), baseFindIndex = require('./baseFindIndex'), isArray = require('../lang/isArray'); /** * Creates a `_.find` or `_.findLast` function. * * @private * @param {Function} eachFunc The function to iterate over a collection. * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {Function} Returns the new find function. */ function createFind(eachFunc, fromRight) { return function(collection, predicate, thisArg) { predicate = baseCallback(predicate, thisArg, 3); if (isArray(collection)) { var index = baseFindIndex(collection, predicate, fromRight); return index > -1 ? collection[index] : undefined; } return baseFind(collection, predicate, eachFunc); }; } module.exports = createFind;
Version data entries
153 entries across 80 versions & 8 rubygems