Repository navigation
v1.4.0 — extract() list helper (top N matches with threshold + optional details)
✨ Highlights
This release adds a new list utility: extract().
extract() is the “top matches” helper for list workflows:
rank → filter (threshold) → limit (top N)
It is designed to be simple by default, with optional detailed output when needed.
✅ Added: extract()
extract() compares an input string against a list of candidates and returns the top N matches.
Simple by default (values only)
By default, it returns a string[]:
import { extract } from 'guess-rater'
const results = extract('hello', ['hello', 'world'], {
threshold: 90,
limit: 5
})
console.log(results) // ['hello']Detailed on demand
If you need scores and indices, request entries:
const results = extract('hello', ['hello', 'world'], {
threshold: 90,
limit: 5,
return: 'entries'
})
// [{ value, score, index }, ...]Explain output (debug/tuning)
Explain details are available when using return: 'entries':
const results = extract('hello', ['hello', 'world'], {
threshold: 90,
limit: 5,
return: 'entries',
explain: true
})
// Each entry includes normalized strings + breakdown (like rate(..., { explain:true }))Notes:
explainis ignored when using the defaultreturn: 'values'(values-only mode).- No behavior changes to existing functions.
📚 Documentation
- Added a new API page documenting
extract() - Updated the exports list and navigation
🧪 Tests & quality
- Added unit tests covering:
- default values-only return (
string[]) - limit handling (
limit) - detailed entries return (
{ value, score, index }[]) - explain output behavior
- default values-only return (
🔄 Compatibility
- No breaking changes
- Backward compatible
- Existing behavior remains unchanged unless you call
extract()