<commit_before>import React from 'react';

export const sharedState = (C, prop) =>
  class _sharedState extends React.Component {
    constructor(props) {
      super(props);

      this.state = {};

      const store = props[prop];
      getComponentInstance(store).then(instance => {
        this.shareStore = instance;
        this.shareStore.subscribe(this._updateState);

        this.setState({ instance });
      });
    }

    _updateState = shared => this.setState({ shared });

    componentWillUnmount() {
      this.shareStore && this.shareStore.unsubscribe(this._updateState);
    }

    render() {
      const { shared, instance } = this.state;
      return <C {...this.props} _shared={shared} _instance={instance}/>;
    }
  }

export const getComponentInstance = store =>
  new Promise((resolve, reject) =>
    store.instance && resolve(store.instance) ||
    setTimeout(() => store.instance && resolve(store.instance), 100)
  );<commit_msg>add default miliseconds<commit_after>import React from 'react';

export const sharedState = (C, prop) =>
  class _sharedState extends React.Component {
    constructor(props) {
      super(props);

      this.state = {};

      const store = props[prop];
      getComponentInstance(store).then(instance => {
        this.shareStore = instance;
        this.shareStore.subscribe(this._updateState);

        this.setState({ instance });
      });
    }

    _updateState = shared => this.setState({ shared });

    componentWillUnmount() {
      this.shareStore && this.shareStore.unsubscribe(this._updateState);
    }

    render() {
      const { shared, instance } = this.state;
      return <C {...this.props} _shared={shared} _instance={instance}/>;
    }
  }

export const getComponentInstance = (store, ms = 100) =>
  new Promise((resolve, reject) =>
    store.instance && resolve(store.instance) ||
    setTimeout(() => store.instance && resolve(store.instance), ms)
  );
{'fraction_non_alphanumeric': 0.14263565891472868, 'fraction_numerical': 0.0031007751937984496, 'mean_word_length': 3.0843881856540083, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '5483986', 'n_tokens_mistral': 552, 'n_tokens_neox': 539, 'n_words': 114}