<commit_before>/* global
	global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout, storage,
	TRUE,
	regexMatchBaseUrl,
	ClassPledge
*/

//=require constants.js
//=require shortcuts.js
//=require variables.js
//=require class/pledge.js

var ClassXhr = (function(XMLHttpRequest) {
	var XDomainRequest = 'XDomainRequest' in global && global.XDomainRequest || XMLHttpRequest;
	
	function checkState() {
		if(this.readyState < 4) {
			this.abort();
		}
	}
	
	return function ClassXhr(url) {
		var boundCheckState = checkState.bind(this),
			deferred        = ClassPledge.defer(),
			xhr             = regexMatchBaseUrl.test(url) ? new XMLHttpRequest() : new XDomainRequest(),
			timeout         = settings.timeout,
			pointer;

		xhr.ontimeout = xhr.onerror = xhr.onabort = function() {
			deferred.reject(xhr.status);
		};
		xhr.onprogress = xhr.onreadystatechange = function() {
			clearTimeout(pointer);

			pointer = setTimeout(boundCheckState, settings.timeout);
		};
		xhr.onload = function() {
			timeout = clearTimeout(timeout);

			if(!('status' in xhr) || xhr.status === 200) {
				deferred.resolve(xhr.responseText, xhr.getResponseHeader && xhr.getResponseHeader('content-type'));
			} else {
				deferred.reject(xhr.status);
			}
		};

		xhr.open('GET', url, TRUE);
		xhr.send();
		
		pointer = setTimeout(boundCheckState, settings.timeout);
		
		return deferred.pledge;
	};
}(XMLHttpRequest));<commit_msg>fix xhr timeout quirk<commit_after>/* global
	global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout, storage,
	TRUE,
	regexMatchBaseUrl,
	ClassPledge
*/

//=require constants.js
//=require shortcuts.js
//=require variables.js
//=require class/pledge.js

var ClassXhr = (function(XMLHttpRequest) {
	var XDomainRequest = 'XDomainRequest' in global && global.XDomainRequest || XMLHttpRequest;
	
	function checkState() {
		if(this.readyState < 4) {
			this.abort();
		}
	}
	
	return function ClassXhr(url) {
		var deferred        = ClassPledge.defer(),
			xhr             = regexMatchBaseUrl.test(url) ? new XMLHttpRequest() : new XDomainRequest(),
			boundCheckState = checkState.bind(xhr),
			timeout         = settings.timeout,
			pointer;

		xhr.ontimeout = xhr.onerror = xhr.onabort = function() {
			deferred.reject(xhr.status);
		};
		xhr.onprogress = xhr.onreadystatechange = function() {
			clearTimeout(pointer);

			pointer = setTimeout(boundCheckState, timeout);
		};
		xhr.onload = function() {
			pointer = clearTimeout(pointer);

			if(!('status' in xhr) || xhr.status === 200) {
				deferred.resolve(xhr.responseText, xhr.getResponseHeader && xhr.getResponseHeader('content-type'));
			} else {
				deferred.reject(xhr.status);
			}
		};

		xhr.open('GET', url, TRUE);
		xhr.send();
		
		pointer = setTimeout(boundCheckState, timeout);
		
		return deferred.pledge;
	};
}(XMLHttpRequest));
{'fraction_non_alphanumeric': 0.13893713094824592, 'fraction_numerical': 0.0027787426189649182, 'mean_word_length': 3.8484848484848486, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1951478', 'n_tokens_mistral': 1049, 'n_tokens_neox': 929, 'n_words': 184}