Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/async.ts>abortWith

A JavaScript extension package for building strong and modern applications.
Latest
function abortWith
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

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">