TaskPromise
import { TaskPromise } from "https://raw.githubusercontent.com/worker-tools/json-stream/master/task-promise.ts";
class TaskPromise<T, TT = T> implements Promise<T> { }
private constructor(
key: symbol,
task: Task<TT>,
mapFn?: ((
value: TT,
i?: 0,
p?: TaskPromise<T, TT>,
) => Awaitable<T>) | undefined | null,thisArg?: any,
);get state();
readonly [Symbol.toStringTag]: string;
catch<V = never>(onrejected?: ((reason: any) => Awaitable<V>) | null): Promise<T | V>;
finally(onfinally?: (() => void) | null): Promise<T>;
map<U = T>(mapFn?: ((
value: T,
i?: 0,
p?: TaskPromise<T, TT>,
) => Awaitable<U>) | undefined | null, thisArg?: any): TaskPromise<U, TT>;then<U = T, V = never>(onfulfilled?: ((value: T) => Awaitable<U>) | undefined | null, onrejected?: ((reason: any) => Awaitable<V>) | undefined | null): Promise<U | V>;
static from<T>(task: () => Awaitable<T>);
§Constructors
§
new TaskPromise(key: symbol, task: Task<TT>, mapFn?: ((
[src]value: TT,
i?: 0,
p?: TaskPromise<T, TT>,
) => Awaitable<T>) | undefined | null, thisArg?: any) private§Properties
§Methods
§
map<U = T>(mapFn?: ((
[src]value: T,
i?: 0,
p?: TaskPromise<T, TT>,
) => Awaitable<U>) | undefined | null, thisArg?: any): TaskPromise<U, TT>Applies transformations to the resolved value without triggering execution.
Returns another task promise that triggers execution via .then
§
then<U = T, V = never>(onfulfilled?: ((value: T) => Awaitable<U>) | undefined | null, onrejected?: ((reason: any) => Awaitable<V>) | undefined | null): Promise<U | V>
[src]Starts the execution of the task associated with this task promise.
If you don't want to start the task at this moment, use .map
instead.