{"id":13447240,"url":"https://github.com/mattyork/fuzzy","last_synced_at":"2025-10-22T09:40:58.188Z","repository":{"id":3960886,"uuid":"5054664","full_name":"mattyork/fuzzy","owner":"mattyork","description":"Filters a list based on a fuzzy string search","archived":false,"fork":false,"pushed_at":"2021-12-20T07:11:22.000Z","size":3514,"stargazers_count":833,"open_issues_count":29,"forks_count":86,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-01-25T09:15:13.360Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattyork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-15T08:31:52.000Z","updated_at":"2024-12-27T09:43:30.000Z","dependencies_parsed_at":"2022-07-12T23:10:35.913Z","dependency_job_id":null,"html_url":"https://github.com/mattyork/fuzzy","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattyork%2Ffuzzy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattyork%2Ffuzzy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattyork%2Ffuzzy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattyork%2Ffuzzy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattyork","download_url":"https://codeload.github.com/mattyork/fuzzy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806070,"owners_count":20350775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:11.795Z","updated_at":"2025-10-22T09:40:53.131Z","avatar_url":"https://github.com/mattyork.png","language":"JavaScript","readme":"# fuzzy [![Build Status](https://img.shields.io/travis/mattyork/fuzzy/master.svg)](https://travis-ci.org/mattyork/fuzzy) [![npm version](https://badge.fury.io/js/fuzzy.svg)](https://badge.fury.io/js/fuzzy)\n\n1k standalone fuzzy search / fuzzy filter a la Sublime Text's command-p fuzzy file search. Works in both node and browser.\n\n[![Example](http://i.imgur.com/obzCQq7.gif)](http://htmlpreview.github.io/?https://github.com/mattyork/fuzzy/blob/master/examples/disney.html)\n\nTry it yourself: [Disney Character Search Example](http://htmlpreview.github.io/?https://github.com/mattyork/fuzzy/blob/master/examples/disney.html)\n\n## Get it\n\nNode:\n\n```bash\n$ npm install --save fuzzy\n$ node\n\u003e var fuzzy = require('fuzzy');\n\u003e console.log(fuzzy)\n{ test: [Function],\n  match: [Function],\n  filter: [Function] }\n```\n\nBrowser:\n\n```html\n\u003cscript src=\"/path/to/fuzzy.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  console.log(fuzzy);\n  // Object \u003e\n  //   filter: function (pattern, arr, opts) {\n  //   match: function (pattern, string, opts) {\n  //   test: function (pattern, string) {\n\u003c/script\u003e\n```\n\n## Use it\n\nPadawan: Simply filter an array of strings.\n\n```javascript\nvar list = ['baconing', 'narwhal', 'a mighty bear canoe'];\nvar results = fuzzy.filter('bcn', list)\nvar matches = results.map(function(el) { return el.string; });\nconsole.log(matches);\n// [ 'baconing', 'a mighty bear canoe' ]\n```\n\nJedi: Wrap matching characters in each string\n\n```javascript\nvar list = ['baconing', 'narwhal', 'a mighty bear canoe'];\nvar options = { pre: '\u003c', post: '\u003e' };\nvar results = fuzzy.filter('bcn', list, options)\nconsole.log(results);\n// [\n//   {string: '\u003cb\u003ea\u003cc\u003eo\u003cn\u003eing'           , index: 0, score: 3, original: 'baconing'},\n//   {string: 'a mighty \u003cb\u003eear \u003cc\u003ea\u003cn\u003eoe', index: 2, score: 3, original: 'a mighty bear canoe'}\n// ]\n```\n\nJedi Master: sometimes the array you give is not an array of strings. You can\npass in a function that creates the string to match against from each element\nin the given array\n\n```javascript\nvar list = [\n    {rompalu: 'baconing', zibbity: 'simba'}\n  , {rompalu: 'narwhal' , zibbity: 'mufasa'}\n  , {rompalu: 'a mighty bear canoe', zibbity: 'saddam hussein'}\n];\nvar options = {\n    pre: '\u003c'\n  , post: '\u003e'\n  , extract: function(el) { return el.rompalu; }\n};\nvar results = fuzzy.filter('bcn', list, options);\nvar matches = results.map(function(el) { return el.string; });\nconsole.log(matches);\n// [ '\u003cb\u003ea\u003cc\u003eo\u003cn\u003eing', 'a mighty \u003cb\u003eear \u003cc\u003ea\u003cn\u003eoe' ]\n```\n\n## Examples\nCheck out the html files in the [examples](https://github.com/mattyork/fuzzy/tree/master/examples) directory.\n\nTry the examples live: \n- [disney](http://htmlpreview.github.io/?https://github.com/mattyork/fuzzy/blob/master/examples/disney.html)\n- [wikipedia](http://htmlpreview.github.io/?https://github.com/mattyork/fuzzy/blob/master/examples/wikipedia.html)\n## Documentation\n[Code is well documented](https://github.com/mattyork/fuzzy/blob/master/lib/fuzzy.js) and the [unit tests](https://github.com/mattyork/fuzzy/blob/master/test/fuzzy.test.js) cover all functionality\n\n## Contributing\nFork the repo!\n\n    git clone \u003cyour_fork\u003e\n    cd fuzzy\n    npm install\n    make\n\nAdd unit tests for any new or changed functionality. Lint, test, and minify using make, then shoot me a pull request.\n\n## Release History\nv0.1.0 - July 25, 2012\n\n* Initial Release\n\nv0.1.1 - September 19, 2015\n\n* Fix broken links in package.json\n* Fix examples\n\nv0.1.2 - September 25, 2016\n\n* Exact matches get the highest score. #15\n* Add TypeScript typings #21\n* Better error handling for invalid input #13\n* Smaller bower install footprint #22\n\nv0.1.3 - October 1, 2016\n\n* Fix blocking bug in React Native #27\n\n## License\nCopyright (c) 2015 Matt York\nLicensed under the MIT license.\n\n## TODO\n\n1. Search improvement: behave a bit more like sublime text by getting\n   the BEST match in a given string, not just the first. For example,\n   searching for 'bass' in 'bodacious bass' should match against 'bass',\n   but it currently matches like so: `\u003cb\u003eod\u003ca\u003eciou\u003cs\u003e ba\u003cs\u003es`. There is\n   a test already written, just need to implement it. Naive O(n^2) worst\n   case: find every match in the string, then select the highest scoring\n   match. Should benchmark this against current implementation once implemented\n   Also, \"reactive rice\" would be `\u003cr\u003e\u003ce\u003eactive r\u003ci\u003e\u003cc\u003ee`\n2. Search feature: Work on multiple strings in a match. For example, be able\n   to match against 'stth' against an object { folder: 'stuff', file: 'thing' }\n3. Async batch updates so the UI doesn't block for huge sets. Or maybe Web Workers?\n4. Performance performance performance!\n","funding_links":[],"categories":["JavaScript","UI Components","Search","Text Search"],"sub_categories":["Search","Surveys","Fuzzy search"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattyork%2Ffuzzy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattyork%2Ffuzzy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattyork%2Ffuzzy/lists"}