<commit_before>// Core coroutine runner
function run(coroutine) {
	return new Promise(function (resolve, reject) {
		(function next(value, exception) {
			var result;
			try {
				result = exception ? coroutine.throw(value) : coroutine.next(value);
			}
			catch (error) {
				return reject(error);
			}
			if (result.done) return resolve(result.value);
			Promise.resolve(result.value).then(next, function(error) {
				next(error, true);
			});
		})();
	});
}

function isGeneratorFunction(obj) {
	return obj && obj.constructor && 'GeneratorFunction' == obj.constructor.name;
}

// Throw error in next event turn
function raise(error) {
	if (!error) return;
	setImmediate(function() {
		throw error;
	});
}

// Run coroutine and raise exception on failure
function copromise(coroutine) {
	if (isGeneratorFunction(coroutine)) {
		coroutine = coroutine();
	}
	return run(coroutine);
}

copromise.exec = function exec(coroutine) {
	return run(coroutine).catch(copromise.raise);
};

module.exports = copromise;<commit_msg>Fix copromise.exec<commit_after>// Core coroutine runner
function run(coroutine) {
	return new Promise(function (resolve, reject) {
		(function next(value, exception) {
			var result;
			try {
				result = exception ? coroutine.throw(value) : coroutine.next(value);
			}
			catch (error) {
				return reject(error);
			}
			if (result.done) return resolve(result.value);
			Promise.resolve(result.value).then(next, function(error) {
				next(error, true);
			});
		})();
	});
}

function isGeneratorFunction(obj) {
	return obj && obj.constructor && 'GeneratorFunction' == obj.constructor.name;
}

// Throw error in next event turn
function raise(error) {
	if (!error) return;
	setImmediate(function() {
		throw error;
	});
}

// Run coroutine and raise exception on failure
function copromise(coroutine) {
	if (isGeneratorFunction(coroutine)) {
		coroutine = coroutine();
	}
	return run(coroutine);
}

copromise.exec = function exec(coroutine) {
	return run(coroutine).catch(raise);
};

module.exports = copromise;
{'fraction_non_alphanumeric': 0.13871126414166257, 'fraction_numerical': 0.0, 'mean_word_length': 4.352631578947369, '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': '4375013', 'n_tokens_mistral': 694, 'n_tokens_neox': 666, 'n_words': 152}