<commit_before>var debug      = require('debug')('pulldasher:pull-manager'),
    pullQueue  = require('./pull-queue'),
    _          = require('underscore');

var sockets = [];
var pulls = [];

var pullManager = module.exports = {
   addSocket: function(socket) {
      sockets.push(socket);
      sendInitialData(socket);
      socket.on('disconnect', function() {
         removeSocket(socket);
      });
   },

   updatePull: function(updatedPull) {
      var pull = getPull(updatedPull.data.repo, updatedPull.data.number);

      if (pull) {
         _.extend(pull, updatedPull);
         if (!pull.isOpen()) {
            pulls = _.without(pulls, pull);
         }
      } else {
         pull = updatedPull;
         if (pull.isOpen()) {
            pulls.push(pull);
         }
      } 

      notifyAboutPullStateChange(pull);
   }
};

function sendInitialData(socket) {
   debug('Emitting `allPulls`: %s pulls altogether', pulls.length);
   socket.emit('allPulls', _.invoke(pulls, 'toObject'));
}

function notifyAboutPullStateChange(pull) {
   debug('Emitting `pullChange`: sending Pull #%s to %s sockets',
   pull.data.number, sockets.length);
   sockets.forEach(function(socket) {
      socket.emit('pullChange', pull.toObject());
   });
}

/**
 * Removes the given socket from the collection
 */
function removeSocket(socket) {
   var index = sockets.indexOf(socket);
   if (index !== -1) {
      sockets.splice(index, 1);
   }
}

function getPull(repo, number) {
   return _.find(pulls, function(pull) {
      return pull.data.repo == repo && pull.data.number == number;
   });
}

pullQueue.on('pullsChanged', function(pulls) {
   pulls.forEach(function(pullId) {
      var pull = getPull(pullId.repo, pullId.number);
      if (pull !== null) {
         pullManager.updatePull(pull);
      }
   });
});<commit_msg>Use triple equals comparison<commit_after>var debug      = require('debug')('pulldasher:pull-manager'),
    pullQueue  = require('./pull-queue'),
    _          = require('underscore');

var sockets = [];
var pulls = [];

var pullManager = module.exports = {
   addSocket: function(socket) {
      sockets.push(socket);
      sendInitialData(socket);
      socket.on('disconnect', function() {
         removeSocket(socket);
      });
   },

   updatePull: function(updatedPull) {
      var pull = getPull(updatedPull.data.repo, updatedPull.data.number);

      if (pull) {
         _.extend(pull, updatedPull);
         if (!pull.isOpen()) {
            pulls = _.without(pulls, pull);
         }
      } else {
         pull = updatedPull;
         if (pull.isOpen()) {
            pulls.push(pull);
         }
      } 

      notifyAboutPullStateChange(pull);
   }
};

function sendInitialData(socket) {
   debug('Emitting `allPulls`: %s pulls altogether', pulls.length);
   socket.emit('allPulls', _.invoke(pulls, 'toObject'));
}

function notifyAboutPullStateChange(pull) {
   debug('Emitting `pullChange`: sending Pull #%s to %s sockets',
   pull.data.number, sockets.length);
   sockets.forEach(function(socket) {
      socket.emit('pullChange', pull.toObject());
   });
}

/**
 * Removes the given socket from the collection
 */
function removeSocket(socket) {
   var index = sockets.indexOf(socket);
   if (index !== -1) {
      sockets.splice(index, 1);
   }
}

function getPull(repo, number) {
   return _.find(pulls, function(pull) {
      return pull.data.repo === repo && Number(pull.data.number) === Number(number);
   });
}

pullQueue.on('pullsChanged', function(pulls) {
   pulls.forEach(function(pullId) {
      var pull = getPull(pullId.repo, pullId.number);
      if (pull !== null) {
         pullManager.updatePull(pull);
      }
   });
});
{'fraction_non_alphanumeric': 0.15442969384990518, 'fraction_numerical': 0.001083717149823896, 'mean_word_length': 2.845833333333333, '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': '5131413', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1134, 'n_words': 217}