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,202 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_connected_domain
4
+ } from "./chunk-M4IBUK4H.mjs";
5
+ import {
6
+ init_esm_shims
7
+ } from "./chunk-7MSZ52XC.mjs";
8
+ import {
9
+ __commonJS
10
+ } from "./chunk-AVDT32AY.mjs";
11
+
12
+ // src/ps/table-parser.js
13
+ var require_table_parser = __commonJS({
14
+ "src/ps/table-parser.js"(exports, module) {
15
+ init_esm_shims();
16
+ var ConnectedDomain = require_connected_domain();
17
+ var EMPTY_EX = /\s/;
18
+ module.exports.parse = function(output) {
19
+ var linesTmp = output.split(/(\r\n)|(\n\r)|\n|\r/);
20
+ var lines = [];
21
+ var titleInfo = {};
22
+ var twoDimArray = [];
23
+ linesTmp.forEach(function(line) {
24
+ if (line && line.trim()) {
25
+ lines.push(line);
26
+ }
27
+ });
28
+ lines.forEach(function(line, index) {
29
+ if (index == 0) {
30
+ var fields = line.split(/\s+/);
31
+ var currentIndex = 0;
32
+ fields.forEach(function(field, idx) {
33
+ if (field) {
34
+ var info = titleInfo[field] = {};
35
+ var indexBegin = line.indexOf(field, currentIndex);
36
+ var indexEnd = currentIndex = indexBegin + field.length;
37
+ if (idx == 0) {
38
+ info.titleBegin = 0;
39
+ } else {
40
+ info.titleBegin = indexBegin;
41
+ }
42
+ if (idx == fields.length - 1) {
43
+ info.titleEnd = line.length - 1;
44
+ } else {
45
+ info.titleEnd = indexEnd;
46
+ }
47
+ }
48
+ });
49
+ } else {
50
+ twoDimArray[index - 1] = line.split("");
51
+ }
52
+ });
53
+ var connectedDomains = ConnectedDomain(
54
+ twoDimArray,
55
+ function(value) {
56
+ if (EMPTY_EX.test(value)) {
57
+ return -1;
58
+ } else {
59
+ return 1;
60
+ }
61
+ },
62
+ true
63
+ );
64
+ var valuesDomainsVerticalGroups = [];
65
+ connectedDomains.domains.sort(function(a, b) {
66
+ return a.bounding.x - b.bounding.x;
67
+ });
68
+ connectedDomains.domains.forEach(function(domain) {
69
+ if (domain.identifier === 1) {
70
+ var overlapped = false;
71
+ valuesDomainsVerticalGroups.forEach(function(group) {
72
+ var bounding = domain.bounding;
73
+ var left = bounding.x;
74
+ var right = bounding.x + bounding.w;
75
+ if (overlap(left, right, group.begin, group.end)) {
76
+ overlapped = true;
77
+ group.domains.push(domain);
78
+ group.begin = group.begin > left ? left : group.begin;
79
+ group.end = group.end < right ? right : group.end;
80
+ }
81
+ });
82
+ if (!overlapped) {
83
+ valuesDomainsVerticalGroups.push({
84
+ begin: domain.bounding.x,
85
+ end: domain.bounding.x + domain.bounding.w,
86
+ domains: [domain]
87
+ });
88
+ }
89
+ }
90
+ });
91
+ valuesDomainsVerticalGroups.forEach(function(group) {
92
+ var title = null;
93
+ var info = null;
94
+ var overlapped = false;
95
+ var minimunLeftDistance = null;
96
+ var nearestLeftTitle = null;
97
+ var distance = null;
98
+ for (title in titleInfo) {
99
+ info = titleInfo[title];
100
+ if (group.begin > info.titleBegin) {
101
+ distance = group.begin - info.titleBegin;
102
+ if (!nearestLeftTitle || distance < minimunLeftDistance) {
103
+ nearestLeftTitle = title;
104
+ minimunLeftDistance = distance;
105
+ }
106
+ }
107
+ if (overlap(group.begin, group.end, info.titleBegin, info.titleEnd)) {
108
+ overlapped = true;
109
+ info.titleBegin = info.titleBegin > group.begin ? group.begin : info.titleBegin;
110
+ info.titleEnd = info.titleEnd < group.end ? group.end : info.titleEnd;
111
+ }
112
+ }
113
+ if (!overlapped && nearestLeftTitle) {
114
+ var nearestTitleField = titleInfo[nearestLeftTitle];
115
+ nearestTitleField.titleBegin = nearestTitleField.titleBegin > group.begin ? group.begin : nearestTitleField.titleBegin;
116
+ nearestTitleField.titleEnd = nearestTitleField.titleEnd < group.end ? group.end : nearestTitleField.titleEnd;
117
+ }
118
+ });
119
+ var result = [];
120
+ lines.forEach(function(line, index) {
121
+ if (index > 0) {
122
+ var lineItem = {};
123
+ var title = null;
124
+ var info = null;
125
+ var value = null;
126
+ for (title in titleInfo) {
127
+ info = titleInfo[title];
128
+ value = line.substring(info.titleBegin, info.titleEnd + 1);
129
+ lineItem[title] = splitValue(value.trim());
130
+ }
131
+ result.push(lineItem);
132
+ }
133
+ });
134
+ return result;
135
+ };
136
+ function overlap(begin1, end1, begin2, end2) {
137
+ return begin1 > begin2 && begin1 < end2 || // 2--1--2--1 or 2--1--1--2
138
+ end1 > begin2 && end1 < end2 || // 1--2--1--2 or 2--1--1--2
139
+ begin1 <= begin2 && end1 >= end2;
140
+ }
141
+ function splitValue(value) {
142
+ var match = value.match(/"/g);
143
+ if (!match || match.length == 1) {
144
+ return value.split(/\s+/);
145
+ } else {
146
+ var result = [];
147
+ var chunk = null;
148
+ var ifInWrappedChunk = false;
149
+ var ifInPureWrappedChunk = false;
150
+ var quotaCount = 0;
151
+ var maxQuotaCount = match.length % 2 == 0 ? match.length : match.length - 1;
152
+ var previousItem = null;
153
+ var values = value.split("");
154
+ values.forEach(function(item, index) {
155
+ if (item !== " ") {
156
+ if (item === '"') {
157
+ if (ifInWrappedChunk === false && quotaCount <= maxQuotaCount) {
158
+ ifInWrappedChunk = true;
159
+ quotaCount++;
160
+ if (previousItem === " " || previousItem === null) {
161
+ ifInPureWrappedChunk = true;
162
+ chunk = "";
163
+ } else {
164
+ chunk += item;
165
+ }
166
+ } else if (ifInWrappedChunk === true) {
167
+ ifInWrappedChunk = false;
168
+ quotaCount++;
169
+ if (ifInPureWrappedChunk === true) {
170
+ ifInPureWrappedChunk = false;
171
+ result.push(chunk);
172
+ chunk = null;
173
+ } else {
174
+ chunk += item;
175
+ }
176
+ }
177
+ } else if (ifInWrappedChunk === false && (previousItem === " " || previousItem === null)) {
178
+ chunk = item;
179
+ } else {
180
+ chunk += item;
181
+ }
182
+ } else if (ifInWrappedChunk) {
183
+ chunk += item;
184
+ } else if (chunk !== null) {
185
+ result.push(chunk);
186
+ chunk = null;
187
+ }
188
+ previousItem = item;
189
+ if (index == values.length - 1 && chunk !== null) {
190
+ result.push(chunk);
191
+ chunk = null;
192
+ }
193
+ });
194
+ return result;
195
+ }
196
+ }
197
+ }
198
+ });
199
+
200
+ export {
201
+ require_table_parser
202
+ };
@@ -0,0 +1,53 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ init_esm_shims
4
+ } from "./chunk-7MSZ52XC.mjs";
5
+ import {
6
+ __commonJS,
7
+ __require
8
+ } from "./chunk-AVDT32AY.mjs";
9
+
10
+ // src/utils.js
11
+ var require_utils = __commonJS({
12
+ "src/utils.js"(exports, module) {
13
+ init_esm_shims();
14
+ var { fs, path } = __require("sbg-utility");
15
+ var argv = __require("minimist")(process.argv.slice(2));
16
+ function getArgs() {
17
+ return argv;
18
+ }
19
+ function delStream(globStream) {
20
+ globStream.stream().on("data", (result) => {
21
+ const fullPath = path.resolve(process.cwd(), result);
22
+ if (fs.statSync(fullPath).isDirectory()) {
23
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
24
+ for (let i = 0; i < subdir.length; i++) {
25
+ del(subdir[i]);
26
+ }
27
+ }
28
+ del(fullPath);
29
+ });
30
+ }
31
+ function del(fullPath) {
32
+ if (fs.statSync(fullPath).isDirectory()) {
33
+ const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
34
+ for (let i = 0; i < subdir.length; i++) {
35
+ del(subdir[i]);
36
+ }
37
+ } else {
38
+ try {
39
+ fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
40
+ console.log("deleted", fullPath);
41
+ } catch (_) {
42
+ console.log("failed delete", fullPath);
43
+ }
44
+ }
45
+ }
46
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
47
+ module.exports = { del, delStream, getArgs, delay };
48
+ }
49
+ });
50
+
51
+ export {
52
+ require_utils
53
+ };
@@ -0,0 +1,173 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ init_esm_shims
4
+ } from "./chunk-7MSZ52XC.mjs";
5
+ import {
6
+ __commonJS
7
+ } from "./chunk-AVDT32AY.mjs";
8
+
9
+ // src/ps/connected-domain.js
10
+ var require_connected_domain = __commonJS({
11
+ "src/ps/connected-domain.js"(exports, module) {
12
+ init_esm_shims();
13
+ module.exports = function(tdArray, indicator, hardlink) {
14
+ hardlink = hardlink || false;
15
+ if (!tdArray) {
16
+ throw new Error("tdArray must be provided");
17
+ }
18
+ if (!indicator) {
19
+ throw new Error("indicator must be provided");
20
+ }
21
+ tdArray = JSON.parse(JSON.stringify(tdArray));
22
+ var domains = {};
23
+ var domainUUID = 0;
24
+ var pointsHash = {};
25
+ tdArray.forEach(function(row, y) {
26
+ row.forEach(function(colItem, x) {
27
+ var identifier2 = indicator(colItem, x, y);
28
+ var neighbours = [];
29
+ if (tdArray[y - 1] && tdArray[y - 1][x] !== void 0) {
30
+ neighbours.push(pointsHash[x + "_" + (y - 1)]);
31
+ }
32
+ if (row[x - 1] !== void 0) {
33
+ neighbours.push(pointsHash[x - 1 + "_" + y]);
34
+ }
35
+ if (!hardlink) {
36
+ if (tdArray[y - 1] && tdArray[y - 1][x - 1] !== void 0) {
37
+ neighbours.push(pointsHash[x - 1 + "_" + (y - 1)]);
38
+ }
39
+ if (tdArray[y - 1] && tdArray[y - 1][x + 1] !== void 0) {
40
+ neighbours.push(pointsHash[x + 1 + "_" + (y - 1)]);
41
+ }
42
+ }
43
+ if (neighbours.length) {
44
+ var matched = false;
45
+ neighbours.forEach(function(neighbour) {
46
+ if (neighbour.identifier == identifier2) {
47
+ if (!matched) {
48
+ addPointToDomain(colItem, x, y, neighbour.domainId);
49
+ matched = true;
50
+ } else {
51
+ var colItemPoint = pointsHash[x + "_" + y];
52
+ if (neighbour.domainId != colItemPoint.domainId) {
53
+ mergeDomains(neighbour.domainId, colItemPoint.domainId);
54
+ }
55
+ }
56
+ }
57
+ });
58
+ if (!matched) {
59
+ addNewDomain(colItem, x, y, identifier2);
60
+ }
61
+ } else {
62
+ addNewDomain(colItem, x, y, identifier2);
63
+ }
64
+ });
65
+ });
66
+ var result = {
67
+ domains: [],
68
+ totalDomains: 0,
69
+ groupByIdentifier: {},
70
+ totalIdentifiers: 0
71
+ };
72
+ var domainId = null;
73
+ var identifier = null;
74
+ var domain = null;
75
+ for (domainId in domains) {
76
+ domain = domains[domainId];
77
+ domain.bounding = calculateBounding(domain.points);
78
+ identifier = domain.identifier;
79
+ result.domains.push(domain);
80
+ result.totalDomains++;
81
+ if (!(identifier in result.groupByIdentifier)) {
82
+ result.groupByIdentifier[identifier] = [];
83
+ result.totalIdentifiers++;
84
+ }
85
+ result.groupByIdentifier[identifier].push(domain);
86
+ }
87
+ function calculateBounding(points) {
88
+ var minX = null;
89
+ var minY = null;
90
+ var maxX = null;
91
+ var maxY = null;
92
+ points.forEach(function(point) {
93
+ if (minX === null || point.x < minX) {
94
+ minX = point.x;
95
+ }
96
+ if (minY === null || point.y < minY) {
97
+ minY = point.y;
98
+ }
99
+ if (maxX === null || point.x > maxX) {
100
+ maxX = point.x;
101
+ }
102
+ if (maxY === null || point.y > maxY) {
103
+ maxY = point.y;
104
+ }
105
+ });
106
+ var w = maxX - minX;
107
+ var h = maxY - minY;
108
+ return {
109
+ x: minX,
110
+ y: minY,
111
+ w,
112
+ h
113
+ };
114
+ }
115
+ function addNewDomain(point, x, y, identifier2) {
116
+ var newDomain = {
117
+ identifier: identifier2,
118
+ domainId: ++domainUUID,
119
+ bounding: {},
120
+ points: []
121
+ };
122
+ var newPoint = {
123
+ value: point,
124
+ x,
125
+ y,
126
+ identifier: identifier2,
127
+ domainId: newDomain.domainId
128
+ };
129
+ pointsHash[x + "_" + y] = {
130
+ value: point,
131
+ identifier: identifier2,
132
+ domainId: newDomain.domainId
133
+ };
134
+ newDomain.points.push(newPoint);
135
+ domains[newDomain.domainId] = newDomain;
136
+ }
137
+ function addPointToDomain(point, x, y, domainId2) {
138
+ var domain2 = domains[domainId2];
139
+ var newPoint = {
140
+ value: point,
141
+ x,
142
+ y,
143
+ identifier: domain2.identifier,
144
+ domainId: domainId2
145
+ };
146
+ pointsHash[x + "_" + y] = {
147
+ value: point,
148
+ identifier: domain2.identifier,
149
+ domainId: domainId2
150
+ };
151
+ domain2.points.push(newPoint);
152
+ }
153
+ function mergeDomains(domainAId, domainBId) {
154
+ var domainA = domains[domainAId];
155
+ var domainB = domains[domainBId];
156
+ if (domainA.identifier == domainB.identifier) {
157
+ domainB.domainId = domainA.domainId;
158
+ domainB.points.forEach(function(point) {
159
+ point.domainId = domainA.domainId;
160
+ pointsHash[point.x + "_" + point.y].domainId = domainA.domainId;
161
+ });
162
+ domainA.points = domainA.points.concat(domainB.points);
163
+ delete domains[domainBId];
164
+ }
165
+ }
166
+ return result;
167
+ };
168
+ }
169
+ });
170
+
171
+ export {
172
+ require_connected_domain
173
+ };