Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Return the first matching value in an array
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
Makefile
Readme.md
component.json
index.js
package.json

Readme.md

find

Find the first matching value in an array.

Installation

$ component install component/find

API

find(array, fn)

Find with a function:

var tobi = find(users, function(u){ return u.name == 'Tobi' });

find(array, string)

Find with property strings:

find(users, 'admin');

find(array, object)

Find with object value matching:

var users = [];
users.push({ name: 'Tobi', age: 2, species: 'ferret' });
users.push({ name: 'Jane', age: 6, species: 'ferret' });
users.push({ name: 'Luna', age: 2, species: 'cat' });

find(users, { name: 'Jane', age: 6 });
// => { name: 'Jane', age: 6, species: 'ferret' }

find(users, { name: 'Jane', age: 1 });
// => undefined

License

MIT

Something went wrong with that request. Please try again.