{"version":3,"file":"abort-controller.mjs.map","sources":["../src/abort-signal.mjs","../src/abort-controller.mjs"],"sourcesContent":["import { EventTarget, defineEventAttribute } from \"event-target-shim\"\n\n/**\n * Aborted flag for each instances.\n * @type {WeakMap<AbortSignal, boolean>}\n */\nconst abortedFlags = new WeakMap()\n\n/**\n * The signal class.\n * @constructor\n * @name AbortSignal\n * @see https://dom.spec.whatwg.org/#abortsignal\n */\nexport default class AbortSignal extends EventTarget {\n    /**\n     * AbortSignal cannot be constructed directly.\n     */\n    constructor() {\n        super()\n        throw new TypeError(\"AbortSignal cannot be constructed directly\")\n    }\n\n    /**\n     * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise.\n     * @type {boolean}\n     */\n    get aborted() {\n        const aborted = abortedFlags.get(this)\n        if (typeof aborted !== \"boolean\") {\n            throw new TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this === null ? \"null\" : typeof this}`)\n        }\n        return Boolean(aborted)\n    }\n\n    /**\n     * The event attribute for `abort` event.\n     * @property\n     * @memberof AbortSignal\n     * @name onabort\n     * @type {Function}\n     */\n}\n\n// Properties should be enumerable.\nObject.defineProperties(AbortSignal.prototype, {\n    aborted: {\n        enumerable: true,\n    },\n})\n\nif (typeof Symbol === \"function\" && typeof Symbol.toStringTag === \"symbol\") { //eslint-disable-line node/no-unsupported-features\n    Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, { //eslint-disable-line node/no-unsupported-features\n        configurable: true,\n        value: \"AbortSignal\",\n    })\n}\n\ndefineEventAttribute(AbortSignal.prototype, \"abort\")\n\n/**\n * Create an AbortSignal object.\n * @returns {AbortSignal} The created AbortSignal object.\n */\nexport function createAbortSignal() {\n    const signal = Object.create(AbortSignal.prototype)\n    EventTarget.call(signal)\n    abortedFlags.set(signal, false)\n    return signal\n}\n\n/**\n * Abort a given signal.\n * @param {AbortSignal} signal The signal to abort.\n * @returns {void}\n */\nexport function abortSignal(signal) {\n    if (abortedFlags.get(signal) !== false) {\n        return\n    }\n\n    abortedFlags.set(signal, true)\n    signal.dispatchEvent({ type: \"abort\" })\n}\n","import AbortSignal, { abortSignal, createAbortSignal } from \"./abort-signal.mjs\"\n\n/**\n * Associated signals.\n * @type {WeakMap<AbortController, AbortSignal>}\n */\nconst signals = new WeakMap()\n\n/**\n * Get the associated signal of a given controller.\n * @param {AbortController} controller The controller to get its associated signal.\n * @returns {AbortSignal} The associated signal.\n */\nfunction getSignal(controller) {\n    const signal = signals.get(controller)\n    if (signal == null) {\n        throw new TypeError(`Expected 'this' to be an 'AbortController' object, but got ${controller === null ? \"null\" : typeof controller}`)\n    }\n    return signal\n}\n\n/**\n * The AbortController.\n * @see https://dom.spec.whatwg.org/#abortcontroller\n */\nexport default class AbortController {\n    /**\n     * Initialize this controller.\n     */\n    constructor() {\n        signals.set(this, createAbortSignal())\n    }\n\n    /**\n     * Returns the `AbortSignal` object associated with this object.\n     * @type {AbortSignal}\n     */\n    get signal() {\n        return getSignal(this)\n    }\n\n    /**\n     * Abort and signal to any observers that the associated activity is to be aborted.\n     * @returns {void}\n     */\n    abort() {\n        // Not depend on this.signal which is overridable.\n        const signal = getSignal(this)\n        if (signal != null) {\n            abortSignal(signal)\n        }\n    }\n}\n\n// Properties should be enumerable.\nObject.defineProperties(AbortController.prototype, {\n    signal: { enumerable: true },\n    abort: { enumerable: true },\n})\n\nif (typeof Symbol === \"function\" && typeof Symbol.toStringTag === \"symbol\") { //eslint-disable-line node/no-unsupported-features\n    Object.defineProperty(AbortController.prototype, Symbol.toStringTag, { //eslint-disable-line node/no-unsupported-features\n        configurable: true,\n        value: \"AbortController\",\n    })\n}\n\nexport { AbortController, AbortSignal }\n"],"names":[],"mappings":";;;;;;;AAEA;;;;AAIA,MAAM,YAAY,GAAG,IAAI,OAAO,GAAE;;;;;;;;AAQlC,AAAe,MAAM,WAAW,SAAS,WAAW,CAAC;;;;IAIjD,WAAW,GAAG;QACV,KAAK,GAAE;QACP,MAAM,IAAI,SAAS,CAAC,4C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