"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSemaphore = createSemaphore;
function __assignType(fn, args) {
    fn.__type = args;
    return fn;
}
function createSemaphore() {
    let isReleased = false;
    let _resolve;
    const promise = (Promise.Ω = [['$']], new Promise(__assignType(resolve => {
        _resolve = resolve;
    }, ['resolve', '', 'P"2!"/"'])));
    return {
        release: () => {
            if (!_resolve)
                throw new Error('Semaphore not ready');
            if (isReleased)
                throw new Error('Semaphore already released');
            isReleased = true;
            process.nextTick(_resolve);
        },
        promise
    };
}
createSemaphore.__type = ['createSemaphore', 'P"/!'];
//# sourceMappingURL=promise.js.map