-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor TypeScript definition to CommonJS compatible export (#31)
- Loading branch information
1 parent
158f5db
commit 9c6f89d
Showing
4 changed files
with
64 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,64 @@ | ||
export interface Options { | ||
/** | ||
* Include other users' processes as well as your own. | ||
* | ||
* On Windows this has no effect and will always be the users' own processes. | ||
* | ||
* @default true | ||
*/ | ||
readonly all?: boolean; | ||
} | ||
declare namespace psList { | ||
interface Options { | ||
/** | ||
Include other users' processes as well as your own. | ||
export interface ProcessDescriptor { | ||
readonly pid: number; | ||
readonly name: string; | ||
readonly ppid: number; | ||
On Windows this has no effect and will always be the users' own processes. | ||
/** | ||
* Not supported on Windows. | ||
*/ | ||
readonly cmd?: string; | ||
@default true | ||
*/ | ||
readonly all?: boolean; | ||
} | ||
|
||
/** | ||
* Not supported on Windows. | ||
*/ | ||
readonly cpu?: number; | ||
interface ProcessDescriptor { | ||
readonly pid: number; | ||
readonly name: string; | ||
readonly ppid: number; | ||
|
||
/** | ||
* Not supported on Windows. | ||
*/ | ||
readonly memory?: number; | ||
/** | ||
Not supported on Windows. | ||
*/ | ||
readonly cmd?: string; | ||
|
||
/** | ||
* Not supported on Windows. | ||
*/ | ||
readonly uid?: number; | ||
/** | ||
Not supported on Windows. | ||
*/ | ||
readonly cpu?: number; | ||
|
||
/** | ||
Not supported on Windows. | ||
*/ | ||
readonly memory?: number; | ||
|
||
/** | ||
Not supported on Windows. | ||
*/ | ||
readonly uid?: number; | ||
} | ||
} | ||
|
||
/** | ||
* Get running processes. | ||
* | ||
* @returns List of running processes. | ||
*/ | ||
export default function psList(options?: Options): Promise<ProcessDescriptor[]>; | ||
declare const psList: { | ||
/** | ||
Get running processes. | ||
@returns List of running processes. | ||
@example | ||
``` | ||
import psList = require('ps-list'); | ||
(async () => { | ||
console.log(await psList()); | ||
//=> [{pid: 3213, name: 'node', cmd: 'node test.js', ppid: 1, uid: 501, cpu: 0.1, memory: 1.5}, …] | ||
})(); | ||
``` | ||
*/ | ||
(options?: psList.Options): Promise<psList.ProcessDescriptor[]>; | ||
|
||
// TODO: remove this in the next major version, refactor the whole definition to: | ||
// declare function psList(options?: psList.Options): Promise<psList.ProcessDescriptor[]>; | ||
// export = psList; | ||
default: typeof psList; | ||
}; | ||
|
||
export = psList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters