<commit_before>//Dependencies.
var CoreStore = require('../CoreStore');
var getDefinition = require('./definition');
var uuid = require('uuid').v4;
const PUSH = 'push';

/**
 * Class standing for the cartridge store.
 */
class MessageStore extends CoreStore {
  /**
   * Add a listener on the global change on the search store.
   * @param {object} conf - The configuration of the message store.
   */
  constructor(conf){
    conf = conf || {};
    conf.definition = conf.definition || getDefinition();
    super(conf);
  }
  /**
   * Get a message from its identifier.
   * @param {string} messageId - The message identifier.
   * @returns {object} - The requested message.
   */
  getMessage(messageId){
    if(!this.data.has(messageId)){
      return undefined;
    }
    var message = this.data.get(messageId);
    if(!message.isAck){
      this.deleteMessage(messageId);
    }
    return message;
  }
  /**
   * Delete a message given its id.
   * @param {string} messageId - The message identifier.
   */
  deleteMessage(messageId){
    if(this.data.has(messageId)){
      this.data = this.data.delete(messageId);
    }
  }
  /**
   * Add a listener on the global change on the search store.
   * @param {object} message - The message to add.
   */
  pushMessage(message){
    message.id = `${uuid()}`;
    this.data = this.data.set(message.id, message);
    this.emit(PUSH, message.id);
  }
  /**
   * Add a listener on the global change on the search store.
   * @param {function} cb - The callback to call when a message is added.
   */
  addPushedMessageListener(cb){
    this.addListener(PUSH, cb);
  }
}

module.exports = MessageStore;<commit_msg>[message] Add remove listener function.<commit_after>//Dependencies.
var CoreStore = require('../CoreStore');
var getDefinition = require('./definition');
var uuid = require('uuid').v4;
const PUSH = 'push';

/**
 * Class standing for the cartridge store.
 */
class MessageStore extends CoreStore {
  /**
   * Add a listener on the global change on the search store.
   * @param {object} conf - The configuration of the message store.
   */
  constructor(conf){
    conf = conf || {};
    conf.definition = conf.definition || getDefinition();
    super(conf);
  }
  /**
   * Get a message from its identifier.
   * @param {string} messageId - The message identifier.
   * @returns {object} - The requested message.
   */
  getMessage(messageId){
    if(!this.data.has(messageId)){
      return undefined;
    }
    var message = this.data.get(messageId);
    if(!message.isAck){
      this.deleteMessage(messageId);
    }
    return message;
  }
  /**
   * Delete a message given its id.
   * @param {string} messageId - The message identifier.
   */
  deleteMessage(messageId){
    if(this.data.has(messageId)){
      this.data = this.data.delete(messageId);
    }
  }
  /**
   * Add a listener on the global change on the search store.
   * @param {object} message - The message to add.
   */
  pushMessage(message){
    message.id = `${uuid()}`;
    this.data = this.data.set(message.id, message);
    this.emit(PUSH, message.id);
  }
  /**
   * Add a listener on the global change on the search store.
   * @param {function} cb - The callback to call when a message is pushed.
   */
  addPushedMessageListener(cb){
    this.addListener(PUSH, cb);
  }
  /**
   * Remove a listener on the global change on the search store.
   * @param {function} cb - The callback to called when a message is pushed.
   */
  removePushedMessageListener(cb){
    this.removeListener(PUSH, cb);
  }
}

module.exports = MessageStore;
{'fraction_non_alphanumeric': 0.13342657342657344, 'fraction_numerical': 0.0005594405594405594, 'mean_word_length': 2.942668136714443, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2094921', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1078, 'n_words': 325}