promise-option
{/* @generated by scripts/sync-content.mjs; do not edit */}
@sandlada/result/promise-option — eager operators on Promise<IOption<T>>.
- Operates on:
Promise<IOption<T>>; callbacks may be synchronous or asynchronous depending on the operator. - Execution model: eager — the chain starts on the call and the returned Promise is already in flight.
- Not here: sync Option operators (
option), sync-to-async lift (bridge-option), lazy thunks (async-option), Result variants (promise-result).
Operators on Promise<IOption>
Section titled “Operators on Promise<IOption>”| Export | Description | Source |
|---|---|---|
mapAsync |
Transforms the Some value with an async callback. |
mapAsync.ts |
bindAsync |
Async chain returning the next Option. | bindAsync.ts |
orElseAsync |
Async fallback on None. |
orElseAsync.ts |
matchAsync |
Async terminal pattern match. | matchAsync.ts |
mapOrAsync / mapOrElseAsync |
Map the Some value or fall back asynchronously. |
mapOrAsync.ts, mapOrElseAsync.ts |
tapAsync / tapErrAsync |
Async side effects; tapErrAsync observes the Some track with fn and the None track with fnNone. |
tapAsync.ts, tapErrAsync.ts |
unwrapOrAsync / unwrapOrElseAsync |
Extract the value or an async default. | unwrapOrAsync.ts, unwrapOrElseAsync.ts |
containsAsync / existsAsync / filterAsync |
Async predicate queries. | containsAsync.ts, existsAsync.ts, filterAsync.ts |
flattenAsync |
Flattens Promise<IOption<IOption<T>>>. |
flattenAsync.ts |
Contract notes
Section titled “Contract notes”- A rejection of the outer
Promiseitself always stays a rejection; it is never converted intoNone. - Callback policy: operators on
Promise<IOption>collapse a throwing callback or an async rejection intoNone/false/ the default value;matchAsync,mapOrElseAsyncandunwrapOrElseAsyncpropagate instead. SyncIOptionlifts are documented underbridge-option. See behavior-modes.md §4.6. - This layer has no
unwrap/expect/orThrow; extraction goes through theunwrapOr*family. - There are no combination APIs here; combine Options with the sync
option/allbefore lifting when needed. - Naming mirrors
promise-result:*AsynconPromise<IOption>. Sync lifts usebridge-option.
Design notes
Section titled “Design notes”- Eager and lazy async are separate modules.
promise-optionmirrorspromise-resulton the Option track, whileasync-optionprovides the lazy thunk counterpart.
Related
Section titled “Related”bridge-option— lift syncIOptionintoPromise<IOption>.option— synchronous Option operators.promise-result— the Result-track mirror.