Standard library
TOption<T>
Represent an optional value as Some(value) or None.
example.tt
import * as Option from "@tt/std/option";
const port = Option.fromNullable(env.PORT)
|> Option.mapP(Number)
|> Option.filterP((n: number) => Number.isFinite(n))
|> Option.unwrapOrP(3000);Features
- Construct with Option.Some(value) and the Option.None value.
- Transform with map, andThen, filter, orElse, zip, flatten, transpose, and collect.
- Bridge nullable values with fromNullable and toNullable.
- Use *P variants in pipelines.