From 7b949e2ec1a24f3fc03576673042a013ded75856 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Mon, 17 Jun 2024 08:13:26 +1000 Subject: [PATCH] BREAKING(async): make `abortablePromise()` and `abortableAsyncIterable()` private --- async/abortable.ts | 58 ++-------------------------------------------- 1 file changed, 2 insertions(+), 56 deletions(-) diff --git a/async/abortable.ts b/async/abortable.ts index d3122479c052..365e71ac3a44 100644 --- a/async/abortable.ts +++ b/async/abortable.ts @@ -73,30 +73,7 @@ export function abortable( } } -/** - * Make a {@linkcode Promise} abortable with the given signal. - * - * @typeParam T The type of the provided and returned promise. - * @param p The promise to make abortable. - * @param signal The signal to abort the promise with. - * @returns A promise that can be aborted. - * - * @example Usage - * ```ts no-eval - * import { abortablePromise } from "@std/async/abortable"; - * - * const request = fetch("https://example.com"); - * - * const c = new AbortController(); - * setTimeout(() => c.abort(), 100); - * - * const p = abortablePromise(request, c.signal); - * - * // The below throws if the request didn't resolve in 100ms - * await p; - * ``` - */ -export function abortablePromise( +function abortablePromise( p: Promise, signal: AbortSignal, ): Promise { @@ -111,38 +88,7 @@ export function abortablePromise( }); } -/** - * Make an {@linkcode AsyncIterable} abortable with the given signal. - * - * @typeParam T The type of the provided and returned async iterable. - * @param p The async iterable to make abortable. - * @param signal The signal to abort the promise with. - * @returns An async iterable that can be aborted. - * - * @example Usage - * ```ts no-eval - * import { - * abortableAsyncIterable, - * delay, - * } from "@std/async"; - * - * const p = async function* () { - * yield "Hello"; - * await delay(1000); - * yield "World"; - * }; - * const c = new AbortController(); - * setTimeout(() => c.abort(), 100); - * - * // Below throws `DOMException` after 100 ms - * // and items become `["Hello"]` - * const items: string[] = []; - * for await (const item of abortableAsyncIterable(p(), c.signal)) { - * items.push(item); - * } - * ``` - */ -export async function* abortableAsyncIterable( +async function* abortableAsyncIterable( p: AsyncIterable, signal: AbortSignal, ): AsyncGenerator {