Skip to main content

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!
Playground

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

optionals.d.ts:65

Call Signature

or<Value>(fn, iterable): Value

Type Parameters

Value

Parameters

fn

() => Value

iterable

Iterable<Value, any, any>

Returns

Value

Defined in

optionals.d.ts:66