"use strict";

module.exports = function createHandlerTracker() {
	let handlers = new Map();

	return {
		add: function (name, func) {
			if (!handlers.has(name)) {
				handlers.set(name, []);
			}

			handlers.get(name).push(func);
		},
		call: function (name, value) {
			let funcs = handlers.get(name);

			if (funcs != null) {
				for (let func of funcs) {
					func(value);
				}
			}
		},
		has: function (name) {
			return handlers.has(name);
		}
	};
};
