File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ export interface Options {
2+ /**
3+ * Include other users' processes as well as your own.
4+ *
5+ * On Windows this has no effect and will always be the users' own processes.
6+ *
7+ * @default true
8+ */
9+ readonly all ?: boolean ;
10+ }
11+
12+ export interface ProcessDescriptor {
13+ readonly pid : number ;
14+ readonly name : string ;
15+ readonly ppid : number ;
16+
17+ /**
18+ * Not supported on Windows.
19+ */
20+ readonly cmd ?: string ;
21+
22+ /**
23+ * Not supported on Windows.
24+ */
25+ readonly cpu ?: number ;
26+
27+ /**
28+ * Not supported on Windows.
29+ */
30+ readonly memory ?: number ;
31+
32+ /**
33+ * Not supported on Windows.
34+ */
35+ readonly uid ?: number ;
36+ }
37+
38+ /**
39+ * Get running processes.
40+ *
41+ * @returns List of running processes.
42+ */
43+ export default function psList ( options ?: Options ) : Promise < ProcessDescriptor [ ] > ;
Original file line number Diff line number Diff line change @@ -59,3 +59,4 @@ const main = async (options = {}) => {
5959} ;
6060
6161module . exports = process . platform === 'win32' ? windows : main ;
62+ module . exports . default = module . exports ;
Original file line number Diff line number Diff line change 1+ import { expectType } from 'tsd-check' ;
2+ import psList , { ProcessDescriptor } from '.' ;
3+
4+ const processes : ProcessDescriptor [ ] = await psList ( ) ;
5+ psList ( { all : false } ) ;
6+
7+ expectType < number > ( processes [ 0 ] . pid ) ;
8+ expectType < string > ( processes [ 0 ] . name ) ;
9+ expectType < number > ( processes [ 0 ] . ppid ) ;
10+ expectType < string | undefined > ( processes [ 0 ] . cmd ) ;
11+ expectType < number | undefined > ( processes [ 0 ] . cpu ) ;
12+ expectType < number | undefined > ( processes [ 0 ] . memory ) ;
13+ expectType < number | undefined > ( processes [ 0 ] . uid ) ;
Original file line number Diff line number Diff line change 1313 "node" : " >=8"
1414 },
1515 "scripts" : {
16- "test" : " xo && ava"
16+ "test" : " xo && ava && tsd-check "
1717 },
1818 "files" : [
1919 " index.js" ,
20+ " index.d.ts" ,
2021 " fastlist.exe"
2122 ],
2223 "keywords" : [
2930 " tasklist"
3031 ],
3132 "devDependencies" : {
32- "ava" : " ^0.25.0" ,
33- "xo" : " ^0.23.0"
33+ "ava" : " ^1.3.1" ,
34+ "tsd-check" : " ^0.3.0" ,
35+ "xo" : " ^0.24.0"
3436 }
3537}
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ Type: `Object`
4141Type: ` boolean ` <br >
4242Default: ` true `
4343
44- Return other users' processes as well as your own.
44+ Include other users' processes as well as your own.
4545
4646On Windows this has no effect and will always be the users' own processes.
4747
You can’t perform that action at this time.
0 commit comments