Skip to content

v1.3.0 — filterMatches() list helper (pandas-like filtering for candidates)

Choose a tag to compare

@Tfoucher5 Tfoucher5 released this 22 Apr 13:07
· 100 commits to master since this release

✨ 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 + breakdown

Notes:

  • explain is ignored when using the default return: '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

🔄 Compatibility

  • No breaking changes
  • Backward compatible
  • Existing behavior remains unchanged unless you call filterMatches()