Skip to content

Tuple

Tuple<A, B> = readonly [A, B]

Defined in: Core/Tuple.ts:23

Tuple<A, B> represents a pair of two values that are always both present. It is a typed alias for readonly [A, B].

Use Tuple when two values always travel together through a pipeline and you want to transform either or both sides without destructuring.

A

B

import { Tuple } from "@nlozgachev/pipelined/core";
import { pipe } from "@nlozgachev/pipelined/composition";

const entry = Tuple.make("alice", 42);

pipe(
  entry,
  Tuple.mapFirst((name) => name.toUpperCase()),
  Tuple.mapSecond((score) => score * 2),
  Tuple.fold((name, score) => `${name}: ${score}`),
); // "ALICE: 84"