<commit_before>/**
 *	@author <NAME> <<EMAIL>>
 */
'use strict';

var _ = require('lodash');
var co = require('co');



/**
 *	Main class of the module.
 *
 *	@param {array} config - Configuration.
 */
var Essence = function(config) {
	this._config = config || [];
	this._services = {};
};



/**
 *	Fetches informations about the given URL.
 *
 *	@param {string} url - URL.
 *	@param {object} options - Options.
 *	@param {function} callback - Callback.
 *	@return {function} - Thunk.
 */
Essence.prototype.fetch = function(url, options, callback) {
	if (_.isFunction(options)) {
		callback = options;
	}

	if (!_.isObject(options)) {
		options = {};
	}

	var fetch = co(function *() {
		var lastError = null;

		for (var i in this._config) {
			var config = this._config[i];

			if (config.scheme.test(url)) {
				try {
					var service = this._service(config);
					return yield service.fetch(url, options);
				} catch (e) {
					lastError = e;
				}
			}
		}

		throw lastError || new Error('Unable to find a suitable service');
	});

	if (callback) {
		fetch.call(this, callback);
	}

	return fetch.bind(this);
};



/**
 *	Returns an instance of the service identified by the given name.
 *
 *	@param {string} name - Service name.
 *	@param {object} config - Configuration.
 *	@return {object} - Service.
 */
Essence.prototype._service = function(config) {
	if (!(config.name in this._services)) {
		this._services[config.name] = config.service(config);
	}
<commit_msg>Simplified a piece of code<commit_after>/**
 *	@author <NAME> <<EMAIL>>
 */
'use strict';

var _ = require('lodash');
var co = require('co');



/**
 *	Main class of the module.
 *
 *	@param {array} config - Configuration.
 */
var Essence = function(config) {
	this._config = config || [];
	this._services = {};
};



/**
 *	Fetches informations about the given URL.
 *
 *	@param {string} url - URL.
 *	@param {object} options - Options.
 *	@param {function} callback - Callback.
 *	@return {function} - Thunk.
 */
Essence.prototype.fetch = function(url, options, callback) {
	if (_.isFunction(options)) {
		callback = options;
	}

	if (!_.isObject(options)) {
		options = {};
	}

	var fetch = co(function *() {
		var lastError = null;

		for (var i in this._config) {
			var config = this._config[i];

			if (config.scheme.test(url)) {
				try {
					var service = this._service(config);
					return yield service.fetch(url, options);
				} catch (e) {
					lastError = e;
				}
			}
		}

		throw lastError || new Error('Unable to find a suitable service');
	}).bind(this);

	if (callback) {
		fetch(callback);
	}

	return fetch;
};



/**
 *	Returns an instance of the service identified by the given name.
 *
 *	@param {string} name - Service name.
 *	@param {object} config - Configuration.
 *	@return {object} - Service.
 */
Essence.prototype._service = function(config) {
	if (!(config.name in this._services)) {
		this._services[config.name] = config.service(config);
	}

{'fraction_non_alphanumeric': 0.16384563303994584, 'fraction_numerical': 0.0, 'mean_word_length': 3.132867132867133, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4641211', 'n_tokens_mistral': 1081, 'n_tokens_neox': 978, 'n_words': 268}