function getRawProcessList()

in lib/index.ts [74:100]


function getRawProcessList(
  pid: number,
  queue: RequestQueue,
  callback: (processList: IProcessInfo[] | IProcessTreeNode) => void,
  filter: (pid: number, processList: IProcessInfo[], maxDepth: number) => IProcessInfo[] | IProcessTreeNode,
  flags?: ProcessDataFlag
): void {
  queue.push({
    callback: callback,
    rootPid: pid
  });

  // Only make a new request if there is not currently a request in progress.
  // This prevents too many requests from being made, there is also a crash that
  // can occur when performing multiple calls to CreateToolhelp32Snapshot at
  // once.
  if (!requestInProgress) {
    requestInProgress = true;
    native.getProcessList((processList: IProcessInfo[]) => {
      queue.forEach(r => {
        r.callback(filter(r.rootPid, processList, MAX_FILTER_DEPTH));
      });
      queue.length = 0;
      requestInProgress = false;
    }, flags || 0);
  }
}