find.js 391 B

123456789101112
  1. define(['./_isArrayLike', './findIndex', './findKey'], function (_isArrayLike, findIndex, findKey) {
  2. // Return the first value which passes a truth test.
  3. function find(obj, predicate, context) {
  4. var keyFinder = _isArrayLike(obj) ? findIndex : findKey;
  5. var key = keyFinder(obj, predicate, context);
  6. if (key !== void 0 && key !== -1) return obj[key];
  7. }
  8. return find;
  9. });