-
Notifications
You must be signed in to change notification settings - Fork 130
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
Add ability to set a threshold per key #50
Conversation
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.
This is great! Just one comment.
src/index.js
Outdated
@@ -60,17 +65,21 @@ function matchSorter(items, value, options = {}) { | |||
* @param {Array} keys - the keys to get values from the item for the ranking | |||
* @param {String} value - the value to rank against | |||
* @param {Object} options - options to control the ranking | |||
* @return {{rank: Number, keyIndex: Number}} - the highest ranking | |||
* @return {{rank: Number, keyIndex: Number, itemThreshold: Number}} - the highest ranking |
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.
Should we call this keyThreshold
instead?
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.
Yup. Agree. I’ll make the change soon.
rename itemThreshold to keyThreshold
this way it’ll match a key when the keyThreshold is lower than the default threshold
f65b6bd
to
7c04205
Compare
I update the variable name to I also added another test to assert that it will match a key when the keys threshold is set lower that the default threshold |
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.
Super! Thanks!
🎉 This PR is included in version 2.3.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Thanks! |
What:
Add the ability to set a threshold per key
Why:
To be able to set specific keys to only match when they meet a specified threshold
How:
By adding returning the keys threshold with each match and verifying that the the match is
>=
the threshold specified on its key.Checklist: