{"id":15590587,"url":"https://github.com/cdimascio/fuzzy","last_synced_at":"2025-03-29T10:17:44.538Z","repository":{"id":83296486,"uuid":"301773458","full_name":"cdimascio/fuzzy","owner":"cdimascio","description":null,"archived":false,"fork":false,"pushed_at":"2020-10-06T15:34:17.000Z","size":3518,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-04T02:57:45.812Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/cdimascio.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-06T15:33:36.000Z","updated_at":"2021-02-23T23:31:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"e7efc250-4c67-4fef-ab1a-8d850dfcdf85","html_url":"https://github.com/cdimascio/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/cdimascio%2Ffuzzy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Ffuzzy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Ffuzzy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Ffuzzy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdimascio","download_url":"https://codeload.github.com/cdimascio/fuzzy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246168106,"owners_count":20734391,"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-10-02T23:23:02.093Z","updated_at":"2025-03-29T10:17:44.503Z","avatar_url":"https://github.com/cdimascio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdimascio%2Ffuzzy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdimascio%2Ffuzzy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdimascio%2Ffuzzy/lists"}