<commit_before>/// <reference path="../promise.d.ts" />

import Promise = require("promise");

function partial(fn: Function, ...args: any[]) {
    return (..._args: any[]) => {
        return fn.apply(undefined, args.concat(_args));
    };
}

export function timeout(ms: number): Promise {
    return new Promise(resolve => {
        setTimeout(() => { resolve.call(undefined); }, ms);
    });
}

export function forEach(values: any[], executor: (value: any, index: number) => Promise): Promise {
    return new Promise((resolve, reject) => {
        if (values.length === 0) {
            return resolve.call(undefined);
        }
        var p, val,
            i = 0,
            len = values.length;

        p = Promise.resolve(undefined);

        for (; i < len; i++) {
            val = values[i];
            p = p.then(partial(executor, val, i), reject);
        }

        p.then(resolve, reject);
    });
}
<commit_msg>Avoid variable renaming if builded in extensions<commit_after>/// <reference path="../promise.d.ts" />

import P = require("promise");

function partial(fn: Function, ...args: any[]) {
    return (..._args: any[]) => {
        return fn.apply(undefined, args.concat(_args));
    };
}

export function timeout(ms: number): Promise {
    return new Promise(resolve => {
        setTimeout(() => { resolve.call(undefined); }, ms);
    });
}

export function forEach(values: any[], executor: (value: any, index: number) => Promise): Promise {
    return new Promise((resolve, reject) => {
        if (values.length === 0) {
            return resolve.call(undefined);
        }
        var p, val,
            i = 0,
            len = values.length;

        p = Promise.resolve(undefined);

        for (; i < len; i++) {
            val = values[i];
            p = p.then(partial(executor, val, i), reject);
        }

        p.then(resolve, reject);
    });
}

{'fraction_non_alphanumeric': 0.17115689381933438, 'fraction_numerical': 0.0021130480718436345, 'mean_word_length': 2.2265758091993186, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '4007274', 'n_tokens_mistral': 562, 'n_tokens_neox': 553, 'n_words': 146}