querysub 0.217.0 → 0.219.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.217.0",
3
+ "version": "0.219.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,31 +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) || [];
72
+ if (headerWords.length === 0) return [];
73
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;
74
77
  for (let i = 0; i < headerWords.length; i++) {
75
78
  let word = headerWords[i];
76
- let wordStart = headerLine.indexOf(word, i === 0 ? 0 : columns[i - 1].end);
77
- let wordEnd = wordStart + word.length;
78
-
79
- let columnStart: number;
80
- let columnEnd: number;
81
-
82
- if (i === headerWords.length - 1) {
83
- // Last header: column starts at the start of header word and goes to end of line
84
- columnStart = wordStart;
85
- columnEnd = headerLine.length;
86
- } else {
87
- // Non-last headers: column starts after previous column and ends at end of header word
88
- columnStart = i === 0 ? 0 : columns[i - 1].end;
89
- columnEnd = wordEnd;
90
- }
79
+ searchPos = headerLine.indexOf(word, searchPos) + word.length;
80
+ boundaries.push(searchPos);
81
+ }
82
+ boundaries[boundaries.length - 1] = Number.MAX_SAFE_INTEGER;
83
+ console.log(`boundaries: ${JSON.stringify(boundaries)}`);
91
84
 
85
+ // Create column definitions using boundaries
86
+ let columns: { name: string; start: number; end: number }[] = [];
87
+ for (let i = 0; i < headerWords.length; i++) {
92
88
  columns.push({
93
- name: word,
94
- start: columnStart,
95
- end: columnEnd
89
+ name: headerWords[i],
90
+ start: boundaries[i],
91
+ end: boundaries[i + 1]
96
92
  });
97
93
  }
98
94
 
@@ -109,18 +105,6 @@ function textTableLineToObj(text: string): Record<string, string>[] {
109
105
 
110
106
  return results;
111
107
  }
112
- async function getLinuxProcessInfo(pid: string) {
113
- try {
114
- let extraArgs = os.platform() !== "win32" && " -o ppid,cmd" || "";
115
- let psInfo = await runPromise(`ps -p ${pid}${extraArgs}`);
116
- let results = textTableLineToObj(psInfo);
117
- let obj = results[0] as { PPID: string; CMD: string };
118
- return obj;
119
- } catch (e: any) {
120
- console.warn(`Error getting tmux process info for ${pid}: ${e.stack}`);
121
- return undefined;
122
- }
123
- }
124
108
  const getLinuxChildPids = measureWrap(async function getLinuxChildPids(pid: string): Promise<{ PID: string; PPID: string; CMD: string }[]> {
125
109
  let prefix = getTmuxPrefix();
126
110
  if (os.platform() === "win32") {