<commit_before>module.exports = timeoutPromise;

function timeoutPromise(time) {
    return new Promise(function (resolve) {
        setTimeout(resolve, time);
    });
}

async function test4(args1, args2 = 0) {
    if (args1.tick && typeof args2 === 'number') {
        args1.tick(args2)
    }
    else if (typeof args1 === 'number') {
        await new Promise(resolve => {
            setTimeout(() => {
            resolve()
        }, clockOrTime);
    });
    }
    
    for (let i = 0; i <= 20; i++) {
        await new Promise(resolve => {
            resolve();
    })
    }
}<commit_msg>timeoutPromise<commit_after>module.exports = timeoutPromise;

function timeoutPromise(args1, args2) {
    var clock;
    var time;
    if (args1 && args1.tick) {
        clock = args1;
        time = args2 || 0;
    }
    else {
        time = args1 || 0;
    }
    var chain = Promise.resolve();
    if (!clock) {
        chain = chain.then(function () {
            return new Promise(function (resolve) {
                setTimeout(function () {
                    resolve();
                }, time);
            })
        });
    }
    else {
        chain = chain.then(function () {
            clock.tick(time);
            return Promise.resolve();
        });
    }
    for (var i = 0; i < 19; i++) {
        chain = chain.then(function () {
            return Promise.resolve();
        })
    }
    return chain;
}
{'fraction_non_alphanumeric': 0.1404494382022472, 'fraction_numerical': 0.016853932584269662, 'mean_word_length': 1.6437847866419295, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '6097361', 'n_tokens_mistral': 424, 'n_tokens_neox': 415, 'n_words': 97}