<commit_before>/** Returns an array with the names of the direct names of a function (e.g. for the function a = (b, c) => {}
 *  getFunctionArgNames(a) will return ["b", "c"]).
 *
 *  Credit: https://davidwalsh.name/javascript-arguments
 */
const getFunctionArgNames = (func) => {
    const args = func.toString().match(/function\s.*?\(([^)]*)\)/)[1];
    return args
        .split(',')
        .map(function (arg) {
            return arg.replace(/\/\*.*\*\//, '').trim();
        })
        .filter(function (arg) {
            return arg;
        });
};

/** Returns an array with the names of the INDIRECT names of the fields of a function's argument object
 *  (e.g. for the function a = (b, c) => {}
  */
const getFunctionRefsNames = (func, ref) => {
    const pattern = new RegExp(ref + "\\.([a-zA-Z0-9_]+)[\\,\\;]", 'g');
    const args = func.toString().match(pattern);
    return args && args.map( arg => arg.slice(ref.length + 1, arg.length - 1));
};

export default {
    getArgs: getFunctionArgNames,
    getRefs: getFunctionRefsNames,
};<commit_msg>Logging arg to refs, for debugging what happens in a minified/uglified app.<commit_after>/** Returns an array with the names of the direct names of a function (e.g. for the function a = (b, c) => {}
 *  getFunctionArgNames(a) will return ["b", "c"]).
 *
 *  Credit: https://davidwalsh.name/javascript-arguments
 */
const getFunctionArgNames = (func) => {
    const args = func.toString().match(/function\s.*?\(([^)]*)\)/)[1];
    return args
        .split(',')
        .map(function (arg) {
            return arg.replace(/\/\*.*\*\//, '').trim();
        })
        .filter(function (arg) {
            return arg;
        });
};

/** Returns an array with the names of the INDIRECT names of the fields of a function's argument object
 *  (e.g. for the function a = (b, c) => {}
  */
const getFunctionRefsNames = (func, ref) => {
    console.log("func:", func.toString);
    console.log("ref:", JSON.stringify(ref));
    const pattern = new RegExp(ref + "\\.([a-zA-Z0-9_]+)[\\,\\;]", 'g');
    const args = func.toString().match(pattern);
    console.log("args:", JSON.stringify(args));
    return args && args.map( arg => arg.slice(ref.length + 1, arg.length - 1));
};

export default {
    getArgs: getFunctionArgNames,
    getRefs: getFunctionRefsNames,
};
{'fraction_non_alphanumeric': 0.19182795698924732, 'fraction_numerical': 0.004301075268817204, 'mean_word_length': 2.7759740259740258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '4297806', 'n_tokens_mistral': 761, 'n_tokens_neox': 747, 'n_words': 213}