Skip to content

Latest commit

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

array-find

Build Status

ES 2015 Array.find ponyfill.

Ponyfill: A polyfill that doesn't overwrite the native method.

Find array elements. Executes a callback for each element, returns the first element for which its callback returns a truthy value.

Usage

varfind=require('array-find');varnumbers=[1,2,3,4];find(numbers,function(element,index,array){returnelement===2;});// => 2varrobots=[{name: 'Flexo'},{name: 'Bender'},{name: 'Buster'}];find(robots,function(robot,index,array){returnrobot.name==='Bender';});// => {name: 'Bender'}find(robots,function(robot,index,array){returnrobot.name==='Fry';});// => undefined

Optionally pass in an object as third argument to use as this when executing callback.

Install

$ npm install array-find

License

MIT

About

Find array elements. Executes a callback for each element, returns the first element for which its callback returns a truthy value.

Resources

Stars

1 star

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages