Skip to content

Instantly share code, notes, and snippets.

@shreyvijayvargiya
Created November 18, 2022 21:37
Show Gist options
  • Save shreyvijayvargiya/588592cbe88cf1e0d8bd99e7a44896b9 to your computer and use it in GitHub Desktop.
Save shreyvijayvargiya/588592cbe88cf1e0d8bd99e7a44896b9 to your computer and use it in GitHub Desktop.
const options = { keys: ['title', 'author.firstName'] }
// Create the Fuse index
const myIndex = Fuse.createIndex(options.keys, books)
// initialize Fuse with the index
const fuse = new Fuse(books, options, myIndex)
// Output
const list = [
{
"title": "Old Man's War",
"author": {
"firstName": "John",
"lastName": "Scalzi"
}
},
{
"title": "The Lock Artist",
"author": {
"firstName": "Steve",
"lastName": "Hamilton"
}
}
/*...*/
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment