Skip to content

B (Boolean)

not_(a: boolean): boolean
and_(b: boolean): (a: boolean) => boolean
or_(b: boolean): (a: boolean) => boolean
ifElse<A>(onTrue: () => A, onFalse: () => A): (cond: boolean) => A

Trailing underscores avoid colliding with JS reserved words.

import { pipe } from '@stopcock/fp'
import * as B from '@stopcock/fp/boolean'
pipe(true, B.not_) // false
pipe(true, B.and_(false)) // false
pipe(
false,
B.ifElse(
() => 'yes',
() => 'no',
),
) // 'no'
// toggle a feature flag
const toggled = pipe(isEnabled, B.not_)
// both conditions must hold
const canAccess = pipe(isAdmin, B.and_(isActive))