Task
Index
Constructor
create
reject
Constructor that always returns a failed
Taskthat rejectsvoid.
resolve
Constructor that always returns a successful
Taskthat resolvesvoid.
Type
hasInstance
Return
trueif anyValue is a validTask
Other
ErrorOf
Extracts error type of task T
Type parameters
- T
ValueOf
Extracts value type of task T
Type parameters
- T
error
ok
all
Resolves with the array of all task values, or reject with the first error
allKeyed
Resolves with the record of all task values, or reject with the first error
allSettled
Resolves an array of all task results
allSettledKeyed
Resolves with the record of all task values, or reject with the first error
andRun
Similar to andThen but the task keep
taskresolved value
andThen
Calls
fnif the task is successful, otherwise returns the failed task untouched. This function can be used for control flow based onTaskvalues.
any
Resolves with the first value, or reject with an aggregated error
from
Create a Task from a
Symbol.runfunction or a TaskLike
ignore
Ignores value of task
map
Maps a
Task<Value, Error>toTask<NewValue, Error>by applying a function to a success value, leaving a failure untouched. This function can be used to compose the results of two functions.
mapError
Maps a
Task<Value, ErrorFrom>toTask<Value, ErrorTo>by applying a function to a contained failure error, leaving a success value untouched. This function can be used to pass through a successful result while handling an error.
mapResult
Maps a
Task<ValueFrom, ErrorFrom>toTask<ValueTo, ErrorTo>by applying a function to the result of the task.
orElse
Calls
fnif the task is failed, otherwise returns the successful task untouched. This function can be used for control flow based onTaskvalues.
run
Run
taskand return the result or a promise of the result⚠ Impure function that may throw an error, it should be used on the edge of the program.
tryCall
Creates a new
Taskthat resolvessideEffect(). When an exception is thrown then it rejectsonError([thrown error]).
Task constructor