import { useMemo } from '../hooks.js';
import { useEffect } from '../use-effect.js';

/**
 * @type {import("core").UseAbortController}
 */
const useAbortController = (args) => {
    const abortController = useMemo(() => new AbortController(), args);

    useEffect(() => () => abortController.abort(), [abortController]);

    return abortController;
};

export { useAbortController };
