Installations
npm install fuzzy
Score
99.9
Supply Chain
99.5
Quality
75.3
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Developer
mattyork
Developer Guide
Module System
CommonJS
Min. Node Version
>= 0.6.0
Typescript Support
No
Node Version
5.1.1
NPM Version
3.5.2
Statistics
832 Stars
64 Commits
86 Forks
17 Watching
2 Branches
8 Contributors
Updated on 20 Nov 2024
Languages
JavaScript (90.59%)
HTML (6.49%)
Makefile (2.92%)
Total Downloads
Cumulative downloads
Total Downloads
249,577,469
Last day
-36.4%
335,161
Compared to previous day
Last week
-7.2%
2,460,644
Compared to previous week
Last month
6.6%
10,837,781
Compared to previous month
Last year
62.5%
93,160,955
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
5
fuzzy
1k standalone fuzzy search / fuzzy filter a la Sublime Text's command-p fuzzy file search. Works in both node and browser.
Try it yourself: Disney Character Search Example
Get it
Node:
1$ npm install --save fuzzy 2$ node 3> var fuzzy = require('fuzzy'); 4> console.log(fuzzy) 5{ test: [Function], 6 match: [Function], 7 filter: [Function] }
Browser:
1<script src="/path/to/fuzzy.js"></script> 2<script> 3 console.log(fuzzy); 4 // Object > 5 // filter: function (pattern, arr, opts) { 6 // match: function (pattern, string, opts) { 7 // test: function (pattern, string) { 8</script>
Use it
Padawan: Simply filter an array of strings.
1var list = ['baconing', 'narwhal', 'a mighty bear canoe']; 2var results = fuzzy.filter('bcn', list) 3var matches = results.map(function(el) { return el.string; }); 4console.log(matches); 5// [ 'baconing', 'a mighty bear canoe' ]
Jedi: Wrap matching characters in each string
1var list = ['baconing', 'narwhal', 'a mighty bear canoe']; 2var options = { pre: '<', post: '>' }; 3var results = fuzzy.filter('bcn', list, options) 4console.log(results); 5// [ 6// {string: '<b>a<c>o<n>ing' , index: 0, score: 3, original: 'baconing'}, 7// {string: 'a mighty <b>ear <c>a<n>oe', index: 2, score: 3, original: 'a mighty bear canoe'} 8// ]
Jedi Master: sometimes the array you give is not an array of strings. You can pass in a function that creates the string to match against from each element in the given array
1var list = [ 2 {rompalu: 'baconing', zibbity: 'simba'} 3 , {rompalu: 'narwhal' , zibbity: 'mufasa'} 4 , {rompalu: 'a mighty bear canoe', zibbity: 'saddam hussein'} 5]; 6var options = { 7 pre: '<' 8 , post: '>' 9 , extract: function(el) { return el.rompalu; } 10}; 11var results = fuzzy.filter('bcn', list, options); 12var matches = results.map(function(el) { return el.string; }); 13console.log(matches); 14// [ '<b>a<c>o<n>ing', 'a mighty <b>ear <c>a<n>oe' ]
Examples
Check out the html files in the examples directory.
Try the examples live:
Documentation
Code is well documented and the unit tests cover all functionality
Contributing
Fork the repo!
git clone <your_fork>
cd fuzzy
npm install
make
Add unit tests for any new or changed functionality. Lint, test, and minify using make, then shoot me a pull request.
Release History
v0.1.0 - July 25, 2012
- Initial Release
v0.1.1 - September 19, 2015
- Fix broken links in package.json
- Fix examples
v0.1.2 - September 25, 2016
- Exact matches get the highest score. #15
- Add TypeScript typings #21
- Better error handling for invalid input #13
- Smaller bower install footprint #22
v0.1.3 - October 1, 2016
- Fix blocking bug in React Native #27
License
Copyright (c) 2015 Matt York Licensed under the MIT license.
TODO
- Search improvement: behave a bit more like sublime text by getting
the BEST match in a given string, not just the first. For example,
searching for 'bass' in 'bodacious bass' should match against 'bass',
but it currently matches like so:
<b>od<a>ciou<s> ba<s>s
. There is a test already written, just need to implement it. Naive O(n^2) worst case: find every match in the string, then select the highest scoring match. Should benchmark this against current implementation once implemented Also, "reactive rice" would be<r><e>active r<i><c>e
- Search feature: Work on multiple strings in a match. For example, be able to match against 'stth' against an object { folder: 'stuff', file: 'thing' }
- Async batch updates so the UI doesn't block for huge sets. Or maybe Web Workers?
- Performance performance performance!
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE-MIT:0
- Info: FSF or OSI recognized license: MIT License: LICENSE-MIT:0
Reason
Found 5/20 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 15 are checked with a SAST tool
Score
3.3
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More