<commit_before>import * as React from 'react';
import { DeepStorage, Path, DeepSubscription, parsePaths, stringOrNumber } from "deep-storage";

export const deep = <State extends {}, P>(
    storage: DeepStorage<State>,
    paths: { [key: string]: Path | stringOrNumber },
    ownProps: { [key: string]: Partial<P> }) => (BaseComponent: React.ComponentType<P>) => {
        const parsedPaths = parsePaths(paths);
        return class extends React.Component<P, {}> {
            subscription: DeepSubscription;
            componentDidMount() {
                this.subscription = storage.subscription((...args: any[]) => {
                    this.forceUpdate();
                });
                for (let key in paths) {
                    this.subscription.subscribeTo(...parsedPaths[key]);
                }
            }
            componentWillUnmount() {
                this.subscription && this.subscription.cancel();
            }
            shouldComponentUpdate(nextProps: P, nextState: {}) {
                const nextPropsAny: any = nextProps;
                for (let key in parsedPaths) {
                    if (nextPropsAny[key] !== storage.stateIn(...parsedPaths[key])) {
                        return true;
                    }
                }
                return false;
            }
            render() {
                const anyProps: any = this.props;
                const newProps: any = { ...anyProps, ...ownProps };
                for (let key in parsedPaths) {
                    newProps[key] = storage.stateIn(...parsedPaths[key])
                }
                return <BaseComponent {...newProps} />;
            }
        };
    }<commit_msg>ownProps<commit_after>import * as React from 'react';
import { DeepStorage, Path, DeepSubscription, parsePaths, stringOrNumber } from "deep-storage";

export const deep = <State extends {}, P>(
    storage: DeepStorage<State>,
    paths: { [key: string]: Path | stringOrNumber },
    ownProps?: { [key: string]: Partial<P> }) => (BaseComponent: React.ComponentType<P>) => {
        const parsedPaths = parsePaths(paths);
        return class extends React.Component<P, {}> {
            subscription: DeepSubscription;
            componentDidMount() {
                this.subscription = storage.subscription((...args: any[]) => {
                    this.forceUpdate();
                });
                for (let key in paths) {
                    this.subscription.subscribeTo(...parsedPaths[key]);
                }
            }
            componentWillUnmount() {
                this.subscription && this.subscription.cancel();
            }
            shouldComponentUpdate(nextProps: P, nextState: {}) {
                const nextPropsAny: any = nextProps;
                for (let key in parsedPaths) {
                    if (nextPropsAny[key] !== storage.stateIn(...parsedPaths[key])) {
                        return true;
                    }
                }
                return false;
            }
            render() {
                const anyProps: any = this.props;
                const newProps: any = { ...anyProps, ...(ownProps || {}) };
                for (let key in parsedPaths) {
                    newProps[key] = storage.stateIn(...parsedPaths[key])
                }
                return <BaseComponent {...newProps} />;
            }
        };
    }
{'fraction_non_alphanumeric': 0.12293632075471699, 'fraction_numerical': 0.0, 'mean_word_length': 1.5114729829755738, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, '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': '5344282', 'n_tokens_mistral': 839, 'n_tokens_neox': 822, 'n_words': 188}