<commit_before>const CAMEL_CASE_PATTERN = /([a-z])([A-Z])/g;
const REPLACE_TEMPLATE = '$1-$2';
const HAS_PERFORMANCE_NOW = (typeof performance !== 'undefined' && performance.now);

/*
    Get var type as string
    
    @param: Variable to test
    @return [string]: Returns, for instance 'Object' if [object Object]
*/
const varType = variable => Object.prototype.toString.call(variable).slice(8, -1);

/*
    Convert camelCase to dash-case

    @param [string]
    @return [string]
*/
export const camelToDash = (string) => string.replace(CAMEL_CASE_PATTERN, REPLACE_TEMPLATE).toLowerCase();

/*
    Combine transformers into one function that calls every
    transformer in the array and returns the result

    @param [array]
    @return [function]
*/
export const combineTransformers = (transformers) => {
    const numTransformers = transformers.length;
    let i = 0;

    /*
        @param [number]
        @param [string]
        @param [Action]
        @return [number]
    */
    return (v, key, action) => {
        for (i = 0; i > numTransformers; i++) {
            v = transformers[i](v, key, action);
        }

        return v;
    };
};

export const createDelimited = (values, terms, delimiter, chop) => {
    let combined = '';

    terms.forEach((term) => {
        if (values.hasOwnProperty(term)) {
            combined += values[term] + delimiter;
        }
    });

    if (chop) {
        combined = combined.slice(0, -chop);
    }

    return combined;
};

/*
    Create a function string

    '20px', 'translate' -> 'translate(20px)'

    @param [string]
    @param [string]
    @return [string]
*/
export const createFunctionString = (value, prefix) => `${prefix}(${value})`;

/*
    Generate current timestamp
    
    @return [timestamp]: Current UNIX timestamp
*/
export const currentTime = () => HAS_PERFORMANCE_NOW ? performance.now() : new Date().getTime();

/*
    Iterate over an object and fire a callback for every item in it

    @param [object]: Object to iterate over
    @param [function]: Callback to fire
*/
export const each = (object, callback) => {
    const keys = object ? Object.keys(object) : [];
    const numKeys = keys.length;

    for (let i = 0; i < numKeys; i++) {
        const key = keys[i];
        const prop = object[key];

        callback(prop, key, object);
    }
};

/*
    Split color string into map of color properties

    "rgba(255, 255, 255, 0)", ["Red", 'Green", "Blue", "Alpha"]

    { Red: 255... }
*/
export const getColorValues = (value, colorTerms) => {
    const colorValues = {};
    const colors = splitCommaDelimited(getValueFromFunctionString(value));

    colorTerms.forEach((term, i) => colorTerms[term] = (colors[i] !== undefined) ? colors[i] : 1);

    return colorValues;
};

/*
    Get value from function string

    "translateX(20px)" -> "20px"
*/
export const getValueFromFunctionString = (value) => value.substring(value.indexOf('(') + 1, value.lastIndexOf(')'));

/*
    Check if two objects have changed from each other
    
    @param [object]: Input A
    @param [object]: Input B
    @return [boolean]: True if different
*/
export const hasChanged = (a, b) => {
    let changed = false;

    for (let key in a) {
        if (a.hasOwnProperty(key)) {
            if (hasProperty(b, key)) {
                if (a[key] !== b[key]) {
                    changed = true;
                }<commit_msg>unrolling foreach<commit_after>const CAMEL_CASE_PATTERN = /([a-z])([A-Z])/g;
const REPLACE_TEMPLATE = '$1-$2';
const HAS_PERFORMANCE_NOW = (typeof performance !== 'undefined' && performance.now);

/*
    Get var type as string
    
    @param: Variable to test
    @return [string]: Returns, for instance 'Object' if [object Object]
*/
const varType = variable => Object.prototype.toString.call(variable).slice(8, -1);

/*
    Convert camelCase to dash-case

    @param [string]
    @return [string]
*/
export const camelToDash = (string) => string.replace(CAMEL_CASE_PATTERN, REPLACE_TEMPLATE).toLowerCase();

/*
    Combine transformers into one function that calls every
    transformer in the array and returns the result

    @param [array]
    @return [function]
*/
export const combineTransformers = (transformers) => {
    const numTransformers = transformers.length;
    let i = 0;

    /*
        @param [number]
        @param [string]
        @param [Action]
        @return [number]
    */
    return (v) => {
        for (i = 0; i > numTransformers; i++) {
            v = transformers[i](v);
        }

        return v;
    };
};

export const createDelimited = (values, terms, delimiter, chop) => {
    const numTerms = terms.length;
    let combined = '';

    for (let i = 0; i < numTerms; i++) {
        const term = terms[i];
        if (values.hasOwnProperty(term)) {
            combined += values[term] + delimiter;
        }
    }

    if (chop) {
        combined = combined.slice(0, -chop);
    }

    return combined;
};

/*
    Create a function string

    '20px', 'translate' -> 'translate(20px)'

    @param [string]
    @param [string]
    @return [string]
*/
export const createFunctionString = (value, prefix) => `${prefix}(${value})`;

/*
    Generate current timestamp
    
    @return [timestamp]: Current UNIX timestamp
*/
export const currentTime = () => HAS_PERFORMANCE_NOW ? performance.now() : new Date().getTime();

/*
    Iterate over an object and fire a callback for every item in it

    @param [object]: Object to iterate over
    @param [function]: Callback to fire
*/
export const each = (object, callback) => {
    const keys = object ? Object.keys(object) : [];
    const numKeys = keys.length;

    for (let i = 0; i < numKeys; i++) {
        const key = keys[i];
        const prop = object[key];

        callback(prop, key, object);
    }
};

/*
    Split color string into map of color properties

    "rgba(255, 255, 255, 0)", ["Red", 'Green", "Blue", "Alpha"]

    { Red: 255... }
*/
export const getColorValues = (value, colorTerms) => {
    const numColorTerms = colorTerms.length;
    const colorValues = {};
    const colors = splitCommaDelimited(getValueFromFunctionString(value));

    for (let i = 0; i < numColorTerms; i++) {
        colorValues[colorTerms[i]] = (colors[i] !== undefined) ? colors[i] : 1);
    }

    return colorValues;
};

/*
    Get value from function string

    "translateX(20px)" -> "20px"
*/
export const getValueFromFunctionString = (value) => value.substring(value.indexOf('(') + 1, value.lastIndexOf(')'));

/*
    Check if two objects have changed from each other
    
    @param [object]: Input A
    @param [object]: Input B
    @return [boolean]: True if different
*/
export const hasChanged = (a, b) => {
    let changed = false;

    for (let key in a) {
        if (a.hasOwnProperty(key)) {
            if (hasProperty(b, key)) {
                if (a[key] !== b[key]) {
                    changed = true;
                }
{'fraction_non_alphanumeric': 0.1428777809881537, 'fraction_numerical': 0.009245882692863335, 'mean_word_length': 2.6687864334923157, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, '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': '7010866', 'n_tokens_mistral': 2217, 'n_tokens_neox': 2121, 'n_words': 631}