Code Monkey home page Code Monkey logo

jquery-fuzzymatch's Introduction

jQuery.fuzzyMatch

jQuery.fuzzyMatch implements a fuzzy-string-matching algorithm inspired by QuickSilver and Command-T in javascript.

It is designed for use as part of an autocompleter, where a finite list of possible strings are to be matched against the few characters that the user has typed.

It offers some improvement over existing prefix-based matches, though it is careful to ensure that if a prefix match has been typed, it will be shown first.

Example

To use this with jQuery.ui.autocomplete, you do:

    $("input").autocomplete({
        source: function (context, callback) {
            callback($(['dog', 'cat', 'cow']).filter(function (a) {
                // Only show items which match
                return $.fuzzyMatch(a, context.term).score;
            }).sort(function (a, b) {
                // And sort them by matchiness.
                var score_a = $.fuzzyMatch(a, context.term).score,
                    score_b = $.fuzzyMatch(b, context.term).score;

                return score_a < score_b ? -1 : score_a === score_b ? 0 : 1;
            }));
        },
        delay: 0
    });

Meta-foo

This is all licensed under the MIT license, contributions are most welcome.

jquery-fuzzymatch's People

Contributors

conradirwin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jquery-fuzzymatch's Issues

I get an error:

Uncaught TypeError: undefined is not a function fuzzy.js?9fd92688852714542edcf93e036b4aea0d3d9104:82

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.