Repository navigation
v1.3.0 — filterMatches() list helper (pandas-like filtering for candidates)
✨ Highlights
This release adds a new list utility: filterMatches().
It is built for the common “dataset workflow”:
rank → filter → (optionally) inspect details
While staying simple by default.
✅ Added: filterMatches()
filterMatches() compares an input string against a list of candidates and keeps only the ones
that score at or above a threshold.
Simple by default
By default, it returns a string[] (values only):
import { filterMatches } from 'guess-rater'
const hits = filterMatches('hello', ['hello', 'world'], { threshold: 90 })
console.log(hits) // ['hello']Detailed on demand
If you need scores and indices, request entries:
const hits = filterMatches('hello', ['hello', 'world'], {
threshold: 90,
return: 'entries'
})
// [{ value, score, index }, ...]Explain output (debug/tuning)
Explain details are available when using return: 'entries':
const hits = filterMatches('hello', ['hello', 'world'], {
threshold: 90,
return: 'entries',
explain: true
})
// Each entry includes normalized strings + breakdownNotes:
explainis ignored when using the defaultreturn: 'values'(values-only mode).- No behavior changes to existing functions.
📚 Documentation
- Added a new API page documenting
filterMatches() - Updated exports list and navigation
🧪 Tests & quality
- Added unit tests covering:
- default values-only return (
string[]) - detailed entries return (
{ value, score, index }[]) - explain output behavior
- threshold filtering correctness
- default values-only return (
🔄 Compatibility
- No breaking changes
- Backward compatible
- Existing behavior remains unchanged unless you call
filterMatches()