<commit_before>var Replayer = function(obj) {
    this.record = [];
    var self = this;
	for (var k in obj) {
		if (typeof obj[k] === 'function') {
            // Close on k.
            (function () {
                var fnName = k;
                self[fnName] = function() {
                    var args = Array.prototype.slice.call(arguments);
                    self.record.push([ fnName, args ]);
                    var result = obj[fnName].call(obj, args);
                    return result === obj ? self : result;
                };
            })();
		}
	}
};

Replayer.prototype.replay = function(newSelf) {
    var results = [];
    for (var idx in this.record) {
        var curMethod = this.record[idx][0];
        var curArgs = this.record[idx][1];
        results.push(newSelf[curMethod].call(newSelf, curArgs));
    }

    return results;
};

module.exports.watch = function(obj) { return new Replayer(obj); };<commit_msg>Adding console logging to try and trap errors in client code<commit_after>var Replayer = function(obj) {
    this.record = [];
    var self = this;
	for (var k in obj) {
		if (typeof obj[k] === 'function') {
            // Close on k.
            (function () {
                var fnName = k;
                self[fnName] = function() {
                    var args = Array.prototype.slice.call(arguments);
                    self.record.push([ fnName, args ]);
                    var result = obj[fnName].call(obj, args);
                    console.log('Recording ' + fnName + ': result = ' + result);
                    return result === obj ? self : result;
                };
            })();
		}
	}
};

Replayer.prototype.replay = function(newSelf) {
    var results = [];
    for (var idx in this.record) {
        var curMethod = this.record[idx][0];
        var curArgs = this.record[idx][1];
        var curResult = newSelf[curMethod].call(newSelf, curArgs);
        console.log('Replaying ' + curMethod + ': result = ' + curResult);
        results.push(curResult);
    }

    return results;
};

module.exports.watch = function(obj) { return new Replayer(obj); };
{'fraction_non_alphanumeric': 0.14043355325164938, 'fraction_numerical': 0.001885014137606032, 'mean_word_length': 1.8119205298013246, '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': '1486185', 'n_tokens_mistral': 628, 'n_tokens_neox': 602, 'n_words': 149}