Add a `noresults` option that returns a string to the user
YPCrumble opened this issue · comments
YPCrumble commented
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?
Sam Verschueren commented
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']