index.js 460 B

1234567891011121314
  1. 'use strict';
  2. const psList = require('ps-list');
  3. const fn = (proc, x) => {
  4. if (typeof proc === 'string') {
  5. return x.name === proc;
  6. }
  7. return x.pid === proc;
  8. };
  9. module.exports = proc => psList().then(list => list.some(x => fn(proc, x)));
  10. module.exports.all = procs => psList().then(list => new Map(procs.map(x => [x, list.some(y => fn(x, y))])));
  11. module.exports.filterExists = procs => psList().then(list => procs.filter(x => list.some(y => fn(x, y))));