querysub 0.216.0 → 0.218.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.216.0",
3
+ "version": "0.218.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -68,20 +68,27 @@ function textTableLineToObj(text: string): Record<string, string>[] {
68
68
  let dataLines = lines.slice(1);
69
69
 
70
70
  // Parse column positions from header
71
- let columns: { name: string; start: number; end: number }[] = [];
72
71
  let headerWords = headerLine.match(/\S+/g) || [];
73
- let currentPos = 0;
72
+ if (headerWords.length === 0) return [];
74
73
 
74
+ // Find column boundaries: start at 0, then at end of each header word (except last), then start of last header, then end of line
75
+ let boundaries: number[] = [0];
76
+ let searchPos = 0;
75
77
  for (let i = 0; i < headerWords.length; i++) {
76
78
  let word = headerWords[i];
77
- let start = headerLine.indexOf(word, currentPos);
78
- let end = i === headerWords.length - 1 ? headerLine.length : headerLine.indexOf(headerWords[i + 1], start + word.length);
79
+ searchPos = headerLine.indexOf(word, searchPos) + word.length;
80
+ boundaries.push(searchPos);
81
+ }
82
+ boundaries[boundaries.length - 1] = Number.MAX_SAFE_INTEGER;
83
+
84
+ // Create column definitions using boundaries
85
+ let columns: { name: string; start: number; end: number }[] = [];
86
+ for (let i = 0; i < headerWords.length; i++) {
79
87
  columns.push({
80
- name: word,
81
- start: start,
82
- end: end
88
+ name: headerWords[i],
89
+ start: boundaries[i],
90
+ end: boundaries[i + 1]
83
91
  });
84
- currentPos = start + word.length;
85
92
  }
86
93
 
87
94
  // Extract values from all data lines
@@ -97,18 +104,6 @@ function textTableLineToObj(text: string): Record<string, string>[] {
97
104
 
98
105
  return results;
99
106
  }
100
- async function getLinuxProcessInfo(pid: string) {
101
- try {
102
- let extraArgs = os.platform() !== "win32" && " -o ppid,cmd" || "";
103
- let psInfo = await runPromise(`ps -p ${pid}${extraArgs}`);
104
- let results = textTableLineToObj(psInfo);
105
- let obj = results[0] as { PPID: string; CMD: string };
106
- return obj;
107
- } catch (e: any) {
108
- console.warn(`Error getting tmux process info for ${pid}: ${e.stack}`);
109
- return undefined;
110
- }
111
- }
112
107
  const getLinuxChildPids = measureWrap(async function getLinuxChildPids(pid: string): Promise<{ PID: string; PPID: string; CMD: string }[]> {
113
108
  let prefix = getTmuxPrefix();
114
109
  if (os.platform() === "win32") {