<commit_before>var EventEmitter = require("events").EventEmitter;
var lazy = require("lazy.js");

var AppDispatcher = require("../AppDispatcher");
var QueueEvents = require("../events/QueueEvents");
var queueScheme = require("./queueScheme");

function processQueue(queue = []) {
  return lazy(queue).map(function (entry) {
    return lazy(queueScheme).extend(entry).value();
  }).value();
}

var QueueStore = lazy(EventEmitter.prototype).extend({
  queue: [],

  getDelayByAppId: function (appId) {
    var timeLeftSeconds = 0;

    var queueEntry = lazy(this.queue).find(function (entry) {
      return entry.app.id === appId && entry.delay != null;
    });

    if (queueEntry) {
      timeLeftSeconds = queueEntry.delay.timeLeftSeconds;
    }

    return timeLeftSeconds;
  }
}).value();

AppDispatcher.register(function (action) {
  switch (action.actionType) {
    case QueueEvents.REQUEST:
      QueueStore.queue = processQueue(action.data.body.queue);
      QueueStore.emit(QueueEvents.CHANGE);
      break;
    case QueueEvents.REQUEST_ERROR:
      QueueStore.emit(
        QueueEvents.REQUEST_ERROR,
        action.data.body
      );
      break;
    case QueueEvents.RESET_DELAY:
      QueueStore.emit(
        QueueEvents.RESET_DELAY,
        action.appId
      );
      break;
    case QueueEvents.RESET_DELAY_ERROR:
      QueueStore.emit(
        QueueEvents.RESET_DELAY_ERROR,
        action.data.body,
        action.appId
      );
      break;
  }
});

module.exports = QueueStore;
<commit_msg>Use of native functions instead of lazy.js in QueueStore, if it makes sense.<commit_after>var EventEmitter = require("events").EventEmitter;

var AppDispatcher = require("../AppDispatcher");
var QueueEvents = require("../events/QueueEvents");
var queueScheme = require("./queueScheme");

var util = require("../helpers/util");

function processQueue(queue = []) {
  return queue.map(function (entry) {
    return util.extendObject(queueScheme, entry);
  });
}

var QueueStore = util.extendObject(EventEmitter.prototype, {
  queue: [],

  getDelayByAppId: function (appId) {
    var timeLeftSeconds = 0;

    var queueEntry = this.queue.find(function (entry) {
      return entry.app.id === appId && entry.delay != null;
    });

    if (queueEntry) {
      timeLeftSeconds = queueEntry.delay.timeLeftSeconds;
    }

    return timeLeftSeconds;
  }
});

AppDispatcher.register(function (action) {
  switch (action.actionType) {
    case QueueEvents.REQUEST:
      QueueStore.queue = processQueue(action.data.body.queue);
      QueueStore.emit(QueueEvents.CHANGE);
      break;
    case QueueEvents.REQUEST_ERROR:
      QueueStore.emit(
        QueueEvents.REQUEST_ERROR,
        action.data.body
      );
      break;
    case QueueEvents.RESET_DELAY:
      QueueStore.emit(
        QueueEvents.RESET_DELAY,
        action.appId
      );
      break;
    case QueueEvents.RESET_DELAY_ERROR:
      QueueStore.emit(
        QueueEvents.RESET_DELAY_ERROR,
        action.data.body,
        action.appId
      );
      break;
  }
});

module.exports = QueueStore;

{'fraction_non_alphanumeric': 0.12410423452768729, 'fraction_numerical': 0.0006514657980456026, 'mean_word_length': 3.0514511873350925, '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': '2823209', 'n_tokens_mistral': 954, 'n_tokens_neox': 930, 'n_words': 171}