Batcher
Batcher:
object
Defined in: Core/Batcher.ts:32
Type Declaration
Section titled “Type Declaration”make: <
K,E,V>(options) =>Batcher<K,E,V> =makeBatcher
Creates a stateful Batcher with the provided configuration options.
Type Parameters
Section titled “Type Parameters”K
E
V
Parameters
Section titled “Parameters”options
Section titled “options”Options<K, E, V>
Returns
Section titled “Returns”Batcher<K, E, V>
Example
Section titled “Example”Outcome
Section titled “Outcome”Outcome:
object
Synchronous elimination, type guards, and converters for Batcher.Outcome.
Outcome.getOrElse
Section titled “Outcome.getOrElse”getOrElse: <
B>(fallback) => <E,V,K>(outcome) =>B|V=getOrElseOutcome
Returns the value if BatcherOk, otherwise returns the fallback value.
Type Parameters
Section titled “Type Parameters”B
Parameters
Section titled “Parameters”fallback
Section titled “fallback”() => B
Returns
Section titled “Returns”<E, V, K>(outcome) => B | V
Batcher.Outcome.match to handle all three cases explicitly.
Example
Section titled “Example”Outcome.is
Section titled “Outcome.is”is:
object
Type guards for checking Batcher.Outcome variants.
Outcome.is.err
Section titled “Outcome.is.err”err: <
E,V,K>(outcome) =>outcome is Err<E>=isErr
Checks whether an outcome is a BatcherErr.
Type Parameters
Section titled “Type Parameters”E
V
K
Parameters
Section titled “Parameters”outcome
Section titled “outcome”Outcome<E, V, K>
Returns
Section titled “Returns”outcome is Err<E>
- Batcher.Outcome.is.ok to check for a resolved value.
- Batcher.Outcome.is.missing to check for an absent key.
Example
Section titled “Example”Outcome.is.missing
Section titled “Outcome.is.missing”missing: <
E,V,K>(outcome) =>outcome is Missing<K>=isMissing
Checks whether an outcome is a BatcherMissing.
Type Parameters
Section titled “Type Parameters”E
V
K
Parameters
Section titled “Parameters”outcome
Section titled “outcome”Outcome<E, V, K>
Returns
Section titled “Returns”outcome is Missing<K>
- Batcher.Outcome.is.ok to check for a resolved value.
- Batcher.Outcome.is.err to check for a query failure.
Example
Section titled “Example”Outcome.is.ok
Section titled “Outcome.is.ok”ok: <
E,V,K>(outcome) =>outcome is Ok<V>=isOk
Checks whether an outcome is a BatcherOk.
Type Parameters
Section titled “Type Parameters”E
V
K
Parameters
Section titled “Parameters”outcome
Section titled “outcome”Outcome<E, V, K>
Returns
Section titled “Returns”outcome is Ok<V>
- Batcher.Outcome.is.err to check for a query failure.
- Batcher.Outcome.is.missing to check for an absent key.
Example
Section titled “Example”Outcome.make
Section titled “Outcome.make”make:
object
Constructors for creating Batcher.Outcome variants.
Outcome.make.err
Section titled “Outcome.make.err”err: <
E,V,K>(error) =>Outcome<E,V,K> =makeErr
Creates a BatcherErr outcome.
Type Parameters
Section titled “Type Parameters”E
V = never
K = never
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”Outcome<E, V, K>
- Batcher.Outcome.make.ok to construct a successful outcome.
- Batcher.Outcome.make.missing to construct an absent key outcome.
Example
Section titled “Example”Outcome.make.missing
Section titled “Outcome.make.missing”missing: <
K,E,V>(key) =>Outcome<E,V,K> =makeMissing
Creates a BatcherMissing outcome.
Type Parameters
Section titled “Type Parameters”K
E = never
V = never
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”Outcome<E, V, K>
- Batcher.Outcome.make.ok to construct a successful outcome.
- Batcher.Outcome.make.err to construct an error outcome.
Example
Section titled “Example”Outcome.make.ok
Section titled “Outcome.make.ok”ok: <
V,E,K>(value) =>Outcome<E,V,K> =makeOk
Creates a BatcherOk outcome.
Type Parameters
Section titled “Type Parameters”V
E = never
K = never
Parameters
Section titled “Parameters”V
Returns
Section titled “Returns”Outcome<E, V, K>
- Batcher.Outcome.make.err to construct an error outcome.
- Batcher.Outcome.make.missing to construct an absent key outcome.
Example
Section titled “Example”Outcome.map
Section titled “Outcome.map”map: <
V,B>(transform) => <E,K>(outcome) =>Outcome<E,B,K> =mapOutcome
Transforms the value inside a BatcherOk outcome. Leaves Missing and Err unchanged.
Type Parameters
Section titled “Type Parameters”V
B
Parameters
Section titled “Parameters”transform
Section titled “transform”(value) => B
Returns
Section titled “Returns”<E, K>(outcome) => Outcome<E, B, K>
Batcher.Outcome.mapError to transform the error channel instead.
Example
Section titled “Example”Outcome.mapError
Section titled “Outcome.mapError”mapError: <
E,F>(transform) => <V,K>(outcome) =>Outcome<F,V,K> =mapErrorOutcome
Transforms the error inside a BatcherErr outcome. Leaves Ok and Missing unchanged.
Type Parameters
Section titled “Type Parameters”E
F
Parameters
Section titled “Parameters”transform
Section titled “transform”(error) => F
Returns
Section titled “Returns”<V, K>(outcome) => Outcome<F, V, K>
Batcher.Outcome.map to transform the value channel instead.
Example
Section titled “Example”Outcome.match
Section titled “Outcome.match”match: <
E,V,K,B>(cases) => (outcome) =>B=matchOutcome
Eliminates a Batcher.Outcome by handling all three cases (ok, missing, err).
Type Parameters
Section titled “Type Parameters”E
V
K
B
Parameters
Section titled “Parameters”(error) => B
missing
Section titled “missing”(key) => B
(value) => B
Returns
Section titled “Returns”(outcome) => B
Batcher.Outcome.getOrElse to extract the value with a fallback.
Example
Section titled “Example”Outcome.to
Section titled “Outcome.to”to:
object
Converters from Batcher.Outcome to standard library and native representations.
Outcome.to.Maybe
Section titled “Outcome.to.Maybe”Maybe: <
E,V,K>(outcome) =>Maybe<V> =toMaybeOutcome
Converts a Batcher.Outcome to a Maybe, mapping BatcherOk to Some and both
BatcherMissing and BatcherErr to None.
Type Parameters
Section titled “Type Parameters”E = never
V = never
K = never
Parameters
Section titled “Parameters”outcome
Section titled “outcome”Outcome<E, V, K>
Returns
Section titled “Returns”Maybe<V>
Batcher.Outcome.to.Result to convert to a fallible Result.
Example
Section titled “Example”Outcome.to.nullable
Section titled “Outcome.to.nullable”nullable: <
E,V,K>(outcome) =>V|null=toNullableOutcome
Converts a Batcher.Outcome to a nullable value (V | null), mapping BatcherOk
to V and both BatcherMissing and BatcherErr to null.
Type Parameters
Section titled “Type Parameters”E = never
V = never
K = never
Parameters
Section titled “Parameters”outcome
Section titled “outcome”Outcome<E, V, K>
Returns
Section titled “Returns”V | null
Batcher.Outcome.to.Maybe to convert to a type-safe Maybe.
Example
Section titled “Example”Outcome.to.Result
Section titled “Outcome.to.Result”Result: <
K,E2>(onMissing) => <E,V>(outcome) =>Result<E2|E,V> =toResultOutcome
Converts a Batcher.Outcome to a Result, projecting BatcherMissing into a domain error.
Type Parameters
Section titled “Type Parameters”K
E2
Parameters
Section titled “Parameters”onMissing
Section titled “onMissing”(key) => E2
Returns
Section titled “Returns”<E, V>(outcome) => Result<E2 | E, V>
Batcher.Outcome.to.Maybe to convert to an optional value.