<commit_before>var _ = require('lodash');
var events = require('./events');
var safeJSONParse = require('./util').safeParse;
var util = require('util');
var makeHostPort = require('./util').makeHostPort;

function errDetails(details) {
    return {error:{details:details}};
}

function wait(millis) {
    var f = _.once(function wait(list, cb) {
            setTimeout(function() { cb(list); }, millis);
    });
    f.callerName = 'wait';
    return f;
}

// test if object conforms to the spec.
// @param name name of the object being tested for better messages on failure.
// @param spec is an object where keys have a value of true or false. True meaning mandatory, false meaning optional.
// @param obj object to test against the spec
function testFields(t, tc, name, spec, obj) {
    var keys = Object.keys(spec);

    // create arrays for mandatory and allowed fields
    var mandatory = keys.filter(function (key) {
        return spec[key] === true;
    });
    var allowed = keys;

    mandatory.forEach(function (key) {
        t.ok(
            key in obj,
            "test mandatory field '" + key + "' in '" + name + "'",
            errDetails({
                message: "missing field in " + name + " message: " + key,
                object: obj
            })
        );
    });

    Object.keys(obj).forEach(function (key) {
        t.notEqual(
            allowed.indexOf(key), -1,
            "test field '" + key + "' in '" + name + "'",
            errDetails({
                message: "unknown field in " + name + " message: " + key,
                object: obj
            })
        );
    });
}

function waitForJoins(t, tc, n) {
    n = _.min([6, n]);
    return function waitForJoins(list, cb) {
        var joins = _.filter(list, {type: events.Types.Join});
        if (joins.length < n) {
            cb(null);
            return;
        }
        
        t.equals(joins.length, n, 'check number of joins', 
            errDetails({journal: _.pluck(list, 'endpoint')}));
<commit_msg>Remove unused code.<commit_after>var _ = require('lodash');
var events = require('./events');
var safeJSONParse = require('./util').safeParse;
var util = require('util');
var makeHostPort = require('./util').makeHostPort;

function errDetails(details) {
    return {error:{details:details}};
}

function wait(millis) {
    var f = _.once(function wait(list, cb) {
            setTimeout(function() { cb(list); }, millis);
    });
    f.callerName = 'wait';
    return f;
}

function waitForJoins(t, tc, n) {
    n = _.min([6, n]);
    return function waitForJoins(list, cb) {
        var joins = _.filter(list, {type: events.Types.Join});
        if (joins.length < n) {
            cb(null);
            return;
        }
        
        t.equals(joins.length, n, 'check number of joins', 
            errDetails({journal: _.pluck(list, 'endpoint')}));

{'fraction_non_alphanumeric': 0.14867688022284123, 'fraction_numerical': 0.0010445682451253482, 'mean_word_length': 2.264772727272727, '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': '1321903', 'n_tokens_mistral': 856, 'n_tokens_neox': 846, 'n_words': 242}