<commit_before>function diff(original, successor) {

    // get types
    var o_type = Object.prototype.toString.call(original);
    var s_type = Object.prototype.toString.call(successor);

    // reject when different types
    if (o_type !== s_type) {
        return false;
    }

    // compare two objects or arrays
    if (o_type === '[object Object]' || o_type === '[object Array]') {
        var keys = Object.keys(original);
        // TODO check for add opeation
        /*var new_keys = Object.keys(successor);*/
        return keys.reduce(function(accumulator, key) {
            var temp = diff(original[key], successor[key]);
            if (temp !== true) {
                if (typeof accumulator === 'boolean') {
                    accumulator = [];
                }
                if (temp === false) {
                    accumulator.push([key]);
                } else {
                    temp.forEach(function(current) {
                        current.unshift(key);
                        accumulator.push(current);
                    });
                }
            }
            return accumulator;
        }, true);
    }

    // compare primitive types
    return original === successor;

}

console.log(JSON.stringify(diff(
    {
        m:[
            1
        ],
        a:1,
        b:[
            0,
            'a',
            5,
            {
                a:3,
                b:{
                    c:{
                        d:{
                            e:1
                        },
                        x:0
                    }
                }
            }
        ],
        c:'aasdfdsfs',
        n: undefined,
        xx: 'sdsd'
    }, {
        m:{
            '0':1
        },
        a:3,
        b:[
            0,
            2,
            5,
            {
                a:3,
                b:{
                    c:{
                        d:{
                            e:12
                        },
                        x:1
                    }
                }
            }
        ],
        c:'aasdfdsfs',
        n: null,
        pp: ['a']
    }
)));<commit_msg>diff now checking additions<commit_after>function diff(original, successor) {

    // get types
    var o_type = Object.prototype.toString.call(original);
    var s_type = Object.prototype.toString.call(successor);

    // reject when different types
    if (o_type !== s_type) {
        return false;
    }

    // compare two objects or arrays
    if (o_type === '[object Object]' || o_type === '[object Array]') {
        var keys = Object.keys(original);
        var new_keys = Object.keys(successor);
        // creating union of both arrays of keys
        if (o_type === '[object Array]') {
            var length_difference = new_keys.length - keys.length;
            if (length_difference > 0) {
                for (let i = length_difference; i > 0 ; --i) {
                    keys.push(new_keys[new_keys.length - i]);
                }
            }
        } else {
            var keys_obj = {};
            keys.forEach(function(key) {
                keys_obj[key] = true;
            });
            new_keys.forEach(function(key) {
                if (!keys_obj[key]) {
                    keys.push(key);
                }
            });
        }
        return keys.reduce(function(accumulator, key) {
            var temp = diff(original[key], successor[key]);
            if (temp !== true) {
                if (typeof accumulator === 'boolean') {
                    accumulator = [];
                }
                if (temp === false) {
                    accumulator.push([key]);
                } else {
                    temp.forEach(function(current) {
                        current.unshift(key);
                        accumulator.push(current);
                    });
                }
            }
            return accumulator;
        }, true);
    }

    // compare primitive types
    return original === successor;

}

console.log(JSON.stringify(diff(
    {
        a: {
            m: {
                a:2,
                b:1
            }
        },
        c: 0,
        z: [0, 2]
    }, {
        a: {
            m: {
                a:1,
                c:1
            }
        },
        b: 0,
        z: [0, 2, 3]
    }
)));
{'fraction_non_alphanumeric': 0.11832412523020258, 'fraction_numerical': 0.006906077348066298, 'mean_word_length': 0.9458128078817734, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2571516', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1115, 'n_words': 242}