var Hook = /** @class */ (function () {
    function Hook() {
        this.registeredHooks = [];
    }
    Hook.prototype.untap = function (name) {
        var index = this.registeredHooks.findIndex(function (item) { return item.name === name; });
        if (index > -1) {
            this.registeredHooks.splice(index, 1);
        }
    };
    Hook.prototype.tap = function (name, callback) {
        var _this = this;
        if (this.registeredHooks.find(function (hook) { return hook.name === name; })) {
            throw new Error("A hook with the name " + name + " has already been registered");
        }
        var listener = {
            name: name,
            callback: callback,
        };
        this.registeredHooks.push(listener);
        return function () {
            var hookIndex = _this.registeredHooks.indexOf(listener);
            if (hookIndex > -1) {
                _this.registeredHooks.splice(hookIndex, 1);
            }
        };
    };
    Hook.prototype.getListeners = function () {
        return this.registeredHooks;
    };
    return Hook;
}());
export { Hook };
