3 [![Build Status](https://travis-ci.org/atom/fuzzaldrin.svg?branch=master)](https://travis-ci.org/atom/fuzzaldrin)
4 [![Build status](https://ci.appveyor.com/api/projects/status/0ig71rjdgfm7y9c1/branch/master)](https://ci.appveyor.com/project/kevinsawicki/fuzzaldrin/branch/master)
6 Fuzzy filtering and string scoring.
8 This library is used by [Atom](http://atom.io) and so its focus will be on
9 scoring and filtering paths, methods, and other things common when writing code.
10 It therefore will specialize in handling common patterns in these types of
11 strings such as characters like `/`, `-`, and `_`, and also handling of
17 npm install fuzzaldrin
20 ### filter(candidates, query, [options])
22 Sort and filter the given candidates by matching them against the given query.
24 * `candidates` - An array of strings or objects.
25 * `query` - A string query to match each candidate against.
26 * `options` - An optional object with the following keys:
27 * `key` - The property to use for scoring if the candidates are objects.
28 * `maxResults` - The maximum numbers of results to return.
30 Returns an array of candidates sorted by best match against the query.
33 {filter} = require 'fuzzaldrin'
35 # With an array of strings
36 candidates = ['Call', 'Me', 'Maybe']
37 results = filter(candidates, 'me')
38 console.log(results) # ['Me', 'Maybe']
40 # With an array of objects
44 {name: 'Maybe', id: 3}
46 results = filter(candidates, 'me', key: 'name')
47 console.log(results) # [{name: 'Me', id: 2}, {name: 'Maybe', id: 3}]
50 ### score(string, query)
52 Score the given string against the given query.
54 * `string` - The string the score.
55 * `query` - The query to score the string against.
58 {score} = require 'fuzzaldrin'
60 score('Me', 'me') # 0.17099999999999999
61 score('Maybe', 'me') # 0.0693
67 git clone https://github.com/atom/fuzzaldrin.git
73 You can run the benchmarks using: