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

race

import { race } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/promise.ts";

An alias for Promise.race. Note that Promise.race leaks async operations in most runtimes. This means that the slower promise does not stop when the faster promise resolves/rejects. In effect Promise.race does not handle cancellation.

@example
import { wait, map, race, wrap } from "./promise.ts";
import { pipe } from "./fn.ts";

const one = pipe(wait(200), map(() => "one"));
const two = pipe(wait(300), map(() => "two"));

// After 200 milliseconds resolves from one
const result = await race(one, two); // "one"
await two // We wait here so async ops don't leak
function race<T extends AnyPromise[]>(...ua: T): Promise<Awaited<T[keyof T]>>;
§
race<T extends AnyPromise[]>(...ua: T): Promise<Awaited<T[keyof T]>>
[src]

§Type Parameters

§
T extends AnyPromise[]
[src]

§Parameters

§
...ua: T optional
[src]

§Return Type

§
Promise<Awaited<T[keyof T]>>
[src]