Function: filterConcur()
Returns a concur iterable that contains the values of concurIterable
excluding the values for which fn
returns a value awaitable to a falsy
value.
Like Array.prototype.filter
, but for concur iterables.
Example
import { asConcur, filterConcur, pipe, reduceConcur, toArray } from 'lfi'
const API_URL = `https://api.dictionaryapi.dev/api/v2/entries/en`
console.log(
await pipe(
asConcur([`sloth`, `lazy`, `sleep`]),
filterConcur(async word => {
const response = await fetch(`${API_URL}/${word}`)
const [{ meanings }] = await response.json()
return meanings.some(meaning => meaning.partOfSpeech === `adjective`)
}),
reduceConcur(toArray()),
),
)
//=> [ 'lazy' ]
Since
v0.0.1
Call Signature
filterConcur<
From
,To
>(fn
): (concurIterable
) =>ConcurIterable
<To
>
Type Parameters
• From
• To
Parameters
fn
(value
) => value is To
Returns
Function
Parameters
concurIterable
ConcurIterable
<From
>
Returns
ConcurIterable
<To
>
Defined in
Call Signature
filterConcur<
From
,To
>(fn
,concurIterable
):ConcurIterable
<To
>
Type Parameters
• From
• To
Parameters
fn
(value
) => value is To
concurIterable
ConcurIterable
<From
>
Returns
ConcurIterable
<To
>
Defined in
Call Signature
filterConcur<
Value
>(fn
): (concurIterable
) =>ConcurIterable
<Value
>
Type Parameters
• Value
Parameters
fn
(value
) => unknown
Returns
Function
Parameters
concurIterable
ConcurIterable
<Value
>
Returns
ConcurIterable
<Value
>
Defined in
Call Signature
filterConcur<
Value
>(fn
,concurIterable
):ConcurIterable
<Value
>
Type Parameters
• Value
Parameters
fn
(value
) => unknown
concurIterable
ConcurIterable
<Value
>
Returns
ConcurIterable
<Value
>