"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.inflight = void 0;
const active = {};
const cleanUp = (key) => (result) => {
    delete active[key];
    return result;
};
exports.inflight = (key, doFly) => {
    if (!active[key]) {
        const clean = cleanUp(key);
        active[key] = doFly()
            .then(clean)
            .catch((e) => {
            clean(e);
            throw e;
        });
    }
    return active[key];
};
