results
Updated on August 22, 2024Source codeTests
createResults is a pipe that transforms a string to an array of search results, optionally with fuzzy matching.
Create results
Call createResults with these parameters to create your results function:
Parameter
Type
Required
Description
candidatesArray
yes
The search candidates that will be made searchable. All items in
candidates should be strings or objects.Options
The options parameter of createResults can be one of two things:
- fast-fuzzy options
- OR, a function that returns fast-fuzzy options.
If you pass a function, it will receive an api object as its first and only parameter. Here are the details on that object:
Property
Type
Description
sortKindString
fast fuzzy's
sortKind enumerable. This is provided so you can easily and type-safely customize sort order via fast fuzzy options.Using with TypeScript
TypeScript will infer two things from your candidates and options parameters:
- The type of items in the
candidatesarray - Whether or not your search results will include match data
The search results you get back from your results function will be type-checked accordingly 🤓