<commit_before>var reddit = global.reddit;

reddit._addSimpleRequest = function(name, endpoint, method, args, constArgs, callback) {
	reddit.prototype[name] = function() {
		var form;
		if(args.length > 0 || constArgs) {
			form = {};
		}
		
		for(var i = 0; i < args.length; i++) {
			form[args[i]] = arguments[i];
		}
		
		for(var i in constArgs) {
			form[i] = constArgs[i];
		}
		
		var userCallback = arguments[arguments.length - 1];
		if(typeof userCallback != 'function') {
			userCallback = null;
		}
		
		var req = {"method": method};
		if(method == "GET") {
			req.qs = form;
		} else {
			req.form = form;
		}
		
		var self = this;
		this._apiRequest(endpoint, req, function(err, response, body) {
			self[callback](err, body, userCallback);
		});
	};
};

reddit._addListingRequest = function(name, endpoint, path, args) {
	reddit.prototype[name] = function() {
		var options;
		var callback;
		if(arguments.length == 0) {
			options = {};
			callback = null;
		} else if(arguments.length == 1 && typeof arguments[0] == 'object') {
			options = arguments[0];
			callback = null;
		} else if(arguments.length == 1 && typeof arguments[0] == 'function') {
			options = {};
			callback = arguments[0];
		} else {
			options = arguments[0];
			callback = arguments[1];
		}
		
		var requestPath = '';
		if(options && options.r) {
			requestPath = "/r/" + options.r;
		}
		
		if(path) {
			requestPath += path;
		}
		
		var qs = {};
		qs.after = options.after;
		qs.before = options.before;
		qs.limit = options.limit;
		qs.count = options.count;
		qs.show = (options.all) ? "all" : undefined;
		
		if(args && options) {
			for(var i = 0; i < args.length; i++) {
				qs[args[i]] = options[args[i]];
			}
			
			if(args.indexOf("restrict_sr") != -1) {
				qs.restrict_sr = !!options.r;
			}
		}
		
		var self = this;
		this._apiRequest(endpoint, {"path": requestPath, "qs": qs}, function(err, response, body) {
			self._listing(err, body, callback);
		});
	};
};<commit_msg>Added ability to pass custom handler to _addListingRequest<commit_after>var reddit = global.reddit;

reddit._addSimpleRequest = function(name, endpoint, method, args, constArgs, callback) {
	reddit.prototype[name] = function() {
		var form;
		if(args.length > 0 || constArgs) {
			form = {};
		}
		
		for(var i = 0; i < args.length; i++) {
			form[args[i]] = arguments[i];
		}
		
		for(var i in constArgs) {
			form[i] = constArgs[i];
		}
		
		var userCallback = arguments[arguments.length - 1];
		if(typeof userCallback != 'function') {
			userCallback = null;
		}
		
		var req = {"method": method};
		if(method == "GET") {
			req.qs = form;
		} else {
			req.form = form;
		}
		
		var self = this;
		this._apiRequest(endpoint, req, function(err, response, body) {
			self[callback](err, body, userCallback);
		});
	};
};

reddit._addListingRequest = function(name, endpoint, path, args, cb) {
	reddit.prototype[name] = function() {
		var options;
		var callback;
		if(arguments.length == 0) {
			options = {};
			callback = null;
		} else if(arguments.length == 1 && typeof arguments[0] == 'object') {
			options = arguments[0];
			callback = null;
		} else if(arguments.length == 1 && typeof arguments[0] == 'function') {
			options = {};
			callback = arguments[0];
		} else {
			options = arguments[0];
			callback = arguments[1];
		}
		
		var requestPath = '';
		if(options && options.r) {
			requestPath = "/r/" + options.r;
		}
		
		if(path) {
			requestPath += path;
		}
		
		var qs = {};
		qs.after = options.after;
		qs.before = options.before;
		qs.limit = options.limit;
		qs.count = options.count;
		qs.show = (options.all) ? "all" : undefined;
		
		if(args && options) {
			for(var i = 0; i < args.length; i++) {
				qs[args[i]] = options[args[i]];
			}
			
			if(args.indexOf("restrict_sr") != -1) {
				qs.restrict_sr = !!options.r;
			}
		}
		
		if(!cb) {
			cb = "_listing";
		}
		
		var self = this;
		this._apiRequest(endpoint, {"path": requestPath, "qs": qs}, function(err, response, body) {
			self[cb](err, body, callback);
		});
	};
};
{'fraction_non_alphanumeric': 0.1746346296755016, 'fraction_numerical': 0.0069358434481050285, 'mean_word_length': 3.0460921843687374, 'pattern_counts': {'":': 6, '<': 7, '<?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': '1022238', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1406, 'n_words': 321}