<commit_before>var Autowire = require('wantsit').Autowire,
  util = require('util'),
  Actions = require('./Actions'),
  Table = require('./Table'),
  path = require('path')

var Processes = function() {
  Actions.call(this)

  this._moment = Autowire
  this._formatMemory = Autowire
  this._fs = Autowire
}
util.inherits(Processes, Actions)

Processes.prototype.list = function(options) {
  this._do(options, function(boss) {
    boss.listProcesses(function(error, processes) {
      if(error) throw error

      var table = new Table('No running processes')
      table.addHeader(['PID', 'User', 'Group', 'Name', 'Uptime', 'Restarts', 'CPU', 'RSS', 'Heap size', 'Heap used', 'Status', 'Type'])

      var addProcessToTable = function(proc, type) {
        if(!proc) {
          return table.addRow(['?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', type])
        }

        var pid = proc.pid ? proc.pid : '?',
          user = proc.user !== undefined ? proc.user : '?',
          group = proc.group !== undefined ? proc.group : '?',
          name = proc.name || '?',
          uptime = proc.uptime ? this._moment.duration(proc.uptime * 1000).humanize() : '?',
          restarts = proc.restarts !== undefined ? proc.restarts : '?',
          rss = isNaN(proc.residentSize) ? '?' : this._formatMemory(proc.residentSize, true),
          heapTotal = isNaN(proc.heapTotal) ? '?' : this._formatMemory(proc.heapTotal, true),
          heapUsed = isNaN(proc.heapUsed) ? '?' : this._formatMemory(proc.heapUsed, true),
          cpu = isNaN(proc.cpu) ? '?' : proc.cpu.toFixed(2),
          status = !proc.status ? '?' : proc.status

        table.addRow([pid, user, group, name, uptime, restarts, cpu, rss, heapTotal, heapUsed, status, type])
      }.bind(this)

      processes.forEach(function (proc) {
        addProcessToTable(proc, proc.cluster ? 'Manager' : 'Process')

        if(proc.cluster && proc.workers) {
          proc.workers.forEach(function(worker) {
            addProcessToTable(worker, 'Worker')
          })
        }
      })

      table.print(console.info)

      boss.disconnect()
    }.bind(this))
  }.bind(this))
}<commit_msg>fixes #16 - isNaN(null) is false, yayjs<commit_after>var Autowire = require('wantsit').Autowire,
  util = require('util'),
  Actions = require('./Actions'),
  Table = require('./Table'),
  path = require('path')

var Processes = function() {
  Actions.call(this)

  this._moment = Autowire
  this._formatMemory = Autowire
  this._fs = Autowire
}
util.inherits(Processes, Actions)

Processes.prototype.list = function(options) {
  this._do(options, function(boss) {
    boss.listProcesses(function(error, processes) {
      if(error) throw error

      var table = new Table('No running processes')
      table.addHeader(['PID', 'User', 'Group', 'Name', 'Uptime', 'Restarts', 'CPU', 'RSS', 'Heap size', 'Heap used', 'Status', 'Type'])

      var addProcessToTable = function(proc, type) {
        if(!proc) {
          return table.addRow(['?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', type])
        }

        var pid = proc.pid ? proc.pid : '?',
          user = proc.user !== undefined ? proc.user : '?',
          group = proc.group !== undefined ? proc.group : '?',
          name = proc.name || '?',
          uptime = proc.uptime ? this._moment.duration(proc.uptime * 1000).humanize() : '?',
          restarts = proc.restarts !== undefined ? proc.restarts : '?',
          rss = proc.residentSize && isNaN(proc.residentSize) ? '?' : this._formatMemory(proc.residentSize, true),
          heapTotal = proc.heapTotal && isNaN(proc.heapTotal) ? '?' : this._formatMemory(proc.heapTotal, true),
          heapUsed = proc.heapUsed && isNaN(proc.heapUsed) ? '?' : this._formatMemory(proc.heapUsed, true),
          cpu = proc.cpu && isNaN(proc.cpu) ? '?' : proc.cpu.toFixed(2),
          status = !proc.status ? '?' : proc.status

        table.addRow([pid, user, group, name, uptime, restarts, cpu, rss, heapTotal, heapUsed, status, type])
      }.bind(this)

      processes.forEach(function (proc) {
        addProcessToTable(proc, proc.cluster ? 'Manager' : 'Process')

        if(proc.cluster && proc.workers) {
          proc.workers.forEach(function(worker) {
            addProcessToTable(worker, 'Worker')
          })
        }
      })

      table.print(console.info)

      boss.disconnect()
    }.bind(this))
  }.bind(this))
}
{'fraction_non_alphanumeric': 0.1822514752610077, 'fraction_numerical': 0.0027235587834770767, 'mean_word_length': 2.852272727272727, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2707810', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1405, 'n_words': 265}