Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

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>);
}

§Type Parameters

§
TT = T
[src]

§Implements

§
Promise<T>
[src]

§Constructors

§
new TaskPromise(key: symbol, task: Task<TT>, mapFn?: ((
value: TT,
i?: 0,
p?: TaskPromise<T, TT>,
) => Awaitable<T>
)
| undefined | null
, thisArg?: any) private
[src]

§Properties

§
state readonly
[src]
§
[Symbol.toStringTag]: string
[src]

§Methods

§
catch<V = never>(onrejected?: ((reason: any) => Awaitable<V>) | null): Promise<T | V>
[src]
§
finally(onfinally?: (() => void) | null): Promise<T>
[src]
§
map<U = T>(mapFn?: ((
value: T,
i?: 0,
p?: TaskPromise<T, TT>,
) => Awaitable<U>
)
| undefined | null
, thisArg?: any): TaskPromise<U, TT>
[src]

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.

§Static Methods

§
from<T>(task: () => Awaitable<T>)
[src]