<commit_before>/*jslint node: true, nomen: true, white: true*/
/*!
 * Sitegear3
 * Copyright(c) 2014 <NAME>, Sitegear.org
 * MIT Licensed
 */

(function (_, events) {
	"use strict";

	/**
	 * Storage interface for sitegear3.
	 * @param driver function The driver function, which must return an object that provides the methods specified in
	 *   the Storage Driver API.
	 * @returns {Object}
	 */
	module.exports = function (driver) {
		var collections = {};
		return {
			collection: function (type) {
				if (!collections[type]) {
					// Instantiate on first access
					collections[type] = _.extend(new events.EventEmitter(), {
						set: function (key, value, callback) {
							var storage = this;
							driver.set(type, key, value, function (error) {
								if (_.isFunction(callback)) {
									callback(error);
								}
								if (error) {
									storage.emit('error', error);
								} else {
									storage.emit('set', type, key, value);
								}
							});
							return this;
						},

						get: function (key, callback) {
							var storage = this;
							driver.get(type, key, function (error, value) {
								if (_.isFunction(callback)) {
									callback(error, value);
								}
								if (error) {
									storage.emit('error', error);
								} else {
									storage.emit('get', type, key, value);
								}
							});
							return this;
						},

						remove: function (key, callback) {
							var storage = this;
							driver.remove(type, key, function (error) {
								if (_.isFunction(callback)) {
									callback(error);
								}
								if (error) {
									storage.emit('error', error);
								} else {
									storage.emit('remove', type, key);
								}
							});
							return this;
						}
					});
					collections[type].on('error', function (error) {
						console.log('Storage interface encountered an error: ' + error);
					});
				}
				return collections[type];
			}
		};
	};
}(require('lodash'), require('events')));<commit_msg>Remove unnecessary local vars.<commit_after>/*jslint node: true, nomen: true, white: true*/
/*!
 * Sitegear3
 * Copyright(c) 2014 <NAME>, Sitegear.org
 * MIT Licensed
 */

(function (_, events) {
	"use strict";

	/**
	 * Storage interface for sitegear3.
	 * @param driver function The driver function, which must return an object that provides the methods specified in
	 *   the Storage Driver API.
	 * @returns {Object}
	 */
	module.exports = function (driver) {
		var collections = {};
		return {
			collection: function (type) {
				if (!collections[type]) {
					// Instantiate on first access
					collections[type] = _.extend(new events.EventEmitter(), {
						set: function (key, value, callback) {
							driver.set(type, key, value, function (error) {
								if (_.isFunction(callback)) {
									callback(error);
								}
								if (error) {
									collections[type].emit('error', error);
								} else {
									collections[type].emit('set', type, key, value);
								}
							});
							return collections[type];
						},

						get: function (key, callback) {
							driver.get(type, key, function (error, value) {
								if (_.isFunction(callback)) {
									callback(error, value);
								}
								if (error) {
									collections[type].emit('error', error);
								} else {
									collections[type].emit('get', type, key, value);
								}
							});
							return collections[type];
						},

						remove: function (key, callback) {
							driver.remove(type, key, function (error) {
								if (_.isFunction(callback)) {
									callback(error);
								}
								if (error) {
									collections[type].emit('error', error);
								} else {
									collections[type].emit('remove', type, key);
								}
							});
							return collections[type];
						}
					});
					collections[type].on('error', function (error) {
						console.log('Storage interface encountered an error: ' + error);
					});
				}
				return collections[type];
			}
		};
	};
}(require('lodash'), require('events')));
{'fraction_non_alphanumeric': 0.1458385093167702, 'fraction_numerical': 0.0029813664596273293, 'mean_word_length': 2.185126582278481, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1508077', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1152, 'n_words': 301}