UNPKG

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).

19 lines (18 loc) 476 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Filters items from an iterable * * @param source the source iterable to filter * @param predicate the predicate to apply to filter items */ function filter(predicate) { return async function* inner(source) { for await (const item of source) { if (await predicate(item)) { yield await item; } } }; } exports.filter = filter;