expose-kit 0.2.8 → 0.3.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/dist/index.js +34 -7
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -143,16 +143,43 @@ var patchDefault = (babelFn) => {
|
|
|
143
143
|
|
|
144
144
|
// utils/common/diff.ts
|
|
145
145
|
function diff(before, after) {
|
|
146
|
-
const
|
|
147
|
-
const
|
|
146
|
+
const b = before.split(/\r?\n/);
|
|
147
|
+
const a = after.split(/\r?\n/);
|
|
148
|
+
const n = b.length;
|
|
149
|
+
const m = a.length;
|
|
150
|
+
const dp = Array.from(
|
|
151
|
+
{ length: n + 1 },
|
|
152
|
+
() => Array(m + 1).fill(0)
|
|
153
|
+
);
|
|
154
|
+
for (let i2 = 0; i2 < n; i2++) {
|
|
155
|
+
for (let j2 = 0; j2 < m; j2++) {
|
|
156
|
+
if (b[i2] === a[j2]) {
|
|
157
|
+
(dp[i2 + 1] || [])[j2 + 1] = (dp[i2]?.[j2] ?? 0) + 1;
|
|
158
|
+
} else {
|
|
159
|
+
(dp[i2 + 1] || [])[j2 + 1] = Math.max(
|
|
160
|
+
dp[i2]?.[j2 + 1] ?? 0,
|
|
161
|
+
dp[i2 + 1]?.[j2] ?? 0
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
148
166
|
const changed = [];
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
167
|
+
let i = n;
|
|
168
|
+
let j = m;
|
|
169
|
+
while (i > 0 || j > 0) {
|
|
170
|
+
if (i > 0 && j > 0 && b[i - 1] === a[j - 1]) {
|
|
171
|
+
i--;
|
|
172
|
+
j--;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (j > 0 && (i === 0 || (dp[i]?.[j - 1] ?? 0) >= (dp[i - 1]?.[j] ?? 0))) {
|
|
176
|
+
changed.push(j);
|
|
177
|
+
j--;
|
|
178
|
+
} else {
|
|
179
|
+
i--;
|
|
153
180
|
}
|
|
154
181
|
}
|
|
155
|
-
return changed;
|
|
182
|
+
return changed.reverse();
|
|
156
183
|
}
|
|
157
184
|
|
|
158
185
|
// commands/safe-scope/index.ts
|
package/dist/package.json
CHANGED