<commit_before>const isArray = Array.isArray;

export interface Enumerable {
    [key: string]: any;
    [kye: number]: any;
}

const strip = function (input: string): string {
    return input.replace(/^\s+|\s+$/g, '');
}

const startWith = function (input: string, prefix: string): boolean {
    return input.indexOf(prefix) === 0;
}

/**
 * Test if a string ends with a given suffix.
 * @param  {string} str    String to test against.
 * @param  {string} suffix Suffix to check for.
 * @return {boolean}
 */
const endsWith = function (str: string, suffix: string) {
    return str.indexOf(suffix, str.length - suffix.length) !== -1;
};


const each = function (obj: Enumerable, fn: Function, context?) {
    let i, l;

    if (isArray(obj)) {
        i = 0;
        l = obj.length;
        for (i; i < l; i += 1) {
            if (context ? fn.call(context, obj[i], i, obj) === false : fn(obj[i], i, obj) === false) {
                break;
            }
        }
    } else {
        for (i in obj) {
            if (obj.hasOwnProperty(i)) {
                if (context ? fn.call(context, obj[i], i, obj) === false : fn(obj[i], i, obj) === false) {
                    break;
                }
            }
        }
    }

    return obj;
}

/**
 * Test ig an item in an enumerable matches your conditions.
 * 
 * @param {Enumerable}    obj     Enumerable object.
 * @param {Function }       fn      Executed for each item. Return if you condition is met. 
 */
const some = function (obj: Enumerable, fn: Function): boolean {
    let i = 0,
        result,
        l;

    if (isArray(obj)) {
        l = obj.length;
        for (i; i < l; i += 1) {
            result = fn(obj[i], i, obj);
            if (result) {
                break;
            }
        }
    } else {
        each(obj, function (value: any, index: number) {
            result = fn(value, index, obj);
            return !(result);
        })
    }

    return !!result;
}

const map = function (obj: Enumerable, fn: Function) {
    let result = [];

    if (isArray(obj)) {
        for (let i = 0, l = obj.length; i < l; i += 1) {
            result[i] = fn(obj[i], i, obj);
        }
    } else {
        for (let i in obj) {
            if (obj.hasOwnProperty(i)) {
                result[i] = fn(obj[i], i);
            }
        }
    }

    return result;
}

const extend = function (...args: any[]) {
    let target = args[0];
    let objs = (args.length > 1) ? Array.prototype.slice.call(args, 1) : [];

    for (let i = 0; i < objs.length; i++) {
        let obj = objs[i] || {};
        for (let key in obj) {
            if (obj.hasOwnProperty(key)) {
                (target as any)[key] = obj[key];
            }
        }
    }

    return target;
}

const keys = function (obj: any) {
    if (!obj) {
        return [];
    }

    if (Object.keys) {
        return Object.keys(obj);
    }

    return map(obj, function (v: any, k: any) {
        return k;
    })
}


/**
 * Throw an error with possiable line number and source file.
 * @param message Error message
 * @param line Line number in template.
 * @param file Template file the error occured in.
 * @throws No seriously, the point is to throw an error.
 */
const throwError = function (message: string, line?: string | number, file?: string): Error {
    if (line) {
        message += ' on line ' + line;
    }

    if (file) {
        message += ' in file ' + file;
    }

    throw new Error(message + '.');
}


export default {
    isArray: isArray,
    each: each,
    some: some,
    map: map,
    keys: keys,
    extend: extend,
    strip: strip,
    startWith: startWith,
    endsWith: endsWith,
    throwError: throwError
}<commit_msg>refactor(utils): Change export methos.<commit_after>const isArray = Array.isArray;

export interface Enumerable {
    [key: string]: any;
    [kye: number]: any;
}

const strip = function (input: string): string {
    return input.replace(/^\s+|\s+$/g, '');
}

const startWith = function (input: string, prefix: string): boolean {
    return input.indexOf(prefix) === 0;
}

/**
 * Test if a string ends with a given suffix.
 * @param  {string} str    String to test against.
 * @param  {string} suffix Suffix to check for.
 * @return {boolean}
 */
const endsWith = function (str: string, suffix: string) {
    return str.indexOf(suffix, str.length - suffix.length) !== -1;
};


const each = function (obj: Enumerable, fn: Function, context?) {
    let i, l;

    if (isArray(obj)) {
        i = 0;
        l = obj.length;
        for (i; i < l; i += 1) {
            if (context ? fn.call(context, obj[i], i, obj) === false : fn(obj[i], i, obj) === false) {
                break;
            }
        }
    } else {
        for (i in obj) {
            if (obj.hasOwnProperty(i)) {
                if (context ? fn.call(context, obj[i], i, obj) === false : fn(obj[i], i, obj) === false) {
                    break;
                }
            }
        }
    }

    return obj;
}

/**
 * Test ig an item in an enumerable matches your conditions.
 * 
 * @param {Enumerable}    obj     Enumerable object.
 * @param {Function }       fn      Executed for each item. Return if you condition is met. 
 */
const some = function (obj: Enumerable, fn: Function): boolean {
    let i = 0,
        result,
        l;

    if (isArray(obj)) {
        l = obj.length;
        for (i; i < l; i += 1) {
            result = fn(obj[i], i, obj);
            if (result) {
                break;
            }
        }
    } else {
        each(obj, function (value: any, index: number) {
            result = fn(value, index, obj);
            return !(result);
        })
    }

    return !!result;
}

const map = function (obj: Enumerable, fn: Function) {
    let result = [];

    if (isArray(obj)) {
        for (let i = 0, l = obj.length; i < l; i += 1) {
            result[i] = fn(obj[i], i, obj);
        }
    } else {
        for (let i in obj) {
            if (obj.hasOwnProperty(i)) {
                result[i] = fn(obj[i], i);
            }
        }
    }

    return result;
}

const extend = function (...args: any[]) {
    let target = args[0];
    let objs = (args.length > 1) ? Array.prototype.slice.call(args, 1) : [];

    for (let i = 0; i < objs.length; i++) {
        let obj = objs[i] || {};
        for (let key in obj) {
            if (obj.hasOwnProperty(key)) {
                (target as any)[key] = obj[key];
            }
        }
    }

    return target;
}

const keys = function (obj: any) {
    if (!obj) {
        return [];
    }

    if (Object.keys) {
        return Object.keys(obj);
    }

    return map(obj, function (v: any, k: any) {
        return k;
    })
}


/**
 * Throw an error with possiable line number and source file.
 * @param message Error message
 * @param line Line number in template.
 * @param file Template file the error occured in.
 * @throws No seriously, the point is to throw an error.
 */
const throwError = function (message: string, line?: string | number, file?: string): Error {
    if (line) {
        message += ' on line ' + line;
    }

    if (file) {
        message += ' in file ' + file;
    }

    throw new Error(message + '.');
}


export default {
    isArray,
    each,
    some,
    map,
    keys,
    extend,
    strip,
    startWith,
    endsWith,
    throwError
}
{'fraction_non_alphanumeric': 0.1450537488093618, 'fraction_numerical': 0.003265750442237039, 'mean_word_length': 1.795739825028528, 'pattern_counts': {'":': 0, '<': 11, '<?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': '5343116', 'n_tokens_mistral': 2393, 'n_tokens_neox': 2325, 'n_words': 751}