krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
18.43k stars 773 forks source link

feat: added flag emptygetsall #729

Closed aworld1 closed 5 months ago

aworld1 commented 1 year ago

Solved an issue requesting a flag that causes empty queries to return all items.

728

Example usage:

let query = getQuery(); // which can be empty
const fuse = new Fuse(searchQuery, {
    emptyGetsAll: true
});
let result = fuse.search(query); // Empty queries should itemize all entries

Defaults to false:

let query = getQuery(); // which can be empty
const fuse = new Fuse(searchQuery, {}); // config has emptyGetsAll as false by default
let result = fuse.search(query); // Empty queries should itemize NO entries
jcubic commented 10 months ago

I was surprised that this is not supported. You need to create an if statement if you want to use the library with a search box that is always empty initially.

@aworld1 I have the same problems with my library, I suggest not committing the dist file since they will always introduce conflicts in minified files.

Try this in your local git repo:

git reset HEAD~1
git checkout dist/*
git commit -am 'feat: added flag emptygetsall'
git push -f

IMHO this should be in the guide to never commit dist files.

stephane-klein commented 10 months ago

@krisk bump

jcubic commented 5 months ago

Awesome maintenance.