<commit_before>module.exports = TwoStep;
module.exports.Steppy = Steppy;

var slice = Array.prototype.slice;

/**
 * Group represents one step in Step's execution flow. Makes a decision when
 * the execution should jump to the next step.
 *
 * @param {function(err, args)} callback
 *   Callback to be called on successful execution end

 * @param {function(err, args)} [errorCallback]
 *   If defined, will be called in case of error (default value: callback arg)
 */
function Group(callback, errorCallback) {
	this.args = [null];
	this.reservedSlots = 0;
	this.callback = callback;
	this.errorCallback = errorCallback || callback;
	this.isDone = false;
}

Group.prototype.done = function done() {
	if (this.isDone) {
		return;
	}
	this.isDone = true;
	//Don't go to next step if no args is passed
	if (this.args.length != 1) {
		this.callback.apply(null, this.args);
	}
};

Group.prototype.error = function error(err) {
	if (this.isDone) {
		return;
	}
	this.isDone = true;
	this.errorCallback(err);
};

/**
 * Reserve space for one argument in the `args` array.
 * @return {Number} index of the reserved slot
 */
Group.prototype._reserveSlot = function() {
	var self = this;
	self.reservedSlots++;
	return self.args.push(undefined) - 1;
};

/**
 * Fill the reserved slot addressed by `index` with the given `value`.
 */
Group.prototype._fillSlot = function(index, data) {
	this.args[index] = data;
	if (!--this.reservedSlots) {
		this.done();
	}
};<commit_msg>uniformly handling error and success group termination<commit_after>module.exports = TwoStep;
module.exports.Steppy = Steppy;

var slice = Array.prototype.slice;

/**
 * Group represents one step in Step's execution flow. Makes a decision when
 * the execution should jump to the next step.
 *
 * @param {function(err, args)} callback
 *   Callback to be called on successful execution end

 * @param {function(err, args)} [errorCallback]
 *   If defined, will be called in case of error (default value: callback arg)
 */
function Group(callback, errorCallback) {
	this.args = [null];
	this.reservedSlots = 0;
	this.callback = callback;
	this.errorCallback = errorCallback || callback;
	this.isDone = false;
}

Group.prototype.done = function done(err) {
	if (this.isDone) {
		return;
	}
	this.isDone = true;
	this.args[0] = err;
	(err ? this.errorCallback : this.callback).apply(null, this.args);
};

Group.prototype.error = function error(err) {
	this.done(err);
};

/**
 * Reserve space for one argument in the `args` array.
 * @return {Number} index of the reserved slot
 */
Group.prototype._reserveSlot = function() {
	var self = this;
	self.reservedSlots++;
	return self.args.push(undefined) - 1;
};

/**
 * Fill the reserved slot addressed by `index` with the given `value`.
 */
Group.prototype._fillSlot = function(index, data) {
	this.args[index] = data;
	if (!--this.reservedSlots) {
		this.done();
	}
};
{'fraction_non_alphanumeric': 0.1334723670490094, 'fraction_numerical': 0.0020855057351407717, 'mean_word_length': 3.9792387543252596, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1821334', 'n_tokens_mistral': 941, 'n_tokens_neox': 909, 'n_words': 284}