Function: or()
Returns the only value in iterable
if it contains exactly one value.
Otherwise, returns the result of invoking fn
.
Example
import { or, pipe } from 'lfi'
console.log(
pipe(
[`sloth`],
or(() => `never called`),
),
)
//=> sloth
console.log(
pipe(
[],
or(() => `called!`),
),
)
//=> called!
console.log(
pipe(
[`sloth`, `lazy`, `sleep`],
or(() => `called!`),
),
)
//=> called!
Since
v0.0.1
Call Signature
or<
Value
>(fn
): (iterable
) =>Value
Type Parameters
• Value
Parameters
fn
() => Value
Returns
Function
Parameters
iterable
Iterable
<Value
, any
, any
>
Returns
Value
Defined in
Call Signature
or<
Value
>(fn
,iterable
):Value
Type Parameters
• Value
Parameters
fn
() => Value
iterable
Iterable
<Value
, any
, any
>
Returns
Value