<commit_before>import React from 'react';
import highlight from './highlight';

const languages = [];
export const registerLanguage = (_, language) => languages.push(language);

export default class ReactHighlightAsync extends React.PureComponent {
  static refractor = null;
  static highlightInstance = null;

  state = {
    refractor: ReactHighlightAsync.refractor
  };

  componentWillMount() {
    if (!ReactHighlightAsync.highlightInstance) {
      const refractorPromise = import(/* webpackChunkName:"react-syntax-highlighter/refractor-import" */ 'refractor/core').then(({ default: refractor }) => {
        languages.forEach((language) => refractor.register(language));
        this.setState({ refractor })
      });
      ReactHighlightAsync.highlightInstance = (highlight(null, {}));
    }
  }
  render() {
    return (<ReactHighlightAsync.highlightInstance {...this.props} astGenerator={this.state.refractor} />);
  }
};
<commit_msg>Clean up promises<commit_after>import React from 'react';
import highlight from './highlight';

const languages = [];
export const registerLanguage = (_, language) => {
  if(ReactHighlightAsync.refractor) {
    return refractor.register(language);
  } else {
    languages.push(language);
  }
};

export default class ReactHighlightAsync extends React.PureComponent {
  static refractor = null;
  static highlightInstance = (highlight(null, {}));
  static refractorPromise = null;
  
  _loadRefractor() {
    ReactHighlightAsync.refractorPromise = import(/* webpackChunkName:"react-syntax-highlighter/refractor-import" */ 'refractor/core').then(({ default: refractor }) => {
      languages.forEach((language) => refractor.register(language));
      ReactHighlightAsync.refractor = refractor;
    });
  }

  componentWillMount() {
    if (!ReactHighlightAsync.refractorPromise) {
      this._loadRefractor();
    }

    ReactHighlightAsync.refractorPromise.then(() => {
      this.forceUpdate();
    });
  }
  render() {
    return (<ReactHighlightAsync.highlightInstance {...this.props} astGenerator={ReactHighlightAsync.refractor} />);
  }
};

{'fraction_non_alphanumeric': 0.13492822966507176, 'fraction_numerical': 0.0, 'mean_word_length': 4.320610687022901, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '2803933', 'n_tokens_mistral': 618, 'n_tokens_neox': 578, 'n_words': 109}