method TaskClass.result
Private
TaskClass.result<T, E>(task: TaskClass<T, E> | PromiseLike<T>): TaskClass<Result<T, E>, never>

Data-first twin of TaskClass#result — the bridge to the bare Result union.

Takes a foreign promise as well as a Task, matching TaskClass.results and the constructor: this twin is most useful over a value someone handed you, and being handed a promise is the ordinary case. A promise is lifted first, so its rejection lands on the failure channel exactly as a Task's would.

const value = await Task.result(Task(() => 21 * 2)); // 42 — or the declared Failure, bare
await Task.result(Promise.resolve(7)); // 7 — a foreign promise needs no wrapping first

Type Parameters

Parameters

task: TaskClass<T, E> | PromiseLike<T>

Return Type

TaskClass<Result<T, E>, never>

Usage

import { TaskClass } from "lib/task/task.ts";