Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace fuse.js with leven to fix no similar matching name error #452

Merged
merged 3 commits into from
Jul 30, 2024

Conversation

cehan-Chloe
Copy link
Collaborator

@cehan-Chloe cehan-Chloe commented Jul 26, 2024

fix for #450

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs
📦 Published PR as canary version: 0.7.5--canary.452.15858

Try this version out locally by upgrading relevant packages to 0.7.5--canary.452.15858

@cehan-Chloe
Copy link
Collaborator Author

/canary

Copy link

codecov bot commented Jul 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.84%. Comparing base (81061cf) to head (52f38dd).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #452      +/-   ##
==========================================
- Coverage   91.84%   91.84%   -0.01%     
==========================================
  Files         338      338              
  Lines       26831    26843      +12     
  Branches     1941     1945       +4     
==========================================
+ Hits        24644    24654      +10     
- Misses       2173     2175       +2     
  Partials       14       14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cehan-Chloe cehan-Chloe marked this pull request as ready for review July 26, 2024 17:24
@cehan-Chloe cehan-Chloe requested a review from spentacular as a code owner July 26, 2024 17:24
@cehan-Chloe cehan-Chloe removed the request for review from spentacular July 26, 2024 17:24
);

const similarType = typeList.reduce((prev, curr) => {
return leven(unwrapped.type, prev) < leven(unwrapped.type, curr)
Copy link
Member

@adierkens adierkens Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we store the value of the previous leven call, to avoid duplication?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    let minDistance = leven(unwrapped.type as string, typeList[0]);
    let similarType = typeList[0];
    typeList.forEach(type => {
      const distance = leven(unwrapped.type, type);
      if (distance < minDistance) {
        minDistance = distance;
        similarType = type;
      }
    });

when you say storing prev value, do you mean this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can still keep everything in a single reduce(), but the way it's structured now we end up calling leven() for the previous values that we have already computed.

something like:

typeList.reduce((prev, curr) => {
  const next = {
    value: leven(unwrapped.type, curr),
    type: unwrapped.type
  };

  if (prev === undefined || prev.value < next.value) {
    return prev;
  }

  return next;
}, undefined);

@cehan-Chloe cehan-Chloe requested a review from adierkens July 30, 2024 13:46
@adierkens adierkens merged commit 20b2248 into main Jul 30, 2024
11 checks passed
@adierkens adierkens deleted the fix-fusejs branch July 30, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants