Constructors
Option.of
The primary way to lift nullable values:
Option.of(value);
| Input | Result |
|---|---|
null | None |
undefined | None |
| any other value | Some(value) |
Some
Creates a non-empty option unconditionally:
Some(0);
Some('');
Some(null); // Option<null> — isDefined is true
Use when the value is already known to be present.
None
Singleton empty option:
import { None } from '@ekz/option';
const missing: Option<string> = None;
Also available as Option.None after the module loads.
Do not use new Option()
The constructor is private. Always use Option.of, Some, or None — otherwise an error is thrown.
Static aliases
Option.Some(1);
Option.None;
Equivalent to the exported Some function and None constant.