'use strict';

var Utility = require('./Utility.cjs');

/**
 * @param {function[]} collection
 * @return {function}
 */
function middleware (collection) {
	var length = Utility.sizeof(collection);

	return function (element, index, children, callback) {
		var output = '';

		for (var i = 0; i < length; i++)
			output += collection[i](element, index, children, callback) || '';

		return output
	}
}

/**
 * @param {function} callback
 * @return {function}
 */
function rulesheet (callback) {
	return function (element) {
		if (!element.root)
			if (element = element.return)
				callback(element);
	}
}

exports.middleware = middleware;
exports.rulesheet = rulesheet;
//# sourceMappingURL=Middleware.cjs.map
