<commit_before>import EventEmitter from './EventEmitter';
import bindMethodContext from './utils/bindMethodContext';

export const EventTypes = {
  METHOD_CALL_START: 'METHOD_CALL_START',
  METHOD_CALL_END: 'METHOD_CALL_END',
};

export const subscribe = (proxy, eventType, handler) => {
  const emitter = proxy[EMITTER_KEY];
  return emitter.on(eventType, handler);
};

const EMITTER_KEY = '__DECOX_EMITTER_KEY__';

export default function defineWrappedClass(OriginalClass, configs) {
  const WrappedClass = defineSubClass(OriginalClass);
  const wrappedMethods = wrapMethods(
    OriginalClass.name,
    OriginalClass.prototype,
    configs.isTarget
  );
  Object.assign(WrappedClass.prototype, wrappedMethods);
  return WrappedClass;
}

const defineSubClass = OriginalClass => {
  return class DecoxSubClass extends OriginalClass {
    constructor(...args) {
      super(...args);
      this[EMITTER_KEY] = new EventEmitter();
      bindMethodContext(this);  // TODO: Should be optional.
    }
  };
};<commit_msg>feat(decox): Fix defineWrappedClass a bit<commit_after>import EventEmitter from './EventEmitter';
import bindMethodContext from './utils/bindMethodContext';

export const EventTypes = {
  METHOD_CALL_START: 'METHOD_CALL_START',
  METHOD_CALL_END: 'METHOD_CALL_END',
};

export const subscribe = (wrappedObject, eventType, handler) => {
  const emitter = wrappedObject[EMITTER_KEY];
  return emitter.on(eventType, handler);
};

const EMITTER_KEY = '__DECOX_EMITTER_KEY__';

export default function defineWrappedClass(OriginalClass, configs = {}) {
  const WrappedClass = defineSubClass(OriginalClass);
  const wrappedMethods = wrapMethods(
    OriginalClass.name,
    OriginalClass.prototype,
    configs.isTarget
  );
  Object.assign(WrappedClass.prototype, wrappedMethods);
  return WrappedClass;
}

const defineSubClass = OriginalClass => {
  return class DecoxSubClass extends OriginalClass {
    constructor(...args) {
      super(...args);

      Object.defineProperty(this, EMITTER_KEY, {
        value: new EventEmitter(),
        configurable: false,
        enumerable: false,
        writable: false,
      })

      bindMethodContext(this);  // TODO: Should be optional.
    }
  };
};
{'fraction_non_alphanumeric': 0.10628674807779286, 'fraction_numerical': 0.0, 'mean_word_length': 4.434889434889435, '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': '5311992', 'n_tokens_mistral': 664, 'n_tokens_neox': 653, 'n_words': 144}