<commit_before>// Asynchronous operations
var Async = (function() {
    
    // Extend functions with "map" and "then" methods 
    Function.prototype.map = function(applied) {

	if (typeof applied != "function") {
	    var key = applied;
	    applied = function(obj) { return obj[key]; }
	}

	var self = this;
	return function(callback) {
	    self(function(){ callback(applied.apply(this,arguments)); });
	}
    };
    
    Function.prototype.then = function(callback) {
	if (callback) 
	    this(function() { callback() });    
	else
	    this(function() {});
    };

    // Extend arrays with "then" methods
    Array.prototype.then = function(callback) {
	var left = this.length;
	for (var i = 0; i < this.length; ++i) 
	    this[i].then(function(){ if (--left == 0) callback(); });
    };
<commit_msg>Have Array.then() provide the values<commit_after>// Asynchronous operations
var Async = (function() {
    
    // Extend functions with "map" and "then" methods 
    Function.prototype.map = function(applied) {

	if (typeof applied != "function") {
	    var key = applied;
	    applied = function(obj) { return obj[key]; }
	}

	var self = this;
	return function(callback) {
	    self(function(){ callback(applied.apply(this,arguments)); });
	}
    };
    
    Function.prototype.then = function(callback) {
	if (callback) 
	    this(function() { callback() });    
	else
	    this(function() {});
    };

    // Extend arrays with "then" methods
    Array.prototype.then = function(callback) {
	var left = this.length, result = [], self = this;
	for (var i = 0; i < this.length; ++i) 
	    (function(i){ 
		self[i].then(function(r){ 
		    result[i] = r;
		    if (--left == 0) callback.apply(this,result); 
		});
	    })(i);
    };

{'fraction_non_alphanumeric': 0.16427340608845492, 'fraction_numerical': 0.0022975301550832855, 'mean_word_length': 2.871111111111111, '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': '1159877', 'n_tokens_mistral': 583, 'n_tokens_neox': 540, 'n_words': 137}