Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provide tree API #2

Merged
merged 1 commit into from
Mar 26, 2024
Merged

feat: provide tree API #2

merged 1 commit into from
Mar 26, 2024

Conversation

antongolub
Copy link
Member

tree()

Returns a child processes list by the specified parent pid. Some kind of shortcut for lookup({ppid: pid}).

import { tree } from '@webpod/ps'

const children = await tree(123) 
/**
[
  {pid: 124, ppid: 123},
  {pid: 125, ppid: 123}
] 
*/

To obtain all nested children, set recursive option to true:

const children = await tree({pid: 123, recursive: true}) 
/**
[
  {pid: 124, ppid: 123},
  {pid: 125, ppid: 123},

  {pid: 126, ppid: 124},
  {pid: 127, ppid: 124},
  {pid: 128, ppid: 124},
  
  {pid: 129, ppid: 125},
  {pid: 130, ppid: 125},
] 
*/

@antonmedv antonmedv merged commit f4948db into main Mar 26, 2024
5 checks passed
@antongolub antongolub deleted the add-tree-api branch March 26, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants