Task
Index
Constructor
create
Type parameters
- Value
- Error = never
error
Create a new
Errorobject
ok
Create a new
Okobject
reject
Constructor that always returns a failed
Taskthat rejectsvoid.Type parameters
- Value = never
resolve
Constructor that always returns a successful
Taskthat resolvesvoid.Type parameters
- Error = never
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
all
Resolves with the array of all task values, or reject with the first error
Type parameters
- T: readonly TaskLike<any, any>[]
allSettled
Resolves an array of all task results
Type parameters
- T: TaskLike<any, any>[]
andRun
Similar to andThen but the task keep
taskresolved valueType parameters
- ValueFrom
- ErrorFrom
- ErrorTo
andThen
Calls
fnif the task is successful, otherwise returns the failed task untouched. This function can be used for control flow based onTaskvalues.Type parameters
- ValueFrom
- ErrorFrom
- ValueTo
- ErrorTo
any
Resolves with the first value, or reject with an aggregated error
Type parameters
- T: TaskLike<any, any>[]
from
Create a Task from a
Symbol.runfunction or a TaskLikeType parameters
- Value
- Error
ignore
Ignores value of task
Type parameters
- Error
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.Type parameters
- ValueFrom
- ErrorFrom
- ValueTo
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.Type parameters
- ValueFrom
- ErrorFrom
- ErrorTo
mapResult
Maps a
Task<ValueFrom, ErrorFrom>toTask<ValueTo, ErrorTo>by applying a function to the result of the task.Type parameters
- ValueFrom
- ErrorFrom
- ValueTo
- ErrorTo
orElse
Calls
fnif the task is failed, otherwise returns the successful task untouched. This function can be used for control flow based onTaskvalues.Type parameters
- ValueFrom
- ErrorFrom
- ValueTo
- ErrorTo
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.
Type parameters
- Value
- Error
tryCall
Creates a new
Taskthat resolvessideEffect(). When an exception is thrown then it rejectsonError([thrown error]).Type parameters
- Value
- Error = never
Task constructor