Function: findConcur()
Returns a concur iterable containing the first value of concurIterable
for
which fn
returns a value awaitable to a truthy value. Otherwise, returns an
empty concur iterable.
Like Array.prototype.find
, but for concur iterables.
Example
const concurIterable = asConcur([1, 2, `sloth`, 4, `other string`])
console.log(
await pipe(
concurIterable,
findConcur(value => typeof value === `string`),
orConcur(() => `yawn`),
),
)
//=> sloth
console.log(
await pipe(
concurIterable,
findConcur(value => Array.isArray(value)),
orConcur(() => `yawn`),
),
)
//=> yawn!
findConcur(fn)
findConcur<
Value
>(fn
): (concurIterable
) =>ConcurOptional
<Value
>
Returns a concur iterable containing the first value of concurIterable
for
which fn
returns a value awaitable to a truthy value. Otherwise, returns an
empty concur iterable.
Like Array.prototype.find
, but for concur iterables.
Type Parameters
• Value
Parameters
• fn
Returns
Function
Parameters
• concurIterable: ConcurIterable
<Value
>
Returns
ConcurOptional
<Value
>
Example
const concurIterable = asConcur([1, 2, `sloth`, 4, `other string`])
console.log(
await pipe(
concurIterable,
findConcur(value => typeof value === `string`),
orConcur(() => `yawn`),
),
)
//=> sloth
console.log(
await pipe(
concurIterable,
findConcur(value => Array.isArray(value)),
orConcur(() => `yawn`),
),
)
//=> yawn!
Defined in
findConcur(fn, concurIterable)
findConcur<
Value
>(fn
,concurIterable
):ConcurOptional
<Value
>
Returns a concur iterable containing the first value of concurIterable
for
which fn
returns a value awaitable to a truthy value. Otherwise, returns an
empty concur iterable.
Like Array.prototype.find
, but for concur iterables.
Type Parameters
• Value
Parameters
• fn
• concurIterable: ConcurIterable
<Value
>
Returns
ConcurOptional
<Value
>
Example
const concurIterable = asConcur([1, 2, `sloth`, 4, `other string`])
console.log(
await pipe(
concurIterable,
findConcur(value => typeof value === `string`),
orConcur(() => `yawn`),
),
)
//=> sloth
console.log(
await pipe(
concurIterable,
findConcur(value => Array.isArray(value)),
orConcur(() => `yawn`),
),
)
//=> yawn!