lazy-some
v0.1.0
Published
Lazy Array some. Once fun returns non falsy value, that value is returned and search is suspended
Downloads
32
Readme
lazy-some
Lazy Array some. Once fun returns non falsy value, that value is returned and search is suspended
Install
$ npm install lazy-some
Usage
require('lazy-some')(Array);
var lines=[
'Line without mail',
'Line with one mail: [email protected]',
'This line is not searches',
'Another line with mail: [email protected]. Not searched'
];
var firstMail=lines.lazySome(function(line){
var match = line.match(/\w+@(?:\w+\.)+\w+/)
return match && match[0];
});
console.log(firstMail); // [email protected]
arr.lazySome(fun [, thisArg])
Calls fun
with each array element until a non falsy value was obtained.
Then that value was returned by lazySome
.
If only falsy values were obtained then false
was returned.