Closed mrleblanc101 closed 1 year ago
You could make it with Fuse's APIs, like this:
const fuse = new Fuse(...);
const searchWrapper = query => {
if (!query) return fuse.getIndex().records.map(({ $: item, i: idx }) => ({ idx, item }));
return fuse.search(query);
};
Just came across this exact issue and wanted to note a couple of things about the second reply just in case someone goes to use it.
fuse.getIndex()
doesn't have a records
property in the type definition (so it will error if using typescript).
$
doesn't actually contain an item from the collection so that won't work as a solution.
This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 30 days
We’re still affected by this, but haven’t had the time to do a PR
I'm not sure why the bot closed this? I commented afterwards to stop it from getting closed.
Description
I used Fuse.js in a Vue application. I wish to display all results if no search params is passed. I can't loop on the original data since the format is not exactly the same so it would complexify my code quite a bit.
Describe the solution you'd like
Add an option to return all results when no search query is provided
Describe alternatives you've considered
Loop on my original object and use if/else to handle the different structure.