Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a noresults option that returns a string to the user #33

Open
YPCrumble opened this issue Jan 6, 2017 · 1 comment
Open

Add a noresults option that returns a string to the user #33

YPCrumble opened this issue Jan 6, 2017 · 1 comment

Comments

@YPCrumble
Copy link

I'd like to provide the user with a default option in the event that their search returns no results. Something simple like "No results found" but that can be customized as well. Is that something you'd be interested in a PR for?

@SamVerschueren
Copy link

Isn't that easily implemented yourself?

const fuzzy = require('fuzzy');

function filter(input, term) {
    const results = fuzzy.filter(input, term);
    
    if (results.length === 0) {
        return ['No results found'];
    }

    return results.map(x => x.string);
}

const list = ['baconing', 'narwhal', 'a mighty bear canoe'];

filter(list, 'bcn');
//=> ['No results found']

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

No branches or pull requests

2 participants