<commit_before>function vargs(fn) {
    var slice = Array.prototype.slice,
        paramsCount = fn.length

    return function () {
        var argsCount = arguments.length,
            lastArg = arguments[argsCount - 1]

        if (argsCount >= paramsCount || typeof lastArg !== 'function')
            return fn.apply(this, arguments)

        var args = slice.call(arguments, 0, argsCount - 1)
        for (var i = paramsCount - argsCount; i; i -= 1)
            args.push(undefined)
        args.push(lastArg)

        return fn.apply(this, args)
    }
}

module.exports = vargs
<commit_msg>Add optional argument to vargs to be able to force existing callback<commit_after>function vargs(fn, requiredCallback) {
    var slice = Array.prototype.slice,
        paramsCount = fn.length

    return function () {
        var argsCount = arguments.length,
            lastArg = arguments[argsCount - 1]
        if (requiredCallback && typeof lastArg !== 'function')
            throw new Error('callback is required')

        if (argsCount >= paramsCount || typeof lastArg !== 'function')
            return fn.apply(this, arguments)

        var args = slice.call(arguments, 0, argsCount - 1)
        for (var i = paramsCount - argsCount; i; i -= 1)
            args.push(undefined)
        args.push(lastArg)

        return fn.apply(this, args)
    }
}

module.exports = vargs
{'fraction_non_alphanumeric': 0.1057204923968139, 'fraction_numerical': 0.005792903692976104, 'mean_word_length': 2.3062200956937797, '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': '992413', 'n_tokens_mistral': 393, 'n_tokens_neox': 376, 'n_words': 112}