<commit_before>define(function(require) {

	var forOwn = require('mout/object/forOwn');
	var merge = require('mout/object/merge');
	var toArray = require('mout/lang/toArray');
	var waterfall = require('deferreds/waterfall');


	var makeChains = function(constructor) {
		var meta = constructor._meta;
		var proto = constructor.prototype;

		meta.chains = meta.members.__chains || {};

		meta.bases.slice(0).reverse().forEach(function(base) {
			meta.chains = merge(meta.chains, base._meta.chains);
		});

		forOwn(meta.chains, function(type, key) {
			var bases = meta.bases.slice(0); //don't modify passed bases

			//first/last in the chain should be this constructor
			bases.unshift(constructor);

			if (type === 'after') {
				bases = bases.reverse();
			}

			proto[key] = function() {
				var args = toArray(arguments);

				bases = bases.filter(function(base) {
					return base._meta.members.hasOwnProperty(key);
				});

				var methods = bases.map(function(base) {
					return base._meta.members[key].bind(this);
				}.bind(this));

				if (args.length) {
					//first argument is passed as an argument to the first
					//method
					methods.unshift(args);
				}

				return waterfall(methods);
			};
		});
	};


	return makeChains;

});
<commit_msg>Fixed plugins/makeChains.js with new deferreds.js' waterfall -> pipe rename<commit_after>define(function(require) {

	var forOwn = require('mout/object/forOwn');
	var merge = require('mout/object/merge');
	var toArray = require('mout/lang/toArray');
	var pipe = require('deferreds/pipe');


	var makeChains = function(constructor) {
		var meta = constructor._meta;
		var proto = constructor.prototype;

		meta.chains = meta.members.__chains || {};

		meta.bases.slice(0).reverse().forEach(function(base) {
			meta.chains = merge(meta.chains, base._meta.chains);
		});

		forOwn(meta.chains, function(type, key) {
			var bases = meta.bases.slice(0); //don't modify passed bases

			//first/last in the chain should be this constructor
			bases.unshift(constructor);

			if (type === 'after') {
				bases = bases.reverse();
			}

			proto[key] = function() {
				var args = toArray(arguments);

				bases = bases.filter(function(base) {
					return base._meta.members.hasOwnProperty(key);
				});

				var methods = bases.map(function(base) {
					return base._meta.members[key].bind(this);
				}.bind(this));

				if (args.length) {
					//first argument is passed as an argument to the first
					//method
					methods.unshift(args);
				}

				return pipe(methods);
			};
		});
	};


	return makeChains;

});

{'fraction_non_alphanumeric': 0.15001943256898562, 'fraction_numerical': 0.001554605518849592, 'mean_word_length': 3.385008517887564, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5867340', 'n_tokens_mistral': 991, 'n_tokens_neox': 806, 'n_words': 177}