Skip to content

feat: allow to pass a getFn for a specific key#627

Merged
krisk merged 2 commits intokrisk:masterfrom
fakenickels:master
May 3, 2022
Merged

feat: allow to pass a getFn for a specific key#627
krisk merged 2 commits intokrisk:masterfrom
fakenickels:master

Conversation

@fakenickels
Copy link
Copy Markdown
Contributor

@fakenickels fakenickels commented Feb 23, 2022

This PR introduces the following

const fuse = new Fuse(Books, {
  useExtendedSearch: true,
  includeMatches: true,
  includeScore: true,
  threshold: 0.3,
  keys: [
    { name: "title", getFn: (book) => book.title },
    { name: "authorName", getFn: (book) => book.author.firstName },
  ],
});
const result = fuse.search({ title: "old man" });

I noticed it has been requested several times

Let me know if any other changes are necessary before merging

@fakenickels fakenickels reopened this Feb 23, 2022
@krisk krisk changed the title allow to pass a getFn for a specific key feat: allow to pass a getFn for a specific key Mar 2, 2022
@Aaronius
Copy link
Copy Markdown

Yes please!

@krisk krisk merged commit 203871f into krisk:master May 3, 2022
@krisk
Copy link
Copy Markdown
Owner

krisk commented May 3, 2022

This is great. As a follow-up to this, could you create a PR with the relevant docs updates?

@krisk
Copy link
Copy Markdown
Owner

krisk commented May 3, 2022

Could you make the requisite TS changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants