EthanRutherford / fast-fuzzy

Fast fuzzy search utility
ISC License
374 stars 8 forks source link

Feature request: option to return unsorted results #17

Closed AlexVipond closed 2 years ago

AlexVipond commented 2 years ago

I'm using fast-fuzzy to handle the search feature for a custom listbox I'm building, and my implementation needs the match data search results to retain the original order of the listbox options.

Proposal: add a sort boolean option to searchCore. It should default to true so that it's not a breaking change, but it could be set to false to return search results in their original order.

search('my query', { sort: false })

Let me know your thoughts @EthanRutherford—I'm happy to PR the feature and take a stab at some tests

EthanRutherford commented 2 years ago

This is a great request, and should be fairly straightforward to add. I could probably take care of this pretty quickly.

EthanRutherford commented 2 years ago

Thanks for the request, this was added in fe56314465d057630de8ca8c102d2a9ca4aca397 and published with version 1.11.0.

AlexVipond commented 2 years ago

Thanks, this is great!

I'm getting an error during TypeScript compilation for this semicolon: https://github.com/EthanRutherford/fast-fuzzy/blob/fe56314465d057630de8ca8c102d2a9ca4aca397/src/fuzzy.d.ts#L5

Seems like it's just a case where semicolons are not allowed. Compilation runs normally as soon as the semicolon is removed.

EthanRutherford commented 2 years ago

Oh, yeah sorry I don't work in typescript all that often, I should probably add something to validate that d.ts file so this kind of thing doesn't happen again. I'll get that fixed, and a patch version shipped.