@bgd-labs/toolbox 0.0.24 → 0.0.25

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/node.js CHANGED
@@ -28580,7 +28580,25 @@ async function diffCode(before, after) {
28580
28580
  ])
28581
28581
  );
28582
28582
  for (const [name, path, source] of contractsBefore) {
28583
- const indexAfter = contractsAfter.findIndex(([_name]) => _name === name);
28583
+ const matchingIndexes = contractsAfter.reduce((acc, val, i) => {
28584
+ if (val[0] === name) acc.push(i);
28585
+ return acc;
28586
+ }, []);
28587
+ let indexAfter = -1;
28588
+ if (matchingIndexes.length === 1) {
28589
+ indexAfter = matchingIndexes[0];
28590
+ } else if (matchingIndexes.length > 1) {
28591
+ let maxSimilarity = -1;
28592
+ for (const idx of matchingIndexes) {
28593
+ const afterSource = contractsAfter[idx][2];
28594
+ const diff = (0, import_diff.diffChars)(source, afterSource);
28595
+ const similarity = diff.reduce((acc, part) => acc + (part.added || part.removed ? 0 : part.count || part.value.length), 0);
28596
+ if (similarity > maxSimilarity) {
28597
+ maxSimilarity = similarity;
28598
+ indexAfter = idx;
28599
+ }
28600
+ }
28601
+ }
28584
28602
  if (indexAfter === -1) {
28585
28603
  changes[name] = (0, import_diff.createPatch)(path, source, "");
28586
28604
  } else {