"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.testMIMO = testMIMO;
exports.testSISO = testSISO;
exports.countEvent = countEvent;
exports.callAfterCount = callAfterCount;
const assert_1 = __importDefault(require("assert"));
function testMIMO(unit, input, output) {
    unit.pushAll(input);
    assert_1.default.deepEqual(unit.takeAll(), output);
}
function testSISO(unit, inputName, input, outputName, output) {
    unit.push(inputName, input);
    assert_1.default.deepEqual(unit.peak(outputName), output);
}
function countEvent(emitter, event, callback) {
    const eventCounter = {
        count: 0,
        remove: () => {
            emitter.removeListener(event, listener);
        },
        reset: () => {
            eventCounter.count = 0;
        },
    };
    const listener = () => {
        eventCounter.count++;
        callback && callback(eventCounter.count);
    };
    emitter.addListener(event, listener);
    return eventCounter;
}
function callAfterCount(pin, event, max = 1000, callback) {
    const eventCounter = countEvent(pin, event, (count) => {
        if (count >= max) {
            callback();
        }
    });
    return eventCounter;
}
//# sourceMappingURL=util.js.map