Giter VIP home page Giter VIP logo

fuse's Introduction

Fuse

Build Status

Fuse is a full JavaScript fuzzy-search implementation that searches accross the keys of every record in a list.

Options

keys (type: Array)

List of properties that will be searched. This also supports nested properties:

var books = [{
  title: "Old Man's War"
  author: {
    firstName: "John",
    lastName: "Scalzi"
  }
}];
var fuse = new Fuse(books, { keys: ["title", "author.firstName"] });

id (type: String)

The name of the identifier property. If specified, the returned result will be a list of the items' identifiers, otherwise it will be a list of the items.


caseSensitive (type: Boolean, default: false)

Indicates whether comparisons should be case sensitive.


includeScore (type: Boolean, default: false)

Whether the score should be included in the result set. When true, each result in the list will be of the form { item: ..., score: ... }


shouldSort (type: Boolean, default: true)

Whether to sort the result list, by score.


searchFn (type: Function, default: BitapSearcher)

The search function to use. Note that the search function ([[Function]]) must conform to the following API:

/*
@param pattern The pattern string to search
@param options The search option
*/
[[Function]].constructor = function(pattern, options) { ... }

/*
@param text: the string to search in for the pattern
@return Object in the form of:
 - isMatch: boolean
 - score: Int
 */
[[Function]].prototype.search = function(text) { ... }

getFn (type: Function, default: Utils.deepValue)

The get function to use when fetching an object's properties. The default will search nested paths ie foo.bar.baz

/*
@param obj The object being searched
@param path The path to the target property
*/

// example using an object with a `getter` method
getFn: function (obj, path) {
  return obj.get(path);
}

sortFn (type: Function, default: Array.prototype.sort)

The function that is used for sorting the result list.

Bitap specific options

location (type: Integer, default: 0)

Determines approximately where in the text is the pattern expected to be found.


threshold (type: Decimal, default: 0.6)

At what point does the match algorithm give up. A threshold of 0.0 requires a perfect match (of both letters and location), a threshold of 1.0 would match anything.


distance (type: Integer, default: 100)

Determines how close the match must be to the fuzzy location (specified by location). An exact letter match which is distance characters away from the fuzzy location would score as a complete mismatch. A distance of 0 requires the match be at the exact location specified, a threshold of 1000 would require a perfect match to be within 800 characters of the location to be found using a threshold of 0.8.


maxPatternLength (type: Integer, default: 32)

The maximum length of the pattern. The longer the pattern, the more intensive the search operation will be. Whenever the pattern exceeds the maxPatternLength, an error will be thrown. Why is this important? Read this.

Contributing to Fuse

Before submitting a pull request, please add relevant tests in test/fuse-test.js, and execute them via npm test.

Note that ALL TESTS MUST PASS, otherwise the pull request will be automatically rejected.

fuse's People

Contributors

krisk avatar dsmilkov avatar cattail avatar chaoaretasty avatar jcbmllgn avatar michaelgregory avatar stevenosloan avatar wmeldon avatar

Watchers

James Cloos avatar

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.