<commit_before>import {isNil, type, contains, any} from 'ramda';
import React from 'react';
import PropTypes from 'prop-types';

/**
 * Deep equality check to know if the data has changed.
 *
 * @param {*} newData - New data to compare
 * @param {*} oldData - The old data to compare
 * @returns {boolean} The data has changed.
 */
function dataChanged(newData, oldData) {
    const oldNull = isNil(oldData);
    const newNull = isNil(newData);
    if (oldNull || newNull) {
        return oldNull !== newNull;
    }
    const newType = type(newData);
    if (newType !== type(oldData)) {
        return true;
    }
    if (newType === 'Array') {
        if (newData.length !== oldData.length) {
            return true;
        }
        for (let i = 0; i < newData.length; i++) {
            if (dataChanged(newData[i], oldData[i])) {
                return true;
            }
        }
    } else if (contains(newType, ['String', 'Number', 'Boolean'])) {
        return oldData !== newData;
    } else if (newType === 'Object') {
        return any(([k, v]) => dataChanged(v, oldData[k]))(
            Object.entries(newData)
        );
    }
    return false;
}<commit_msg>:bug: Fix Store key removal from dict.<commit_after>import {isNil, type, contains, any} from 'ramda';
import React from 'react';
import PropTypes from 'prop-types';

/**
 * Deep equality check to know if the data has changed.
 *
 * @param {*} newData - New data to compare
 * @param {*} oldData - The old data to compare
 * @returns {boolean} The data has changed.
 */
function dataChanged(newData, oldData) {
    const oldNull = isNil(oldData);
    const newNull = isNil(newData);
    if (oldNull || newNull) {
        return oldNull !== newNull;
    }
    const newType = type(newData);
    if (newType !== type(oldData)) {
        return true;
    }
    if (newType === 'Array') {
        if (newData.length !== oldData.length) {
            return true;
        }
        for (let i = 0; i < newData.length; i++) {
            if (dataChanged(newData[i], oldData[i])) {
                return true;
            }
        }
    } else if (contains(newType, ['String', 'Number', 'Boolean'])) {
        return oldData !== newData;
    } else if (newType === 'Object') {
        const oldEntries = Object.entries(oldData);
        const newEntries = Object.entries(newData);
        if (oldEntries.length !== newEntries.length) {
            return true;
        }
        return any(([k, v]) => dataChanged(v, oldData[k]))(
            newEntries
        );
    }
    return false;
}
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.00078064012490242, 'mean_word_length': 2.3070967741935484, 'pattern_counts': {'":': 0, '<': 5, '<?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': '900625', 'n_tokens_mistral': 774, 'n_tokens_neox': 770, 'n_words': 233}