find.js 392 B

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