bevacqua / fuzzysearch

:crystal_ball: Tiny and blazing-fast fuzzy search in JavaScript
https://ponyfoo.com
MIT License
2.71k stars 87 forks source link

Curry the fuzzysearch method #13

Closed stutrek closed 8 years ago

stutrek commented 8 years ago

This PR curries the fuzzysearch method if you pass only one argument. With it you can pass it to array.filter like so:

var stuff = ['cartwheel', 'boatwheel', 'wheels on the bus', 'car tire'];
var results = stuff.filter(fuzzysearch('car'));
console.log(results); // ['cartwheel', 'car tire']

The existing uncurried two argument API is exactly the same.

bevacqua commented 8 years ago

No thanks. You can do this externally.

stuff.filter(fuzzysearch.bind(null, 'car'))