How to use fuzzy - 10 common examples

To help you get started, we’ve selected a few fuzzy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rebassjs / rebass / backup-src / fuzzy-input.jsx View on Github external
findMatches: function(string) {
    var self = this;
    var results = fuzzy.filter(string, this.props.options);
    var matches = [];
    //results.map(function(result) {
    //  if (result.score > self.props.minScore) {
    //    matches.push(result.string);
    //  }
    //});
    this.setState({ matches: results });
  },
github rebassjs / rebass / dist / fuzzy-input.js View on Github external
findMatches: function(string) {
    var self = this;
    var results = fuzzy.filter(string, this.props.options);
    var matches = [];
    //results.map(function(result) {
    //  if (result.score > self.props.minScore) {
    //    matches.push(result.string);
    //  }
    //});
    this.setState({ matches: results });
  },
github sprintly / sprintly-ui / src / components / selector_menu / index.js View on Github external
filterList: function(filterBy) {
    // If user input, returns fuzzy search-delimited list of options;
    // else, shows all options.
    if (!filterBy) {
      this.setState({
        visible: this.getOptionNames()
      });
      return;
    }

    var visible = _.pluck(fuzzy.filter(filterBy, this.getOptionNames()), 'string');

    this.setState({
      visible: visible,
      clearInput: false
    });
  },
github plibither8 / licensed / src / initiators / search-license.js View on Github external
exports.searchLicense = ({input}, flags) => {

    /**
     * All but last strings in input are
     * concatenated to form one search term 
     * on which a fuzzy search is performed 
     * to match a license name
    */

    let i = 0;
    do {
        searchTerm += input[i++];
    } while (i < input.length - 1);

    // Fuzzy search
    const results = fuzzy
        .filter(searchTerm, Object.keys(licenses))
        .map(({original}) => original);

    /**
     * If no results for the search
     * term are found, output err 
     * message and abort.
     */

    if (!results.length) {
        process.stdout.write(red(`\n❌ No license name matching '${searchTerm}' was found.\nPlease try again with another name.\n`));
        return;
    }

    /**
     * If called with a year flag use
github qlik-oss / after-work.js / plugins / interactive-plugin / src / search-test-files.js View on Github external
setTimeout(() => {
      const fuzzyResult = fuzzy.filter(input, inputTestFiles);
      const val = fuzzyResult.map(el => el.original);
      resolve(val);
    });
  });
github Cox-Automotive / alks-cli / lib / alks.js View on Github external
function validateInvocation(){
    var commands         = _.map(program.commands, '_name'),
        requestedCommand = _.head(program.args);

    if(!program.args.length){
        return program.help();
    }
    else if(!_.includes(commands, requestedCommand)){
        var msg      = [requestedCommand, ' is not a valid ALKS command.'],
            suggests = fuzzy.filter(requestedCommand, commands),
            suggest  = suggests.map(function(sug){ return sug.string; });

        if(suggest.length){
            msg.push(clc.white(' Did you mean '));
            msg.push(clc.white.underline(suggest[0]));
            msg.push(clc.white('?'));
        }
        return utils.errorAndExit(msg.join(''));
    }
}
github Cox-Automotive / alks-cli / lib / utils.js View on Github external
exports.subcommandSuggestion = function(program, subcommand){
    var commands         = _.map(program.commands, '_name'),
        requestedCommand = _.head(program.args);

    if(program.args.length && !_.includes(commands, requestedCommand)){
        var prefix   = ['alks', subcommand, ''].join(' '),
            msg      = [prefix, requestedCommand, ' is not a valid ALKS command.'],
            suggests = fuzzy.filter(requestedCommand, commands),
            suggest  = suggests.map(function(sug){ return sug.string; });

        if(suggest.length){
            msg.push(clc.white(' Did you mean '));
            msg.push(clc.white.underline(prefix + suggest[0]));
            msg.push(clc.white('?'));
        }

        exports.errorAndExit(msg.join(''));
    }
};
github netlify / netlify-cms / packages / netlify-cms-core / src / backend.ts View on Github external
async query(collection: Collection, searchFields: string[], searchTerm: string) {
    const entries = await this.listAllEntries(collection);
    const hits = fuzzy
      .filter(searchTerm, entries, { extract: extractSearchFields(searchFields) })
      .sort(sortByScore)
      .map(f => f.original);
    return { query: searchTerm, hits };
  }
github blueberryapps / react-bluekit / src / app / StateProvider.react.js View on Github external
filterComponentsIndex() {
      const {componentsIndex} = this.props
      const {searchedText} = this.state
      const options = {pre: ``, post: ''}
      if (`${searchedText}`.length > 0)
        return fuzzyFilter(searchedText.toLowerCase(), Object.keys(componentsIndex))
          .reduce((acc, key) => ({...acc, [key.original]: {...componentsIndex[key.original], highlightedMenu: fuzzyFilter(searchedText.toLowerCase(), [componentsIndex[key.original].menu], options)[0].string}}), {})
      return componentsIndex
    }
github eclipse-theia / theia / packages / core / src / browser / tree / fuzzy-search.ts View on Github external
async filter(input: FuzzySearch.Input): Promise[]> {
        return fuzzy.filter(input.pattern, input.items.slice(), {
            pre: FuzzySearch.PRE,
            post: FuzzySearch.POST,
            extract: input.transform
        }).sort(this.sortResults.bind(this)).map(this.mapResult.bind(this));
    }

fuzzy

small, standalone fuzzy search / fuzzy filter. browser or node

MIT
Latest version published 8 years ago

Package Health Score

67 / 100
Full package analysis

Popular fuzzy functions