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

Implement kushuh's change preventing div by zero in removeDocumentScoreParameters #789

Conversation

AdventureBeard
Copy link

Implement @kushuh's proposed change in #766 , modifying removeDocumentScoreParameters to check for a divide by zero scenario before doing the calculation.

Sorry to snipe this change; just needed it badly, haha!

Copy link

vercel bot commented Sep 14, 2024

@AdventureBeard is attempting to deploy a commit to the OramaSearch Team on Vercel.

A member of the Team first needs to authorize it.

@AdventureBeard AdventureBeard changed the title Implement kushuh's change preventing div by zero Implement kushuh's change preventing div by zero in removeDocumentScoreParameters Sep 14, 2024
@micheleriva
Copy link
Member

Hi @AdventureBeard, thanks a lot for this PR! I fear that you should either do:

index.avgFieldLength[prop] = 0;

or

delete index.avgFieldLength[prop]

otherwise it'll fail type-checking as you're assigning undefined to a number property. Probably assigning to 0 is fine.

@micheleriva
Copy link
Member

Superseeded by @#792

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