axax
Version:
A library of async iterator extensions for JavaScript including ```map```, ```reduce```, ```filter```, ```flatMap```, ```pipe``` and [more](https://github.com/jamiemccrindle/axax/blob/master/docs/API.md#functions).
17 lines (16 loc) • 438 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Take the first value or the first value to pass predicate from an async iterable
*/
function first(predicate = () => true) {
return async function* inner(source) {
for await (const item of source) {
if (predicate(item)) {
yield item;
break;
}
}
};
}
exports.first = first;