123456789101112131415161718192021 |
- var some = require('./some');
- var makeIterator = require('../function/makeIterator_');
- /**
- * Returns first item that matches criteria
- */
- function find(obj, callback, thisObj) {
- callback = makeIterator(callback, thisObj);
- var result;
- some(obj, function(value, key, obj) {
- if (callback(value, key, obj)) {
- result = value;
- return true; //break
- }
- });
- return result;
- }
- module.exports = find;
|