<commit_before>// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP

import React, { Component,  PropTypes } from 'react';
import jsxToString from 'jsx-to-string';
import debounce from 'lodash/debounce';
import Box from 'grommet/components/Box';

//hjjs configuration
const hljs = require('highlight.js/lib/highlight');
hljs.registerLanguage('bash', require('highlight.js/lib/languages/bash'));
hljs.registerLanguage('xml', require('highlight.js/lib/languages/xml'));
hljs.registerLanguage('javascript',
  require('highlight.js/lib/languages/javascript'));
hljs.registerLanguage('scss', require('highlight.js/lib/languages/scss'));

export default class Example extends Component {
  constructor (props) {
    super(props);
    this._highlightCode = props.debounceHighlight
      ? debounce(this._highlightCode.bind(this), 100)
      : this._highlightCode.bind(this);
  }

  componentDidMount () {
    this._highlightCode();
  }

  componentDidUpdate () {
    this._highlightCode();
  }<commit_msg>Use setTimeout to debounce highlight & remove `lodash/debounce`<commit_after>// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP

import React, { Component,  PropTypes } from 'react';
import jsxToString from 'jsx-to-string';
import Box from 'grommet/components/Box';

//hjjs configuration
const hljs = require('highlight.js/lib/highlight');
hljs.registerLanguage('bash', require('highlight.js/lib/languages/bash'));
hljs.registerLanguage('xml', require('highlight.js/lib/languages/xml'));
hljs.registerLanguage('javascript',
  require('highlight.js/lib/languages/javascript'));
hljs.registerLanguage('scss', require('highlight.js/lib/languages/scss'));

export default class Example extends Component {
  constructor (props) {
    super(props);
    this._highlightCode = this._highlightCode.bind(this);
  }

  componentDidMount () {
    this._highlightCode();
  }

  componentDidUpdate () {
    if (this.props.debounceHighlight) {
      clearTimeout(this._highlightTimer);
      this._highlightTimer = setTimeout(this._highlightCode, 100);
    } else {
      this._highlightCode();
    }
  }
{'fraction_non_alphanumeric': 0.13713477851083883, 'fraction_numerical': 0.010367577756833177, 'mean_word_length': 5.083094555873926, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '71019', 'n_tokens_mistral': 671, 'n_tokens_neox': 603, 'n_words': 122}