@preventive/compare 1.0.0 → 1.0.1
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/compare.d.ts +0 -2
- package/names.d.ts +0 -2
- package/package.json +1 -1
- package/pretty.d.ts +0 -2
- package/src/renames.js +7 -6
package/compare.d.ts
CHANGED
package/names.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preventive/compare",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Two file trees compared as git diff compares them, with their line change sets and the patch git writes; and minified JavaScript compared with its layout and its renamed names set aside, each step checked to hide no change",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./compare.js",
|
package/pretty.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Hand-written against pretty.js; a change to either belongs with the other.
|
|
2
|
-
|
|
3
1
|
// `text` formatted by oxfmt as a file with `extension`, changing what is written
|
|
4
2
|
// no more than layout needs (keys keep their quotes, no trailing commas or arrow
|
|
5
3
|
// parentheses are added, template literals stay), the copy used only where checks
|
package/src/renames.js
CHANGED
|
@@ -70,11 +70,12 @@ function familyKeys(path) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// Whether either file of a pair by path has a candidate that is a rename by
|
|
73
|
-
// itself and scores at least halfway from the pair's score to 100
|
|
73
|
+
// itself and scores at least halfway from the pair's score to 100%: sizes too
|
|
74
|
+
// far apart for that go unread.
|
|
74
75
|
function outdone({ pairs, used, scoreOf }, { remaining, open }, { s, d, score }, minimum) {
|
|
75
76
|
const better = Math.max(minimum, score + Math.trunc((MAX_SCORE - score) / 2))
|
|
76
|
-
return open.some((o) => o !== d && !pairs.has(o) && scoreOf(s, o,
|
|
77
|
-
|| remaining.some((r) => r !== s && !used.has(r) && scoreOf(r, d,
|
|
77
|
+
return open.some((o) => o !== d && !pairs.has(o) && scoreOf(s, o, better) >= better)
|
|
78
|
+
|| remaining.some((r) => r !== s && !used.has(r) && scoreOf(r, d, better) >= better)
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
// Paths a build changes: however a pair scores, the best of a file's partners.
|
|
@@ -115,11 +116,11 @@ function familyRenames(context, left, weigh, minimum) {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
// Renames told by path, which git does not look for.
|
|
119
|
-
// other candidate is scored, so none can be better.
|
|
119
|
+
// Renames told by path, which git does not look for. Under -M100%, or past the
|
|
120
|
+
// rename limit, no other candidate is scored, so none can be better.
|
|
120
121
|
function pathRenames(context, minimum, limit) {
|
|
121
122
|
const left = unpaired(context)
|
|
122
|
-
const weigh = left.remaining.length * left.open.length <= limit * limit
|
|
123
|
+
const weigh = minimum < MAX_SCORE && left.remaining.length * left.open.length <= limit * limit
|
|
123
124
|
buildRenames(context, left, weigh, minimum)
|
|
124
125
|
familyRenames(context, left, weigh, minimum)
|
|
125
126
|
}
|