<commit_before>var https = require('https');
var querystring = require('querystring');

(function(){
	var Streak = {};

	//expose to global
	if (typeof exports !== 'undefined') {
	    if (typeof module !== 'undefined' && module.exports) {
	      exports = module.exports = Streak;
	    }
	    exports.StreakAPI = Streak;
	}
	else {
		root['StreakAPI'] = Streak;
	}

	//private members and functions
	var _authKey;

	function _getRequestOptions(path){
		return {
			host: 'mailfoogae.appspot.com',
			path: '/api/v1/' + path,
			auth: _authKey
		};
	}

	function _requestCallback(cb, errCb, noParse){
		return function(response){
			var str = '';
			response.on('data', function(chunk){
				str += chunk;
			});

			response.on('end', function(){
				if(cb){
					if(!noParse){
						try{
							cb(JSON.parse(str));
						}
						catch(err){
							cb(str);
						}

					}
					else{
						cb(str);
					}

				}
			});

			response.on('error', function(error){
				if(errCb){
					return errCb(error);
				}
			})
		}
	}

	function _get(path, cb, errCb, noParse){
		var opts = _getRequestOptions(path);
		var request = https.request(opts, _requestCallback(cb, errCb, noParse));
		request.end();
	}

	function _put(path, data, cb, errCb){
		var dstr = querystring.stringify(data);
		var opts = _getRequestOptions(path + "?" + dstr);
		opts.method = "PUT";

		var request = https.request(opts, _requestCallback(cb, errCb));

		request.end();
	}

	function _delete(path, cb, errCb){
		var opts = _getRequestOptions(path);
		opts.method = "DELETE";
		var request = https.request(opts, _requestCallback(cb, errCb));
		request.end();
	}

	function _post(path, data, cb, errCb){
		var dstr = JSON.stringify(data);
		var opts = _getRequestOptions(path);

		opts.method = "POST";
		opts.headers = {
			'Content-Type': 'application/json',
			'Content-Length': dstr.length
		}

		var request = https.request(opts, _requestCallback(cb, errCb));

		request.write(dstr);
		request.end();
	}
<commit_msg>Added the errCb to the https request 'error' event.<commit_after>var https = require('https');
var querystring = require('querystring');

(function(){
	var Streak = {};

	//expose to global
	if (typeof exports !== 'undefined') {
	    if (typeof module !== 'undefined' && module.exports) {
	      exports = module.exports = Streak;
	    }
	    exports.StreakAPI = Streak;
	}
	else {
		root['StreakAPI'] = Streak;
	}

	//private members and functions
	var _authKey;

	function _getRequestOptions(path){
		return {
			host: 'mailfoogae.appspot.com',
			path: '/api/v1/' + path,
			auth: _authKey
		};
	}

	function _requestCallback(cb, errCb, noParse){
		return function(response){
			var str = '';
			response.on('data', function(chunk){
				str += chunk;
			});

			response.on('end', function(){
				if(cb){
					if(!noParse){
						try{
							cb(JSON.parse(str));
						}
						catch(err){
							cb(str);
						}

					}
					else{
						cb(str);
					}

				}
			});

			response.on('error', function(error){
				if(errCb){
					return errCb(error);
				}
			})
		}
	}

	function _get(path, cb, errCb, noParse){
		var opts = _getRequestOptions(path);
		var request = https.request(opts, _requestCallback(cb, errCb, noParse));
		request.on('error', errCb)
		request.end();
	}

	function _put(path, data, cb, errCb){
		var dstr = querystring.stringify(data);
		var opts = _getRequestOptions(path + "?" + dstr);
		opts.method = "PUT";

		var request = https.request(opts, _requestCallback(cb, errCb));
		
		request.on('error', errCb)
		request.end();
	}

	function _delete(path, cb, errCb){
		var opts = _getRequestOptions(path);
		opts.method = "DELETE";
		var request = https.request(opts, _requestCallback(cb, errCb));
		request.on('error', errCb)
		request.end();
	}

	function _post(path, data, cb, errCb){
		var dstr = JSON.stringify(data);
		var opts = _getRequestOptions(path);

		opts.method = "POST";
		opts.headers = {
			'Content-Type': 'application/json',
			'Content-Length': dstr.length
		}

		var request = https.request(opts, _requestCallback(cb, errCb));

		request.write(dstr);
		request.on('error', errCb)
		request.end();
	}

{'fraction_non_alphanumeric': 0.16022232962783953, 'fraction_numerical': 0.0004833252779120348, 'mean_word_length': 3.214867617107943, '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': '279908', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1444, 'n_words': 310}