Function: includesConcur()
Returns a promise that resolves to true
if any value of concurIterable
is
equal to searchElement
using Object.is
. Otherwise returns a promise that
resolves to false
.
Like Array.prototype.includes
, but for concur iterables.
Example
import { asConcur, flatMapConcur, includesConcur, pipe } from 'lfi'
const API_URL = `https://api.dictionaryapi.dev/api/v2/entries/en`
const getPartsOfSpeech = async word => {
const response = await fetch(`${API_URL}/${word}`)
const [{ meanings }] = await response.json()
return meanings.map(meaning => meaning.partOfSpeech)
}
console.log(
await pipe(
asConcur([`sloth`, `lazy`, `sleep`]),
flatMapConcur(getPartsOfSpeech),
includesConcur(`noun`),
),
)
//=> true
console.log(
await pipe(
asConcur([`sloth`, `lazy`, `sleep`]),
flatMapConcur(getPartsOfSpeech),
includesConcur(`adverb`),
),
)
//=> false
Since
v0.0.2
Call Signature
includesConcur(
searchElement
): <Value
>(concurIterable
) =>Promise
<boolean
>
Parameters
searchElement
unknown
Returns
Function
Type Parameters
• Value
Parameters
concurIterable
ConcurIterable
<Value
>
Returns
Promise
<boolean
>
Defined in
Call Signature
includesConcur<
Value
>(searchElement
,concurIterable
):Promise
<boolean
>
Type Parameters
• Value
Parameters
searchElement
unknown
concurIterable
ConcurIterable
<Value
>
Returns
Promise
<boolean
>