binary-collections 2.0.5 → 2.0.6

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.
Files changed (104) hide show
  1. package/bin/bash-dummy +7 -2
  2. package/bin/clean-nodemodule +7 -2
  3. package/bin/clean-nodemodules +7 -2
  4. package/bin/dev +7 -2
  5. package/bin/empty +7 -2
  6. package/bin/git-fix-encoding +7 -2
  7. package/bin/git-reduce-size +7 -2
  8. package/bin/kill-process +7 -2
  9. package/bin/nodekill +7 -2
  10. package/bin/prod +7 -2
  11. package/bin/rmfind +7 -2
  12. package/bin/rmpath +7 -2
  13. package/bin/rmx +9 -3
  14. package/bin/submodule +13 -2
  15. package/bin/submodule-install +7 -2
  16. package/bin/submodule-remove +7 -2
  17. package/eslint.config.cjs +97 -0
  18. package/lib/chunk-7MSZ52XC.mjs +14 -0
  19. package/lib/chunk-AVDT32AY.mjs +20 -0
  20. package/lib/chunk-E75HJFJO.mjs +20 -0
  21. package/lib/chunk-GA4DDV65.mjs +202 -0
  22. package/lib/chunk-LPLPQBYP.mjs +53 -0
  23. package/lib/chunk-M4IBUK4H.mjs +173 -0
  24. package/lib/chunk-S4SJ7SDW.mjs +625 -0
  25. package/lib/del-gradle.cjs +72 -0
  26. package/lib/del-gradle.d.mts +2 -0
  27. package/lib/del-gradle.d.ts +2 -0
  28. package/lib/del-gradle.js +72 -0
  29. package/lib/del-gradle.mjs +28 -0
  30. package/lib/del-node-modules.cjs +72 -0
  31. package/lib/del-node-modules.d.mts +2 -0
  32. package/lib/del-node-modules.d.ts +2 -0
  33. package/lib/del-node-modules.js +63 -10
  34. package/lib/del-node-modules.mjs +28 -0
  35. package/lib/del-ps.cjs +706 -0
  36. package/lib/del-ps.d.mts +2 -0
  37. package/lib/del-ps.d.ts +2 -0
  38. package/lib/del-ps.js +706 -0
  39. package/lib/del-ps.mjs +46 -0
  40. package/lib/del-yarn-caches.cjs +65 -0
  41. package/lib/del-yarn-caches.d.mts +2 -0
  42. package/lib/del-yarn-caches.d.ts +2 -0
  43. package/lib/del-yarn-caches.js +60 -6
  44. package/lib/del-yarn-caches.mjs +21 -0
  45. package/lib/find-node-modules.cjs +12 -0
  46. package/lib/find-node-modules.d.mts +2 -0
  47. package/lib/find-node-modules.d.ts +2 -0
  48. package/lib/find-node-modules.js +6 -7
  49. package/lib/find-node-modules.mjs +21 -0
  50. package/lib/git-purge.cjs +704 -0
  51. package/lib/git-purge.d.mts +2 -0
  52. package/lib/git-purge.d.ts +2 -0
  53. package/lib/git-purge.js +704 -0
  54. package/lib/git-purge.mjs +50 -0
  55. package/lib/index.cjs +2 -0
  56. package/lib/index.d.mts +2 -0
  57. package/lib/index.d.ts +2 -0
  58. package/{index.js → lib/index.js} +1 -0
  59. package/lib/index.mjs +9 -0
  60. package/lib/npm-run-series.cjs +61 -0
  61. package/lib/npm-run-series.d.mts +1 -0
  62. package/lib/npm-run-series.d.ts +1 -0
  63. package/lib/npm-run-series.js +37 -20
  64. package/lib/npm-run-series.mjs +47 -0
  65. package/lib/package-resolutions.cjs +28 -0
  66. package/lib/package-resolutions.d.mts +25 -0
  67. package/lib/package-resolutions.d.ts +25 -0
  68. package/lib/package-resolutions.js +28 -0
  69. package/lib/package-resolutions.mjs +31 -0
  70. package/lib/ps/connected-domain.cjs +156 -0
  71. package/lib/ps/connected-domain.d.mts +3 -0
  72. package/lib/ps/connected-domain.d.ts +3 -0
  73. package/lib/ps/connected-domain.js +156 -0
  74. package/lib/ps/connected-domain.mjs +7 -0
  75. package/lib/ps/index.cjs +555 -0
  76. package/lib/ps/index.d.cjs +17 -0
  77. package/lib/ps/index.d.d.mts +26 -0
  78. package/lib/ps/index.d.d.ts +26 -0
  79. package/lib/ps/index.d.js +17 -0
  80. package/lib/ps/index.d.mjs +8 -0
  81. package/lib/ps/index.d.mts +26 -0
  82. package/lib/ps/index.d.ts +26 -0
  83. package/lib/ps/index.js +555 -0
  84. package/lib/ps/index.mjs +203 -0
  85. package/lib/ps/isWin.cjs +3 -0
  86. package/lib/ps/isWin.d.mts +3 -0
  87. package/lib/ps/isWin.d.ts +3 -0
  88. package/lib/ps/isWin.js +3 -0
  89. package/lib/ps/isWin.mjs +7 -0
  90. package/lib/ps/table-parser.cjs +359 -0
  91. package/lib/ps/table-parser.d.mts +3 -0
  92. package/lib/ps/table-parser.d.ts +3 -0
  93. package/lib/ps/table-parser.js +359 -0
  94. package/lib/ps/table-parser.mjs +8 -0
  95. package/lib/utils.cjs +35 -0
  96. package/lib/utils.d.mts +20 -0
  97. package/lib/utils.d.ts +20 -0
  98. package/lib/utils.js +22 -23
  99. package/lib/utils.mjs +7 -0
  100. package/package.json +76 -32
  101. package/readme.md +23 -0
  102. package/src/ps/index.js +285 -0
  103. package/test/package.json +19 -0
  104. package/lib/package-resolutions.json +0 -22
@@ -0,0 +1,203 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_table_parser
4
+ } from "../chunk-GA4DDV65.mjs";
5
+ import "../chunk-M4IBUK4H.mjs";
6
+ import {
7
+ require_isWin
8
+ } from "../chunk-E75HJFJO.mjs";
9
+ import {
10
+ init_esm_shims
11
+ } from "../chunk-7MSZ52XC.mjs";
12
+ import {
13
+ __commonJS,
14
+ __require
15
+ } from "../chunk-AVDT32AY.mjs";
16
+
17
+ // src/ps/index.js
18
+ var require_ps = __commonJS({
19
+ "src/ps/index.js"(exports, module) {
20
+ init_esm_shims();
21
+ var ChildProcess = __require("child_process");
22
+ var IS_WIN = require_isWin();
23
+ var TableParser = require_table_parser();
24
+ var EOL = /(\r\n)|(\n\r)|\n|\r/;
25
+ var SystemEOL = __require("os").EOL;
26
+ var Exec = module.exports = exports = function(args, callback) {
27
+ var spawn = ChildProcess.spawn;
28
+ if (IS_WIN) {
29
+ var CMD = spawn("cmd");
30
+ var stdout = "";
31
+ var stderr = null;
32
+ CMD.stdout.on("data", function(data) {
33
+ stdout += data.toString();
34
+ });
35
+ CMD.stderr.on("data", function(data) {
36
+ if (stderr === null) {
37
+ stderr = data.toString();
38
+ } else {
39
+ stderr += data.toString();
40
+ }
41
+ });
42
+ CMD.on("exit", function() {
43
+ var beginRow;
44
+ stdout = stdout.split(EOL);
45
+ stdout.forEach(function(out, index) {
46
+ if (out && typeof beginRow == "undefined" && out.indexOf("CommandLine") === 0) {
47
+ beginRow = index;
48
+ }
49
+ });
50
+ stdout.splice(stdout.length - 1, 1);
51
+ stdout.splice(0, beginRow);
52
+ callback(stderr, stdout.join(SystemEOL) || false);
53
+ });
54
+ CMD.stdin.write("wmic process get ProcessId,ParentProcessId,CommandLine \n");
55
+ CMD.stdin.end();
56
+ } else {
57
+ if (typeof args === "string") {
58
+ args = args.split(/\s+/);
59
+ }
60
+ const child = spawn("ps", args);
61
+ stdout = "";
62
+ stderr = null;
63
+ child.stdout.on("data", function(data) {
64
+ stdout += data.toString();
65
+ });
66
+ child.stderr.on("data", function(data) {
67
+ if (stderr === null) {
68
+ stderr = data.toString();
69
+ } else {
70
+ stderr += data.toString();
71
+ }
72
+ });
73
+ child.on("exit", function() {
74
+ if (stderr) {
75
+ return callback(stderr.toString());
76
+ } else {
77
+ callback(null, stdout || false);
78
+ }
79
+ });
80
+ }
81
+ };
82
+ exports.lookup = function(query, callback) {
83
+ var exeArgs = query.psargs || ["lx"];
84
+ var filter = {};
85
+ var idList;
86
+ if (query.pid) {
87
+ if (Array.isArray(query.pid)) {
88
+ idList = query.pid;
89
+ } else {
90
+ idList = [query.pid];
91
+ }
92
+ idList = idList.map(function(v) {
93
+ return String(v);
94
+ });
95
+ }
96
+ if (query.command) {
97
+ filter["command"] = new RegExp(query.command, "i");
98
+ }
99
+ if (query.arguments) {
100
+ filter["arguments"] = new RegExp(query.arguments, "i");
101
+ }
102
+ if (query.ppid) {
103
+ filter["ppid"] = new RegExp(query.ppid);
104
+ }
105
+ return Exec(exeArgs, function(err, output) {
106
+ if (err) {
107
+ return callback(err);
108
+ } else {
109
+ var processList = parseGrid(output);
110
+ var resultList = [];
111
+ processList.forEach(function(p) {
112
+ var flt;
113
+ var type;
114
+ var result = true;
115
+ if (idList && idList.indexOf(String(p.pid)) < 0) {
116
+ return;
117
+ }
118
+ for (type in filter) {
119
+ flt = filter[type];
120
+ result = flt.test(p[type]) ? result : false;
121
+ }
122
+ if (result) {
123
+ resultList.push(p);
124
+ }
125
+ });
126
+ callback(null, resultList);
127
+ }
128
+ });
129
+ };
130
+ exports.kill = function(pid, signal, next) {
131
+ if (arguments.length == 2 && typeof signal == "function") {
132
+ next = signal;
133
+ signal = void 0;
134
+ }
135
+ var checkTimeoutSeconds = signal && signal.timeout || 30;
136
+ if (typeof signal === "object") {
137
+ signal = signal.signal;
138
+ }
139
+ try {
140
+ process.kill(pid, signal);
141
+ } catch (e) {
142
+ return next && next(e);
143
+ }
144
+ var checkConfident = 0;
145
+ var checkTimeoutTimer = null;
146
+ var checkIsTimeout = false;
147
+ function checkKilled(finishCallback) {
148
+ exports.lookup({ pid }, function(err, list) {
149
+ if (checkIsTimeout) return;
150
+ if (err) {
151
+ clearTimeout(checkTimeoutTimer);
152
+ finishCallback && finishCallback(err);
153
+ } else if (list.length > 0) {
154
+ checkConfident = checkConfident - 1 || 0;
155
+ checkKilled(finishCallback);
156
+ } else {
157
+ checkConfident++;
158
+ if (checkConfident === 5) {
159
+ clearTimeout(checkTimeoutTimer);
160
+ finishCallback && finishCallback();
161
+ } else {
162
+ checkKilled(finishCallback);
163
+ }
164
+ }
165
+ });
166
+ }
167
+ next && checkKilled(next);
168
+ checkTimeoutTimer = next && setTimeout(function() {
169
+ checkIsTimeout = true;
170
+ next(new Error("Kill process timeout"));
171
+ }, checkTimeoutSeconds * 1e3);
172
+ };
173
+ function parseGrid(output) {
174
+ if (!output) {
175
+ return [];
176
+ }
177
+ return formatOutput(TableParser.parse(output));
178
+ }
179
+ function formatOutput(data) {
180
+ var formatedData = [];
181
+ data.forEach(function(d) {
182
+ var pid = d.PID && d.PID[0] || d.ProcessId && d.ProcessId[0] || void 0;
183
+ var cmd = d.CMD || d.CommandLine || d.COMMAND || void 0;
184
+ var ppid = d.PPID && d.PPID[0] || d.ParentProcessId && d.ParentProcessId[0] || void 0;
185
+ if (pid && cmd) {
186
+ var command = cmd[0];
187
+ var args = "";
188
+ if (cmd.length > 1) {
189
+ args = cmd.slice(1);
190
+ }
191
+ formatedData.push({
192
+ pid,
193
+ command,
194
+ arguments: args,
195
+ ppid
196
+ });
197
+ }
198
+ });
199
+ return formatedData;
200
+ }
201
+ }
202
+ });
203
+ export default require_ps();
@@ -0,0 +1,3 @@
1
+ // src/ps/isWin.js
2
+ var isWin = process.platform === "win32";
3
+ module.exports = isWin;
@@ -0,0 +1,3 @@
1
+ declare const isWin: boolean;
2
+
3
+ export { isWin as default };
@@ -0,0 +1,3 @@
1
+ declare const isWin: boolean;
2
+
3
+ export { isWin as default };
@@ -0,0 +1,3 @@
1
+ // src/ps/isWin.js
2
+ var isWin = process.platform === "win32";
3
+ module.exports = isWin;
@@ -0,0 +1,7 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_isWin
4
+ } from "../chunk-E75HJFJO.mjs";
5
+ import "../chunk-7MSZ52XC.mjs";
6
+ import "../chunk-AVDT32AY.mjs";
7
+ export default require_isWin();
@@ -0,0 +1,359 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __esm = (fn, res) => function __init() {
3
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
+ };
5
+ var __commonJS = (cb, mod) => function __require() {
6
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7
+ };
8
+
9
+ // node_modules/tsup/assets/cjs_shims.js
10
+ var init_cjs_shims = __esm({
11
+ "node_modules/tsup/assets/cjs_shims.js"() {
12
+ }
13
+ });
14
+
15
+ // src/ps/connected-domain.js
16
+ var require_connected_domain = __commonJS({
17
+ "src/ps/connected-domain.js"(exports2, module2) {
18
+ init_cjs_shims();
19
+ module2.exports = function(tdArray, indicator, hardlink) {
20
+ hardlink = hardlink || false;
21
+ if (!tdArray) {
22
+ throw new Error("tdArray must be provided");
23
+ }
24
+ if (!indicator) {
25
+ throw new Error("indicator must be provided");
26
+ }
27
+ tdArray = JSON.parse(JSON.stringify(tdArray));
28
+ var domains = {};
29
+ var domainUUID = 0;
30
+ var pointsHash = {};
31
+ tdArray.forEach(function(row, y) {
32
+ row.forEach(function(colItem, x) {
33
+ var identifier2 = indicator(colItem, x, y);
34
+ var neighbours = [];
35
+ if (tdArray[y - 1] && tdArray[y - 1][x] !== void 0) {
36
+ neighbours.push(pointsHash[x + "_" + (y - 1)]);
37
+ }
38
+ if (row[x - 1] !== void 0) {
39
+ neighbours.push(pointsHash[x - 1 + "_" + y]);
40
+ }
41
+ if (!hardlink) {
42
+ if (tdArray[y - 1] && tdArray[y - 1][x - 1] !== void 0) {
43
+ neighbours.push(pointsHash[x - 1 + "_" + (y - 1)]);
44
+ }
45
+ if (tdArray[y - 1] && tdArray[y - 1][x + 1] !== void 0) {
46
+ neighbours.push(pointsHash[x + 1 + "_" + (y - 1)]);
47
+ }
48
+ }
49
+ if (neighbours.length) {
50
+ var matched = false;
51
+ neighbours.forEach(function(neighbour) {
52
+ if (neighbour.identifier == identifier2) {
53
+ if (!matched) {
54
+ addPointToDomain(colItem, x, y, neighbour.domainId);
55
+ matched = true;
56
+ } else {
57
+ var colItemPoint = pointsHash[x + "_" + y];
58
+ if (neighbour.domainId != colItemPoint.domainId) {
59
+ mergeDomains(neighbour.domainId, colItemPoint.domainId);
60
+ }
61
+ }
62
+ }
63
+ });
64
+ if (!matched) {
65
+ addNewDomain(colItem, x, y, identifier2);
66
+ }
67
+ } else {
68
+ addNewDomain(colItem, x, y, identifier2);
69
+ }
70
+ });
71
+ });
72
+ var result = {
73
+ domains: [],
74
+ totalDomains: 0,
75
+ groupByIdentifier: {},
76
+ totalIdentifiers: 0
77
+ };
78
+ var domainId = null;
79
+ var identifier = null;
80
+ var domain = null;
81
+ for (domainId in domains) {
82
+ domain = domains[domainId];
83
+ domain.bounding = calculateBounding(domain.points);
84
+ identifier = domain.identifier;
85
+ result.domains.push(domain);
86
+ result.totalDomains++;
87
+ if (!(identifier in result.groupByIdentifier)) {
88
+ result.groupByIdentifier[identifier] = [];
89
+ result.totalIdentifiers++;
90
+ }
91
+ result.groupByIdentifier[identifier].push(domain);
92
+ }
93
+ function calculateBounding(points) {
94
+ var minX = null;
95
+ var minY = null;
96
+ var maxX = null;
97
+ var maxY = null;
98
+ points.forEach(function(point) {
99
+ if (minX === null || point.x < minX) {
100
+ minX = point.x;
101
+ }
102
+ if (minY === null || point.y < minY) {
103
+ minY = point.y;
104
+ }
105
+ if (maxX === null || point.x > maxX) {
106
+ maxX = point.x;
107
+ }
108
+ if (maxY === null || point.y > maxY) {
109
+ maxY = point.y;
110
+ }
111
+ });
112
+ var w = maxX - minX;
113
+ var h = maxY - minY;
114
+ return {
115
+ x: minX,
116
+ y: minY,
117
+ w,
118
+ h
119
+ };
120
+ }
121
+ function addNewDomain(point, x, y, identifier2) {
122
+ var newDomain = {
123
+ identifier: identifier2,
124
+ domainId: ++domainUUID,
125
+ bounding: {},
126
+ points: []
127
+ };
128
+ var newPoint = {
129
+ value: point,
130
+ x,
131
+ y,
132
+ identifier: identifier2,
133
+ domainId: newDomain.domainId
134
+ };
135
+ pointsHash[x + "_" + y] = {
136
+ value: point,
137
+ identifier: identifier2,
138
+ domainId: newDomain.domainId
139
+ };
140
+ newDomain.points.push(newPoint);
141
+ domains[newDomain.domainId] = newDomain;
142
+ }
143
+ function addPointToDomain(point, x, y, domainId2) {
144
+ var domain2 = domains[domainId2];
145
+ var newPoint = {
146
+ value: point,
147
+ x,
148
+ y,
149
+ identifier: domain2.identifier,
150
+ domainId: domainId2
151
+ };
152
+ pointsHash[x + "_" + y] = {
153
+ value: point,
154
+ identifier: domain2.identifier,
155
+ domainId: domainId2
156
+ };
157
+ domain2.points.push(newPoint);
158
+ }
159
+ function mergeDomains(domainAId, domainBId) {
160
+ var domainA = domains[domainAId];
161
+ var domainB = domains[domainBId];
162
+ if (domainA.identifier == domainB.identifier) {
163
+ domainB.domainId = domainA.domainId;
164
+ domainB.points.forEach(function(point) {
165
+ point.domainId = domainA.domainId;
166
+ pointsHash[point.x + "_" + point.y].domainId = domainA.domainId;
167
+ });
168
+ domainA.points = domainA.points.concat(domainB.points);
169
+ delete domains[domainBId];
170
+ }
171
+ }
172
+ return result;
173
+ };
174
+ }
175
+ });
176
+
177
+ // src/ps/table-parser.js
178
+ init_cjs_shims();
179
+ var ConnectedDomain = require_connected_domain();
180
+ var EMPTY_EX = /\s/;
181
+ module.exports.parse = function(output) {
182
+ var linesTmp = output.split(/(\r\n)|(\n\r)|\n|\r/);
183
+ var lines = [];
184
+ var titleInfo = {};
185
+ var twoDimArray = [];
186
+ linesTmp.forEach(function(line) {
187
+ if (line && line.trim()) {
188
+ lines.push(line);
189
+ }
190
+ });
191
+ lines.forEach(function(line, index) {
192
+ if (index == 0) {
193
+ var fields = line.split(/\s+/);
194
+ var currentIndex = 0;
195
+ fields.forEach(function(field, idx) {
196
+ if (field) {
197
+ var info = titleInfo[field] = {};
198
+ var indexBegin = line.indexOf(field, currentIndex);
199
+ var indexEnd = currentIndex = indexBegin + field.length;
200
+ if (idx == 0) {
201
+ info.titleBegin = 0;
202
+ } else {
203
+ info.titleBegin = indexBegin;
204
+ }
205
+ if (idx == fields.length - 1) {
206
+ info.titleEnd = line.length - 1;
207
+ } else {
208
+ info.titleEnd = indexEnd;
209
+ }
210
+ }
211
+ });
212
+ } else {
213
+ twoDimArray[index - 1] = line.split("");
214
+ }
215
+ });
216
+ var connectedDomains = ConnectedDomain(
217
+ twoDimArray,
218
+ function(value) {
219
+ if (EMPTY_EX.test(value)) {
220
+ return -1;
221
+ } else {
222
+ return 1;
223
+ }
224
+ },
225
+ true
226
+ );
227
+ var valuesDomainsVerticalGroups = [];
228
+ connectedDomains.domains.sort(function(a, b) {
229
+ return a.bounding.x - b.bounding.x;
230
+ });
231
+ connectedDomains.domains.forEach(function(domain) {
232
+ if (domain.identifier === 1) {
233
+ var overlapped = false;
234
+ valuesDomainsVerticalGroups.forEach(function(group) {
235
+ var bounding = domain.bounding;
236
+ var left = bounding.x;
237
+ var right = bounding.x + bounding.w;
238
+ if (overlap(left, right, group.begin, group.end)) {
239
+ overlapped = true;
240
+ group.domains.push(domain);
241
+ group.begin = group.begin > left ? left : group.begin;
242
+ group.end = group.end < right ? right : group.end;
243
+ }
244
+ });
245
+ if (!overlapped) {
246
+ valuesDomainsVerticalGroups.push({
247
+ begin: domain.bounding.x,
248
+ end: domain.bounding.x + domain.bounding.w,
249
+ domains: [domain]
250
+ });
251
+ }
252
+ }
253
+ });
254
+ valuesDomainsVerticalGroups.forEach(function(group) {
255
+ var title = null;
256
+ var info = null;
257
+ var overlapped = false;
258
+ var minimunLeftDistance = null;
259
+ var nearestLeftTitle = null;
260
+ var distance = null;
261
+ for (title in titleInfo) {
262
+ info = titleInfo[title];
263
+ if (group.begin > info.titleBegin) {
264
+ distance = group.begin - info.titleBegin;
265
+ if (!nearestLeftTitle || distance < minimunLeftDistance) {
266
+ nearestLeftTitle = title;
267
+ minimunLeftDistance = distance;
268
+ }
269
+ }
270
+ if (overlap(group.begin, group.end, info.titleBegin, info.titleEnd)) {
271
+ overlapped = true;
272
+ info.titleBegin = info.titleBegin > group.begin ? group.begin : info.titleBegin;
273
+ info.titleEnd = info.titleEnd < group.end ? group.end : info.titleEnd;
274
+ }
275
+ }
276
+ if (!overlapped && nearestLeftTitle) {
277
+ var nearestTitleField = titleInfo[nearestLeftTitle];
278
+ nearestTitleField.titleBegin = nearestTitleField.titleBegin > group.begin ? group.begin : nearestTitleField.titleBegin;
279
+ nearestTitleField.titleEnd = nearestTitleField.titleEnd < group.end ? group.end : nearestTitleField.titleEnd;
280
+ }
281
+ });
282
+ var result = [];
283
+ lines.forEach(function(line, index) {
284
+ if (index > 0) {
285
+ var lineItem = {};
286
+ var title = null;
287
+ var info = null;
288
+ var value = null;
289
+ for (title in titleInfo) {
290
+ info = titleInfo[title];
291
+ value = line.substring(info.titleBegin, info.titleEnd + 1);
292
+ lineItem[title] = splitValue(value.trim());
293
+ }
294
+ result.push(lineItem);
295
+ }
296
+ });
297
+ return result;
298
+ };
299
+ function overlap(begin1, end1, begin2, end2) {
300
+ return begin1 > begin2 && begin1 < end2 || // 2--1--2--1 or 2--1--1--2
301
+ end1 > begin2 && end1 < end2 || // 1--2--1--2 or 2--1--1--2
302
+ begin1 <= begin2 && end1 >= end2;
303
+ }
304
+ function splitValue(value) {
305
+ var match = value.match(/"/g);
306
+ if (!match || match.length == 1) {
307
+ return value.split(/\s+/);
308
+ } else {
309
+ var result = [];
310
+ var chunk = null;
311
+ var ifInWrappedChunk = false;
312
+ var ifInPureWrappedChunk = false;
313
+ var quotaCount = 0;
314
+ var maxQuotaCount = match.length % 2 == 0 ? match.length : match.length - 1;
315
+ var previousItem = null;
316
+ var values = value.split("");
317
+ values.forEach(function(item, index) {
318
+ if (item !== " ") {
319
+ if (item === '"') {
320
+ if (ifInWrappedChunk === false && quotaCount <= maxQuotaCount) {
321
+ ifInWrappedChunk = true;
322
+ quotaCount++;
323
+ if (previousItem === " " || previousItem === null) {
324
+ ifInPureWrappedChunk = true;
325
+ chunk = "";
326
+ } else {
327
+ chunk += item;
328
+ }
329
+ } else if (ifInWrappedChunk === true) {
330
+ ifInWrappedChunk = false;
331
+ quotaCount++;
332
+ if (ifInPureWrappedChunk === true) {
333
+ ifInPureWrappedChunk = false;
334
+ result.push(chunk);
335
+ chunk = null;
336
+ } else {
337
+ chunk += item;
338
+ }
339
+ }
340
+ } else if (ifInWrappedChunk === false && (previousItem === " " || previousItem === null)) {
341
+ chunk = item;
342
+ } else {
343
+ chunk += item;
344
+ }
345
+ } else if (ifInWrappedChunk) {
346
+ chunk += item;
347
+ } else if (chunk !== null) {
348
+ result.push(chunk);
349
+ chunk = null;
350
+ }
351
+ previousItem = item;
352
+ if (index == values.length - 1 && chunk !== null) {
353
+ result.push(chunk);
354
+ chunk = null;
355
+ }
356
+ });
357
+ return result;
358
+ }
359
+ }
@@ -0,0 +1,3 @@
1
+ declare function parse(output: any): any[];
2
+
3
+ export { parse };
@@ -0,0 +1,3 @@
1
+ declare function parse(output: any): any[];
2
+
3
+ export { parse };