Skip to content

unless

unless<A, B, C>(predicate, onFalse): (value) => B | C

Defined in: Composition/unless.ts:19

Executes a function on the piped value if a predicate is NOT met, otherwise returns the value unchanged.

A

B

C

(value) => value is B

(value) => C

(value) => B | C

pipe(
  5,
  unless(n => n % 2 === 0, n => n * 2)
); // 10

pipe(
  4,
  unless(n => n % 2 === 0, n => n * 2)
); // 4

when for executing when a predicate is met

unless<A, B>(predicate, onFalse): <V>(value) => B | V

Defined in: Composition/unless.ts:23

Executes a function on the piped value if a predicate is NOT met, otherwise returns the value unchanged.

A

B = A

(value) => boolean

(value) => B

<V>(value) => B | V

pipe(
  5,
  unless(n => n % 2 === 0, n => n * 2)
); // 10

pipe(
  4,
  unless(n => n % 2 === 0, n => n * 2)
); // 4

when for executing when a predicate is met