Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ps-list

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ps-list - npm Package Compare versions

Comparing version 4.1.0 to 5.0.0

26

index.js

@@ -7,4 +7,2 @@ 'use strict';

const TEN_MEGABYTE = 1000 * 1000 * 10;
function win() {

@@ -22,15 +20,11 @@ return tasklist().then(data => {

function def(opts) {
opts = opts || {};
function def(options = {}) {
const ret = {};
const flags = (opts.all === false ? '' : 'a') + 'wwxo';
const flags = (options.all === false ? '' : 'a') + 'wwxo';
return Promise.all(['comm', 'args', '%cpu', '%mem'].map(cmd => {
return pify(childProcess.execFile)('ps', [flags, `pid,${cmd}`], {
maxBuffer: TEN_MEGABYTE
}).then(stdout => {
return Promise.all(['comm', 'args', 'ppid', '%cpu', '%mem'].map(cmd => {
return pify(childProcess.execFile)('ps', [flags, `pid,${cmd}`]).then(stdout => {
for (let line of stdout.trim().split('\n').slice(1)) {
line = line.trim();
const pid = line.split(' ', 1)[0];
const [pid] = line.split(' ', 1);
const val = line.slice(pid.length + 1).trim();

@@ -48,9 +42,11 @@

// issues due to differences in `ps` between the spawns
return Object.keys(ret).filter(x => ret[x].comm && ret[x].args).map(x => {
// TODO: Use `Object.entries` when targeting Node.js 8
return Object.keys(ret).filter(x => ret[x].comm && ret[x].args && ret[x].ppid && ret[x]['%cpu'] && ret[x]['%mem']).map(x => {
return {
pid: parseInt(x, 10),
pid: Number.parseInt(x, 10),
name: path.basename(ret[x].comm),
cmd: ret[x].args,
cpu: ret[x]['%cpu'],
memory: ret[x]['%mem']
ppid: Number.parseInt(ret[x].ppid, 10),
cpu: Number.parseFloat(ret[x]['%cpu']),
memory: Number.parseFloat(ret[x]['%mem'])
};

@@ -57,0 +53,0 @@ });

{
"name": "ps-list",
"version": "4.1.0",
"description": "Get running processes",
"license": "MIT",
"repository": "sindresorhus/ps-list",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"ps",
"proc",
"process",
"processes",
"list",
"running",
"tasklist"
],
"dependencies": {
"pify": "^3.0.0",
"tasklist": "^3.1.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
"name": "ps-list",
"version": "5.0.0",
"description": "Get running processes",
"license": "MIT",
"repository": "sindresorhus/ps-list",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"ps",
"proc",
"process",
"processes",
"list",
"running",
"tasklist"
],
"dependencies": {
"pify": "^3.0.0",
"tasklist": "^3.1.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
}

@@ -20,9 +20,9 @@ # ps-list [![Build Status](https://travis-ci.org/sindresorhus/ps-list.svg?branch=master)](https://travis-ci.org/sindresorhus/ps-list) [![Build status](https://ci.appveyor.com/api/projects/status/i733mfqw11sja2xf/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/ps-list/branch/master)

psList().then(data => {
console.log(data);
//=> [{pid: 3213, name: 'node', cmd: 'node test.js', cpu: '0.1', memory: '1.5'}, ...]
});
(async () => {
console.log(await psList());
//=> [{pid: 3213, name: 'node', cmd: 'node test.js', ppid: 1, cpu: 0.1, memory: 1.5}, …]
})();
```
> The `cpu` and `memory` percentage is not supported on Windows.
> The `cpu`, `memory`, and `ppid` properties are not supported on Windows.

@@ -29,0 +29,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc