// @flow /** * A collection of string matching algorithms built with React Select in mind. */ // Option type from React Select and similar libraries. export type Option = { label?: string, value?: any, }; type MapOfStrings = {[key: string]: string}; /** * Filters React Select options and sorts by similarity to a search filter. * Handles partial matches, eg. searching for "Waberg High" will find "Raoul * Wallenberg Traditional High School". Case insensitive. Ignores * non-alphanumeric characters. * * @param options An unfiltered list of Options. * @param? filter A string to compare against Option labels. * @param? substitutions Strings with multiple spellings or variations that we * expect to match, eg. accented characters or abbreviated words. * * @return A filtered and sorted array of Options. */ export function filterOptions( options: Array