<commit_before>// Useful functions
var util = {
	each: function( data, callback ) {
		// Array
		if( typeof( data.length ) == 'number' ) {
			for( var i = 0; i < data.length; i++ ) {
				callback( i, data[i] );
			}
			return;
		}
		// Object
		for( key in data ) {
			callback( key, data[key] );
		}
	},

	ajax: function( method, url, options ) {
		var req = new XMLHttpRequest();
		req.onreadystatechange = function() {
			if( req.readyState == 4 ) {
				if( req.status != 200 )
					return options.error( req.status, 'Bad HTTP response' );

				try {
					var data = JSON.parse( req.responseText );
					return options.success( req.status, data );
				} catch( e ) {
					return options.error( req.status, e.message );
				}
			}
		}
		req.open( method, url, options.async ? true : false );
		req.send();
	},

	approach: function( start, finish, step, callback ) {

	}
};

// Set an elements style
// data = { style_name: style_value }
Element.prototype.css = function( data ) {
	for( key in data ) {
		this.style.setProperty( key, data[key] );
	}
}
// Animate an element
Element.prototype.animate = function( duration, data ) {
	console.log('hi');
}<commit_msg>Add Object.search, Object.each, Array.each, remove uti.each<commit_after>// Useful functions
var util = {
	ajax: function( method, url, options ) {
		var req = new XMLHttpRequest();
		req.onreadystatechange = function() {
			if( req.readyState == 4 ) {
				if( req.status != 200 )
					return options.error( req.status, 'Bad HTTP response' );

				try {
					var data = JSON.parse( req.responseText );
					return options.success( req.status, data );
				} catch( e ) {
					return options.error( req.status, e.message );
				}
			}
		}
		req.open( method, url, options.async ? true : false );
		req.send();
	},

	approach: function( start, finish, step, func ) {

	}
};

// Set an elements style
// data = { style_name: style_value }
Element.prototype.css = function( data ) {
	for( key in data ) {
		this.style.setProperty( key, data[key] );
	}
}
// Animate an element
Element.prototype.animate = function( duration, data ) {
	console.log('hi');
}


// Loop array
Array.prototype.each = function( each_func ) {
	for( var i=0; i<this.length; i++ ) {
		each_func( i, this[i] );
	}
}


// Loop object
Object.prototype.each = function( each_func ) {
	for( key in this ) {
		if( this.hasOwnProperty( key ) ) {
			each_func( key, this[key] );
		}
	}
}
// Search object
Object.prototype.search = function( search_func ) {
	var found_key;
	this.each( function( key, value ) {
		if( search_func( key, value, found_key ) ) {
			found_key = key;
		}
	});
	
	return this[found_key] || null;
}
{'fraction_non_alphanumeric': 0.15678126180581792, 'fraction_numerical': 0.0037778617302606727, 'mean_word_length': 2.9229629629629628, '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': '577332', 'n_tokens_mistral': 1037, 'n_tokens_neox': 908, 'n_words': 244}