-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rajendrant
committed
Dec 19, 2018
1 parent
ae13519
commit 0952d3d
Showing
5 changed files
with
43 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
build/ | ||
node_modules/ | ||
prebuilds/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,42 @@ | ||
fuzzaldrinplusfast = require('node-gyp-build')(__dirname); | ||
binding = require('node-gyp-build')(__dirname); | ||
|
||
defaultPathSeparator = if process?.platform is "win32" then '\\' else '/' | ||
|
||
parseOptions = (options) -> | ||
options.allowErrors ?= false | ||
options.usePathScoring ?= true | ||
options.useExtensionBonus ?= false | ||
options.pathSeparator ?= defaultPathSeparator | ||
options.optCharRegEx ?= null | ||
options.wrap ?= null | ||
options.maxResults ?= 0 | ||
return options | ||
|
||
class FuzzaldrinPlusFast | ||
constructor: -> | ||
@obj = new binding.Fuzzaldrin() | ||
|
||
setCandidates: (candidates, options = {}) -> | ||
if options.key? | ||
candidates = candidates.map(item => item[options.key]) | ||
@obj.setCandidates(candidates) | ||
|
||
filter: (query, options = {}) -> | ||
options = parseOptions(options) | ||
@obj.filter query, options.maxResults, | ||
options.usePathScoring, options.useExtensionBonus | ||
|
||
module.exports = | ||
|
||
New: -> | ||
new fuzzaldrinplusfast.Fuzzaldrin() | ||
new FuzzaldrinPlusFast() | ||
|
||
filter: (candidates, query, options = {}) -> | ||
obj = new fuzzaldrinplusfast.Fuzzaldrin() | ||
obj.setCandidates(candidates) | ||
obj = new FuzzaldrinPlusFast() | ||
obj.setCandidates(candidates, options) | ||
obj.filter(query, options) | ||
|
||
score: (candidate, query, options = {}) -> | ||
fuzzaldrinplusfast.score candidate, query, options | ||
binding.score candidate, query, options | ||
|
||
prepareQuery: -> |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters