Takes a filterFunc and a iterable, and returns a new async iterator of the same type containing the members of the given iterable which cause the filterFunc to return true.
import { filter } from 'streaming-iterables'
import { getPokemon } from './util'
const filterWater = filter(pokemon => pokemon.elements.include('water'))
for await (const pokemon of filterWater(getPokemon())) {
console.log(pokemon)
}
// squirtle
// vaporeon
// magikarp
Takes a
filterFunc
and aiterable
, and returns a new async iterator of the same type containing the members of the given iterable which cause thefilterFunc
to return true.