"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAbortError = exports.throwAbortError = exports.createAbortError = void 0;
var kIsAbortError = Symbol('kIsAbortError');
function createAbortError(signal, message) {
    if (signal === null || signal === void 0 ? void 0 : signal.reason) {
        if (typeof signal.reason === 'object') {
            signal.reason[kIsAbortError] = true;
        }
        // Throwing the abort reason as the spec to comply with WHATWG specs
        // https://dom.spec.whatwg.org/#aborting-ongoing-activities
        return signal.reason;
    }
    // If no reason than throw DOMException with abort error according to the specs
    // https://dom.spec.whatwg.org/#interface-abortcontroller
    var error = new DOMException(message || 'Aborted', 'AbortError');
    error[kIsAbortError] = true;
    return error;
}
exports.createAbortError = createAbortError;
function throwAbortError(signal, message) {
    throw createAbortError(signal, message);
}
exports.throwAbortError = throwAbortError;
function isAbortError(error) {
    if (!error || typeof error !== 'object') {
        return false;
    }
    return error[kIsAbortError] || error.name === 'AbortError';
}
exports.isAbortError = isAbortError;
//# sourceMappingURL=abort.js.map