0.1.0 • Published 9 years ago
lazy-some v0.1.0
lazy-some
Lazy Array some. Once fun returns non falsy value, that value is returned and search is suspended
Install
$ npm install lazy-someUsage
require('lazy-some')(Array);
var lines=[
'Line without mail',
'Line with one mail: name@host.dom',
'This line is not searches',
'Another line with mail: other@mail.dom. Not searched'
];
var firstMail=lines.lazySome(function(line){
var match = line.match(/\w+@(?:\w+\.)+\w+/)
return match && match[0];
});
console.log(firstMail); // name@host.domarr.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.
License
0.1.0
9 years ago
also available in:
