<commit_before>const EventEmitter = require('events');

const consul = require('consul');
const backoff = require('backoff');
const C = require('./constants');
const decode = require('./decode');
const configure = require('./configure');

/**
 * Class that extends EventEmitter and watches consul and fires events when detect changes
 */
class Consulr extends EventEmitter {
  constructor(config) {
    super();
    this.config = configure(config);

    this.waitIndex = 0;
    this.consulQuery = {
      key: this.config.prefix,
      recurse: true,
      index: this.waitIndex,
      wait: C.DEFAULT_WAIT_TIME_IN_MINUTE
    };
  }

  /**
   * Start to watch for updates
   */
  run() {
    this.consul = consul();

    this.expBackoff = backoff.exponential({
      initialDelay: 100 * 10, // 1  seconds
      maxDelay: 10000 // 10 seconds
    });

    this.expBackoff.on('backoff', this._backoffHandler.bind(this));
    ['ready', 'fail'].map(evt => this.expBackoff.on(evt, this._backoff.bind(this)));
    this._backoff();
  }

  close() {
    this.removeAllListeners('update');
    this._reset();
  }

  _backoffHandler() {
    this.consul.kv.get(this.consulQuery, (err, result, res) => {
      if (err) {
        return this._handleError(err);
      }

      let metadata = this.consul.parseQueryMeta(res);
        // if same, there is no changes
      let lastIndex = parseInt(metadata.LastIndex);
      if (lastIndex === this.waitIndex) {
        if (this.config.fireInternalEvents === true) {<commit_msg>add radix parameter to parseInt<commit_after>const EventEmitter = require('events');

const consul = require('consul');
const backoff = require('backoff');
const C = require('./constants');
const decode = require('./decode');
const configure = require('./configure');

/**
 * Class that extends EventEmitter and watches consul and fires events when detect changes
 */
class Consulr extends EventEmitter {
  constructor(config) {
    super();
    this.config = configure(config);

    this.waitIndex = 0;
    this.consulQuery = {
      key: this.config.prefix,
      recurse: true,
      index: this.waitIndex,
      wait: C.DEFAULT_WAIT_TIME_IN_MINUTE
    };
  }

  /**
   * Start to watch for updates
   */
  run() {
    this.consul = consul();

    this.expBackoff = backoff.exponential({
      initialDelay: 100 * 10, // 1  seconds
      maxDelay: 10000 // 10 seconds
    });

    this.expBackoff.on('backoff', this._backoffHandler.bind(this));
    ['ready', 'fail'].map(evt => this.expBackoff.on(evt, this._backoff.bind(this)));
    this._backoff();
  }

  close() {
    this.removeAllListeners('update');
    this._reset();
  }

  _backoffHandler() {
    this.consul.kv.get(this.consulQuery, (err, result, res) => {
      if (err) {
        return this._handleError(err);
      }

      let metadata = this.consul.parseQueryMeta(res);
        // if same, there is no changes
      let lastIndex = parseInt(metadata.LastIndex, 10);
      if (lastIndex === this.waitIndex) {
        if (this.config.fireInternalEvents === true) {
{'fraction_non_alphanumeric': 0.1443129520052597, 'fraction_numerical': 0.009861932938856016, 'mean_word_length': 3.0039473684210525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2703896', 'n_tokens_mistral': 964, 'n_tokens_neox': 938, 'n_words': 217}