Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

12345678910111213141516171819202122232425
  1. var baseIteratee = require('./_baseIteratee'),
  2. isArrayLike = require('./isArrayLike'),
  3. keys = require('./keys');
  4. /**
  5. * Creates a `_.find` or `_.findLast` function.
  6. *
  7. * @private
  8. * @param {Function} findIndexFunc The function to find the collection index.
  9. * @returns {Function} Returns the new find function.
  10. */
  11. function createFind(findIndexFunc) {
  12. return function(collection, predicate, fromIndex) {
  13. var iterable = Object(collection);
  14. if (!isArrayLike(collection)) {
  15. var iteratee = baseIteratee(predicate, 3);
  16. collection = keys(collection);
  17. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  18. }
  19. var index = findIndexFunc(collection, predicate, fromIndex);
  20. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  21. };
  22. }
  23. module.exports = createFind;