/*
 *  Helpers related to node standard library.
 */

var fs = require('fs');

var nodeHelpers = {

  isFn: function (callback) {
    return callback !== undefined
      && typeof (callback) === 'function';
  },

  /**
   * Properly invoke a callback function.
   *
   * @param {Function} callback Callback function to invoke.
   */
  invoke: function (callback) {
    if ( nodeHelpers.isFn(callback) ) {
      var args = Array.prototype.slice.call(arguments, 0);
      args.shift();
      callback.apply(null, args);
    }
  },

  /**
   * Clear from the require cache, the given app path.
   *
   * @param {String} modulePath App path to clear from require cache.
   */
  clearRequireCache: function (modulePath) {
    if ( fs.existsSync(modulePath) ){
      modulePath = fs.realpathSync(modulePath);
    }
    for (var name in require.cache) {
      if (name.match(new RegExp('^' + modulePath))) {
        delete require.cache[name];
      }
    }
  },

  /**
   * Tells if the current process has freed
   * it s resources and thus is ready to quit properly
   */
  hasFreedResources: function () {
    /*eslint-disable */
    var handlesC = process._getActiveHandles().length;
    var requestsC = process._getActiveRequests().length;
    /*eslint-enable */
    return handlesC + requestsC === 0;
  },

  /**
   * Close a node server by calling each socket.destroy on close event
   *
   * @param {Object} server Server to clean.
   */
  clearCloseServer: function (server) {
    var sockets = [];
    server.on('connection', function removeSockets (socket) {
      sockets.push(socket);
      socket.on('close', function () {
        sockets.splice(sockets.indexOf(socket), 1);
      });
    });
    server.on('close', function() {
      sockets.forEach(function destroySocket (socket){
        socket.destroy();
      });
    });
  }
};

module.exports = nodeHelpers;
@@ -98,16 +98,22 @@
 %7B%0A%0A  isF
+unctio
 n: funct
@@ -388,16 +388,22 @@
 pers.isF
+unctio
 n(callba

change isFn to isFunction