0.1.0 • Published 7 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-some
Usage
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.dom
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.
License
0.1.0
7 years ago