<commit_before>'use strict';

module.exports = function (opts, cb) {
    if (typeof opts === 'function') {
        cb = opts;
        opts = {};
    }

    opts.debounce = opts.debounce || 0;
    opts.timeout = opts.timeout || 200;

    var batch = [];

    function flush() {
        if (!batch.length) { return; }
        var _batch = batch;
        batch = [];
        process.nextTick(cb.bind(null, _batch));

    }

    var timeout;

    return function (event) {
        batch.push(event);
        if (timeout) { clearTimeout(timeout); }

        if (opts.limit && batch.length >= opts.limit) {
            flush();
            return;
        }

        timeout = setTimeout(flush, opts.timeout);
    };
};
<commit_msg>Added check for callback<commit_after>'use strict';

module.exports = function (opts, cb) {
    if (typeof opts === 'function') {
        cb = opts;
        opts = {};
    }

    if (typeof cb !== 'function') {
        throw new Error('Provided callback is not a function: ' + callback.toString());
    }

    opts.debounce = opts.debounce || 0;
    opts.timeout = opts.timeout || 200;

    var batch = [];

    function flush() {
        if (!batch.length) { return; }
        var _batch = batch;
        batch = [];
        process.nextTick(cb.bind(null, _batch));
    }

    var timeout;

    return function (event) {
        batch.push(event);
        if (timeout) { clearTimeout(timeout); }

        if (opts.limit && batch.length >= opts.limit) {
            flush();
            return;
        }

        timeout = setTimeout(flush, opts.timeout);
    };
};

{'fraction_non_alphanumeric': 0.1475204017576899, 'fraction_numerical': 0.005021971123666039, 'mean_word_length': 1.9034608378870674, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '429381', 'n_tokens_mistral': 488, 'n_tokens_neox': 461, 'n_words': 116}