fuzzy icon indicating copy to clipboard operation
fuzzy copied to clipboard

Add a `noresults` option that returns a string to the user

Open YPCrumble opened this issue 9 years ago • 1 comments

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?

YPCrumble avatar Jan 06 '17 15:01 YPCrumble

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']

SamVerschueren avatar Jan 18 '17 19:01 SamVerschueren