/* IMPORT */
import makeNakedPromise from 'promise-make-naked';
/* MAIN */
const makeCounterPromise = () => {
    const { promise, resolve, isPending } = makeNakedPromise();
    let counter = 0;
    const increment = () => {
        counter += 1;
    };
    const decrement = () => {
        counter -= 1;
        if (counter)
            return;
        resolve();
    };
    const init = () => {
        increment();
        queueMicrotask(decrement);
    };
    init();
    return { promise, isPending, increment, decrement };
};
/* EXPORT */
export default makeCounterPromise;
