Migration Guide

v0.4 → v0.5

We only have made some changes in tiebreakers in this release. FZF doesn't uses this option by default. So if you have not used a tiebreaker in your code, a version bump is all what you need!

options.tiebreakers

  • The third argument of tiebreaker has been changed from options to selector
DIFF
- function byTrimmedLengthAsc(a, b, options) {
- return options.selector(a.item).trim().length - options.selector(b.item).trim().length;
+ function byTrimmedLengthAsc(a, b, selector) {
+ return selector(a.item).trim().length - selector(b.item).trim().length;
}
const fzf = new Fzf(list, () => {
tiebreakers: [byTrimmedLengthAsc]
})
  • The behaviour of tiebreakers now matches with original FZF and with other search solutions. You can find more details about it in the updated section for tiebreakers in the docs.

v0.3 → v0.4

options.maxResultItems

maxResultItems has been renamed. Please change occurrences of maxResultItems to limit in your code.

DIFF
const fzf = new Fzf(list, {
- maxResultItems: 10
+ limit: 10
})

options.cache

This option has been removed. Please remove its instances from your code if you've written any.

DIFF
const fzf = new Fzf(list, {
- cache: true,
// ... other options
})

options.normalize

normalize is now turned on by default. This means that by default, diacritics/accents from words will be removed. (So search string "fe" will match both "Caffè" and "Caffe" for example.) This change should not affect most of the users of this library, but if you are aware of this feature and want to keep it turned off, you'll have to assign it to false.

DIFF
const fzf = new Fzf(list, {
+ normalize: false,
// ... other options
})

options.forward

This option wasn't available in v0.3.

If you queried "comp" on "src/components/input-composed.ts" you would get:

v0.3v0.4
src/components/input-composed.tssrc/components/input-composed.ts

So in v0.3 "comp" that appears at the end is highlighted while in v0.4 first match from the start is highlighted.

If you want to keep the old behaviour, you would need to turn forward off:

DIFF
const fzf = new Fzf(list, {
+ forward: false,
// ... other options
})

resultItem.positions

positions has now been converted to a Set and will always be a non-null value. You usually use positions to highlight matched characters of a string.

DIFF
- <HighlightChars text={entry.item} indices={entry.positions ?? []} />
+ <HighlightChars text={entry.item} indices={entry.positions} />
// ...
interface HighlightCharsProps {
text: string
- indices: number[]
+ indices: Set<number>
}
// ...
export const HighlightChars = (props: HighlightCharsProps) => {
const strArr = props.text.split("");
const nodes = strArr.map((v, i) => {
- if (props.indices.includes(i)) {
+ if (props.indices.has(i)) {

resultItem.result

result is flattened. This will result in the following code change:

DIFF
const entries = (new Fzf(list)).find(query);
const entry = entries[0];
- const { start, end, score } = entry.result
+ const { start, end, score } = entry