dist/fuzzy-match-utils.js
function filterOptions(options, filter, substitutions) {
    // If the filter is blank, return the full list of Options.
    if (!filter) {
        return options;
    }

    var cleanFilter = cleanUpText(filter, substitutions);
    return options
    // Filter out undefined or null Options.
    .filter(function (_ref) {
        var label = _ref.label,
            value = _ref.value;
        return label != null && value != null;
    })
    // Create a {score, Option} pair for each Option based on its label's
    // similarity to the filter text.
    .map(function (option) {
        return {
            option: option,
            score: typeaheadSimilarity(cleanUpText(option.label, substitutions), cleanFilter)
        };
    })
    // Only include matches of the entire substring, with a slight
    // affordance for transposition or extra characters.
    .filter(function (pair) {
        return pair.score >= cleanFilter.length - 2;
    })
    // Sort 'em by order of their score.
    .sort(function (a, b) {
        return b.score - a.score;
    })
    // …and grab the original Options back from their pairs.
    .map(function (pair) {
        return pair.option;
    });
}
function filterOptions(options, filter, substitutions) {
    // If the filter is blank, return the full list of Options.
    if (!filter) {
        return options;
    }

    var cleanFilter = cleanUpText(filter, substitutions);
    return options
    // Filter out undefined or null Options.
    .filter(function (_ref) {
        var label = _ref.label,
            value = _ref.value;
        return label != null && value != null;
    })
    // Create a {score, Option} pair for each Option based on its label's
    // similarity to the filter text.
    .map(function (option) {
        return {
            option: option,
            score: typeaheadSimilarity(cleanUpText(option.label, substitutions), cleanFilter)
        };
    })
    // Only include matches of the entire substring, with a slight
    // affordance for transposition or extra characters.
    .filter(function (pair) {
        return pair.score >= cleanFilter.length - 2;
    })
    // Sort 'em by order of their score.
    .sort(function (a, b) {
        return b.score - a.score;
    })
    // …and grab the original Options back from their pairs.
    .map(function (pair) {
        return pair.option;
    });
}
function filterOptions ( options , filter , substitutions ) { // If the filter is blank, return the full list of Options. if ( ! filter ) { return options ; } var cleanFilter = cleanUpText ( filter , substitutions ) ; return options // Filter out undefined or null Options. . filter ( function ( _ref ) { var label = _ref . label , value = _ref . value ; return label != null && value != null ; } ) // Create a {score, Option} pair for each Option based on its label's // similarity to the filter text. . map ( function ( option ) { return { option : option , score : typeaheadSimilarity ( cleanUpText ( option . label , substitutions ) , cleanFilter ) } ; } ) // Only include matches of the entire substring, with a slight // affordance for transposition or extra characters. . filter ( function ( pair ) { return pair . score >= cleanFilter . length - 2 ; } ) // Sort 'em by order of their score. . sort ( function ( a , b ) { return b . score - a . score ; } ) // …and grab the original Options back from their pairs. . map ( function ( pair ) { return pair . option ; } ) ; }
A collection of string matching algorithms built with React Select in mind.
 Option type from React Select and similar libraries.
A collection of string matching algorithms built with React Select in mind . Option type from React Select and similar libraries .