<commit_before>import Immutable from 'immutable';

const KEY_SEPARATOR = '-';

function MultiDecorator(decorators) {
  this.decorators = Immutable.List(decorators);
}

/**
 Return list of decoration IDs per character

 @param {ContentBlock} block
 @return {List<String>}
 */
MultiDecorator.prototype.getDecorations = function getDecorations(block) {
  const decorations = Array(block.getText().length).fill(null);

  this.decorators.forEach((decorator, i) => {
    const subDecorations = decorator.getDecorations(block);

    subDecorations.forEach((key, offset) => {
      if (!key) {
        return;
      }

      const decoration = i + KEY_SEPARATOR + key;

      decorations[offset] = decoration;
    });
  });

  return Immutable.List(decorations);
};

/**
 Return component to render a decoration

 @param {String} key
 @return {Function}
 */
MultiDecorator.prototype.getComponentForKey = function getComponentForKey(key) {
  const decorator = this.getDecoratorForKey(key);
  return decorator.getComponentForKey(
    this.getInnerKey(key)
  );
};

/**
 Return props to render a decoration

 @param {String} key
 @return {Object}
 */
MultiDecorator.prototype.getPropsForKey = function getPropsForKey(key) {
  const decorator = this.getDecoratorForKey(key);
  return decorator.getPropsForKey(
    this.getInnerKey(key)
  );
};

/**
 Return a decorator for a specific key

 @param {String} key
 @return {Decorator}
 */
MultiDecorator.prototype.getDecoratorForKey = function getDecoratorForKey(key) {
  const parts = key.split(KEY_SEPARATOR);
  const index = Number(parts[0]);

  return this.decorators.get(index);
};

/**
 Return inner key for a decorator

 @param {String} key
 @return {String}
 */
MultiDecorator.prototype.getInnerKey = function getInnerKey(key) {
  const parts = key.split(KEY_SEPARATOR);
  return parts.slice(1).join(KEY_SEPARATOR);
};

module.exports = MultiDecorator;<commit_msg>Convert MultiDecorator to ES6 Class<commit_after>import Immutable from 'immutable';

const KEY_SEPARATOR = '-';

class MultiDecorator {
  constructor(decorators) {
    this.decorators = Immutable.List(decorators);
  }

  /**
   * Return list of decoration IDs per character
   *
   * @param {ContentBlock} block
   * @return {List<String>}
   */
  getDecorations(block) {
    const decorations = new Array(block.getText().length).fill(null);

    this.decorators.forEach((decorator, i) => {
      const subDecorations = decorator.getDecorations(block);

      subDecorations.forEach((key, offset) => {
        if (!key) {
          return;
        }

        decorations[offset] = i + KEY_SEPARATOR + key;
      });
    });

    return Immutable.List(decorations);
  }

  /**
   * Return component to render a decoration
   *
   * @param {String} key
   * @return {Function}
   */
  getComponentForKey(key) {
    const decorator = this.getDecoratorForKey(key);
    return decorator.getComponentForKey(
      MultiDecorator.getInnerKey(key)
    );
  }

  /**
   * Return props to render a decoration
   *
   * @param {String} key
   * @return {Object}
   */
  getPropsForKey(key) {
    const decorator = this.getDecoratorForKey(key);
    return decorator.getPropsForKey(
      MultiDecorator.getInnerKey(key)
    );
  }

  /**
   * Return a decorator for a specific key
   *
   * @param {String} key
   * @return {Decorator}
   */
  getDecoratorForKey(key) {
    const parts = key.split(KEY_SEPARATOR);
    const index = Number(parts[0]);

    return this.decorators.get(index);
  }

  /**
   * Return inner key for a decorator
   *
   * @param {String} key
   * @return {String}
   */
  static getInnerKey(key) {
    const parts = key.split(KEY_SEPARATOR);
    return parts.slice(1).join(KEY_SEPARATOR);
  }
}

module.exports = MultiDecorator;
{'fraction_non_alphanumeric': 0.12269938650306748, 'fraction_numerical': 0.0013336889837289945, 'mean_word_length': 3.539951573849879, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4258982', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1207, 'n_words': 255}