import { abortWith } from "https://deno.land/x/ayonli_jsext@v0.9.72/async.ts";
Creates a new abort controller with a parent
signal, the new abort signal
will be aborted if the controller's abort
method is called or when the
parent signal is aborted, whichever happens first.
Examples
Example 1
Example 1
import { abortWith } from "@ayonli/jsext/async";
const parent = new AbortController();
const child1 = abortWith(parent.signal);
const child2 = abortWith(parent.signal);
child1.abort();
console.assert(child1.signal.aborted);
console.assert(!parent.signal.aborted);
parent.abort();
console.assert(child2.signal.aborted);
console.assert(child2.signal.reason === parent.signal.reason);
Parameters
parent: AbortSignal
optional
options: Omit<AbortWithOptions, "parent">