-
Notifications
You must be signed in to change notification settings - Fork 48
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
Conversation
/canary |
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
react/player/src/asset/index.tsx
Outdated
); | ||
|
||
const similarType = typeList.reduce((prev, curr) => { | ||
return leven(unwrapped.type, prev) < leven(unwrapped.type, curr) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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);
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?
📦 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