{"id":13437937,"url":"https://github.com/farzher/fuzzysort","last_synced_at":"2025-05-13T16:11:23.665Z","repository":{"id":41329956,"uuid":"100681719","full_name":"farzher/fuzzysort","owner":"farzher","description":"Fast SublimeText-like fuzzy search for JavaScript.","archived":false,"fork":false,"pushed_at":"2024-10-14T06:14:17.000Z","size":1764,"stargazers_count":3953,"open_issues_count":8,"forks_count":159,"subscribers_count":38,"default_branch":"master","last_synced_at":"2024-10-30T01:02:30.700Z","etag":null,"topics":["filter","fuzzy","javascript","search","sublime"],"latest_commit_sha":null,"homepage":"https://rawgit.com/farzher/fuzzysort/master/test/test.html","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/farzher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-08-18T06:43:55.000Z","updated_at":"2024-10-27T08:13:34.000Z","dependencies_parsed_at":"2024-05-28T15:53:09.543Z","dependency_job_id":"25e1da5c-cd57-4067-8bab-6181812129d2","html_url":"https://github.com/farzher/fuzzysort","commit_stats":{"total_commits":185,"total_committers":4,"mean_commits":46.25,"dds":0.01621621621621616,"last_synced_commit":"c7f1d2674d7fa526015646bc02fd17e29662d30c"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzher%2Ffuzzysort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzher%2Ffuzzysort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzher%2Ffuzzysort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzher%2Ffuzzysort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/farzher","download_url":"https://codeload.github.com/farzher/fuzzysort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250248479,"owners_count":21399274,"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":["filter","fuzzy","javascript","search","sublime"],"created_at":"2024-07-31T03:01:01.392Z","updated_at":"2025-04-22T13:30:46.768Z","avatar_url":"https://github.com/farzher.png","language":"JavaScript","readme":"\u003cp align=\"center\"\u003e\u003ca href=\"https://raw.github.com/farzher/fuzzysort/master/fuzzysort.js\"\u003e\n  \u003cimg src=\"https://i.imgur.com/axkOMVs.png\" alt=\"fuzzysort\" /\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  Fast, Tiny, \u0026 Good fuzzy search for JavaScript.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eFast:\u003c/b\u003e \u003cb\u003e\u0026lt;1ms\u003c/b\u003e to search \u003cb\u003e13,000\u003c/b\u003e files.\n  \u003cbr\u003e\n  \u003cb\u003eTiny:\u003c/b\u003e \u003cb\u003e1 file\u003c/b\u003e, \u003cb\u003e0 dependencies\u003c/b\u003e, \u003cb\u003e5kb\u003c/b\u003e.\n  \u003cbr\u003e\n  \u003cb\u003eGood:\u003c/b\u003e clean api + sorts results well.\n\u003c/p\u003e\n\n\n## [Demo](https://rawgit.com/farzher/fuzzysort/master/test/test.html)\n\nhttps://rawgit.com/farzher/fuzzysort/master/test/test.html\n\n![](https://i.imgur.com/muaw363.gif)\n\n![](https://i.imgur.com/SXC9A3q.png)\n\n![](https://i.imgur.com/fUkJ7G3.png)\n\n![](https://i.imgur.com/CnVXRbf.png)\n\n\n\n\n\n## Installation Node / Bun / Deno\n\n```sh\nnpm i fuzzysort\n```\n```js\nimport fuzzysort from 'fuzzysort'\n```\n```js\nconst fuzzysort = require('fuzzysort')\n```\n\n\n\n## Installation Browser\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/fuzzysort@3.1.0/fuzzysort.min.js\"\u003e\u003c/script\u003e\n```\n\n\n## Usage\n\n### `fuzzysort.go(search, targets, options=null)`\n\n```js\nconst mystuff = [{file: 'Apple.cpp'}, {file: 'Banana.cpp'}]\nconst results = fuzzysort.go('a', mystuff, {key: 'file'})\n// [{score: 0.81, obj: {file: 'Apple.cpp'}}, {score: 0.59, obj: {file: 'Banana.cpp'}}]\n```\n\n### Options\n\n```js\nfuzzysort.go(search, targets, {\n  threshold: 0,    // Don't return matches worse than this\n  limit: 0,        // Don't return more results than this\n  all: false,      // If true, returns all results for an empty search\n\n  key: null,       // For when targets are objects (see its example usage)\n  keys: null,      // For when targets are objects (see its example usage)\n  scoreFn: null,   // For use with `keys` (see its example usage)\n})\n```\n\n\n\n\n## What's a `result`\n\n```js\nconst result = fuzzysort.single('query', 'some string that contains my query.')\nresult.score       // .80 (1 is a perfect match. 0.5 is a good match. 0 is no match.)\nresult.target      // 'some string that contains my query.'\nresult.obj         // reference to your original obj when using options.key\nresult.indexes     // [29, 30, 31, 32, 33]\n\nresult.highlight('\u003cb\u003e', '\u003c/b\u003e')\n// 'some string that contains my \u003cb\u003equery\u003c/b\u003e.'\n\nresult.highlight((m, i) =\u003e \u003creact key={i}\u003e{m}\u003c/react\u003e)\n// ['some string that contains my ', \u003creact key=0\u003equery\u003c/react\u003e, '.']\n```\n\n### Advanced Usage\n\nSearch a list of objects, by multiple complex keys, with custom weights.\n\n```js\nlet objects = [{\n  title: 'Liechi Berry',\n  meta: {desc: 'Raises Attack when HP is low.'},\n  tags: ['berries', 'items'],\n  bookmarked: true,\n}, {\n  title: 'Petaya Berry',\n  meta: {desc: 'Raises Special Attack when HP is low.'},\n}]\n\nlet results = fuzzysort.go('attack berry', objects, {\n  keys: ['title', 'meta.desc', obj =\u003e obj.tags?.join()],\n  scoreFn: r =\u003e r.score * r.obj.bookmarked ? 2 : 1, // if the item is bookmarked, boost its score\n})\n\nvar keysResult = results[0]\n// When using multiple `keys`, results are different. They're indexable to get each normal result\nkeysResult[0].highlight() // 'Liechi \u003cb\u003eBerry\u003c/b\u003e'\nkeysResult[1].highlight() // 'Raises \u003cb\u003eAttack\u003c/b\u003e when HP is low.'\nkeysResult.score          // .84\nkeysResult.obj.title      // 'Liechi Berry'\n```\n\n\n\n## How To Go Fast · Performance Tips\n\n```js\nlet targets = [{file: 'Monitor.cpp'}, {file: 'MeshRenderer.cpp'}]\n\n// filter out targets that you don't need to search! especially long ones!\ntargets = targets.filter(t =\u003e t.file.length \u003c 1000)\n\n// if your targets don't change often, provide prepared targets instead of raw strings!\ntargets.forEach(t =\u003e t.filePrepared = fuzzysort.prepare(t.file))\n\n// don't use options.key if you don't need a reference to your original obj\ntargets = targets.map(t =\u003e t.filePrepared)\n\nconst options = {\n  limit: 100,    // don't return more results than you need!\n  threshold: .5, // don't return bad results\n}\nfuzzysort.go('gotta', targets, options)\nfuzzysort.go('go',    targets, options)\nfuzzysort.go('fast',  targets, options)\n```\n\n\n### Gotcha\n`result.score` is implemented as a getter/setter and stored different internally\n`r.score = .3; // r.score == 0.30000000000000004`\n\n\n\n\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=farzher/fuzzysort)](https://star-history.com/#farzher/fuzzysort)\n\n\n\n### Changelog\n\n#### v3.1.0\n- Automatically handle diacritics / accents / ligatures\n\n#### v3.0.0\n- Added new behavior when using `keys` and your search contains spaces!\n- Added `options.key` can now be a function `{key: obj =\u003e obj.tags.join()}`\n- Removed `fuzzysort.indexes` \u0026 Added `result.indexes` (as a getter/setter for GC perf)\n- Removed `fuzzysort.highlight()` \u0026 Added `result.highlight()`\n- Changed scoring: score is now a number from 0 to 1 instead of from -Infinity to 0\n- Changed scoring: substring matches are even more relevant\n- Changed scoring: `straw berry` now matches great against `strawberry`\n- Changed scoring: tweaked the scoring quite a bit\n- `result.score` is behind a getter/setter for performance reasons\n- Fixed minor issues\n\n#### v2.0.0\n- Added new behavior when your search contains spaces!\n- Added fuzzysort.min.js\n- Now depends on ES6 features\n- Removed `result.indexes` \u0026 Added `fuzzysort.indexes` (improved GC performance)\n- Completely Removed `options.allowTypo`\n- Completely Removed `fuzzysort.goAsync`\n- Completely Removed `fuzzysort.new`\n- Rewrote the demo\n\n#### v1.9.0\n- Even faster\n- Added `options.all`\n- Deprecated/Removed `options.allowTypo`\n- Deprecated/Removed `fuzzysort.goAsync`\n- Changed scoring: boosted substring matches\n- Changed scoring: targets with too many beginning indexes lose points for being a bad target\n- Changed scoring: penality for not starting near the beginning\n- Changed scoring: penality for more groups\n- Fixed \"Exponential backtracking hangs browser\"\n\n#### v1.2.0\n- Added `fuzzysort.highlight(result, callback)`\n\n#### v1.1.0\n- Added `allowTypo` as an option\n\n#### v1.0.0\n\n- Inverted scores; they're now negative instead of positive, so that higher scores are better\n- Added ability to search objects by `key`/`keys` with custom weights\n- Removed the option to automatically highlight and exposed `fuzzysort.highlight`\n- Removed all options from `fuzzysort` and moved them into `fuzzysort.go` optional params\n\n#### v0.x.x\n\n- init\n","funding_links":[],"categories":["JavaScript","javascript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarzher%2Ffuzzysort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarzher%2Ffuzzysort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarzher%2Ffuzzysort/lists"}