{"id":18555679,"url":"https://github.com/mixpanel/fuzzbunny","last_synced_at":"2025-04-09T23:32:25.254Z","repository":{"id":43914672,"uuid":"233734382","full_name":"mixpanel/fuzzbunny","owner":"mixpanel","description":"Fast fuzzy string searching/matching/highlighting","archived":true,"fork":false,"pushed_at":"2023-07-18T23:30:39.000Z","size":2247,"stargazers_count":83,"open_issues_count":8,"forks_count":5,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-03-28T19:49:26.619Z","etag":null,"topics":["fuzzy-matching","fuzzy-search","javascript","search"],"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/mixpanel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-01-14T01:58:42.000Z","updated_at":"2025-02-23T12:28:46.000Z","dependencies_parsed_at":"2024-06-21T20:18:01.357Z","dependency_job_id":"b4894621-e2e0-4d50-acbb-bd714ceec61d","html_url":"https://github.com/mixpanel/fuzzbunny","commit_stats":{"total_commits":66,"total_committers":4,"mean_commits":16.5,"dds":"0.28787878787878785","last_synced_commit":"4c44776f5d428e4787296b5da9a6408fd435f8f1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixpanel%2Ffuzzbunny","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixpanel%2Ffuzzbunny/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixpanel%2Ffuzzbunny/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixpanel%2Ffuzzbunny/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mixpanel","download_url":"https://codeload.github.com/mixpanel/fuzzbunny/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248129936,"owners_count":21052668,"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":["fuzzy-matching","fuzzy-search","javascript","search"],"created_at":"2024-11-06T21:27:33.869Z","updated_at":"2025-04-09T23:32:23.300Z","avatar_url":"https://github.com/mixpanel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fuzzbunny\n\n`fuzzbunny` is a small (1k), fast \u0026 memory efficient fuzzy string searching/matching/highlighting library.\nIt works equally well in a browser environment or Node.js.\n\n![Build Status](https://github.com/mixpanel/fuzzbunny/actions/workflows/tests.yml/badge.svg)\n[![npm](https://img.shields.io/npm/v/fuzzbunny.svg)](https://www.npmjs.com/package/fuzzbunny)\n[![npm](https://img.shields.io/npm/dm/fuzzbunny.svg)](https://www.npmjs.com/package/fuzzbunny)\n[![npm](https://img.shields.io/npm/l/fuzzbunny.svg)](https://github.com/mixpanel/fuzzbunny/blob/master/LICENCE)\n\n## Why fuzzbunny?\n\n- **Human friendly** - fuzzbunny scoring and algorithm is more tuned to \"human\" searching patterns. It surfaces what you're looking for with minimal keystrokes.\n- **Lightweight** - ~3KB minified and has zero dependencies.\n- **Ultra fast** - ~million lines/second on a 2.4Ghz virtual core.\n\nOther similar libraries are [fuzzymatch](https://www.npmjs.com/package/fuzzymatch), [fuzzy](https://www.npmjs.com/package/fuzzy), [fuzzy-search](fuzzy-search), [fuzzyjs](fuzzyjs).\n\n`fuzzbunny` aims to be nimble and fast. It has a simple api that can easily be integrated with any frontend library to build great search UI. We use it at [mixpanel.com](https://mixpanel.com) to power our UI dropdowns and tables.\n\n## Installation\n\n`npm install --save fuzzbunny` or `yarn add fuzzbunny`\n\n## Demo\n\n[Fuzzbunny Gutenberg Catalog Demo →](https://mixpanel.github.io/fuzzbunny)\n\n![Fuzzbunny demo](https://user-images.githubusercontent.com/1018196/77124047-0fbf6580-69ff-11ea-8d44-f8006b7770fd.gif)\n\n## Usage\n\n```js\nconst {fuzzyFilter, fuzzyMatch} = require(`fuzzbunny`);\n// or import {fuzzyFilter, fuzzyMatch} from 'fuzzbunny';\n\nconst heroes = [\n  {\n    name: `Claire Bennet`,\n    ability: `Rapid cellular regeneration`,\n  },\n  {\n    name: `Micah Sanders`,\n    ability: `Technopathy`,\n  },\n  {\n    name: `Hiro Nakamura`,\n    ability: `Space-time manipulation`,\n  },\n  {\n    name: `Peter Petrelli`,\n    ability: `Tactile power mimicry`,\n  },\n];\n\n// Use fuzzyFilter to filter an array of items on specific fields and get filtered + score-sorted results with highlights.\nconst results = fuzzyFilter(heroes, `stm`, {fields: [`name`, `ability`]});\n/*\nresults = [\n  {\n    item: {\n      name: 'Peter Petrelli',\n      ability: 'Tactile power mimicry',\n    },\n    score: 1786,\n    highlights: {\n      ability: ['', 'T', 'actile power ', 'm', 'imicry'],\n    },\n  },\n  {\n    item: {\n      name: 'Hiro Nakamura',\n      ability: 'Space-time manipulation',\n    },\n    score: 983,\n    highlights: {\n      ability: ['Space-', 't', 'ime ', 'm', 'anipulation'],\n    },\n  },\n];\n*/\n\n// Use fuzzyMatch to match a single string to get score + highlights. Returns null if no match found.\nconst match = fuzzyMatch(heroes[0].name, `ben`);\n/*\nmatch = {\n  score: 2893,\n  highlights: ['Claire ', 'Ben', 'net'],\n};\n*/\n```\n\n## Scoring and Sort order\n\n`fuzzbunny` uses a scoring algorithm that prioritizes following signals. See `_getMatchScore` function.\n\nExample 1:\n\n- Start of string - `{Mayfl}ower` ranks above `The {Mayfl}ower`\n- Closer to start - `The {Mayfl}ower` ranks above `Story of the {Mayfl}ower`\n- Contiguous length - `The {Mayfl}ower` ranks above `{May} {fl}ower`\n- Alphabetically - `The {May} {fl}ower` ranks above `This {May} {fl}ower`\n\n![image](https://user-images.githubusercontent.com/1018196/77127584-58305080-6a0a-11ea-9fee-d8eaf28744b8.png)\n\nExample 2:\n\n```js\nconst f = require(`fuzzbunny`);\nf.fuzzyMatch(`Gobbling pupusas`, `usa`);\n// {score: 2700, highlights: ['Gobbling pup', 'usa', 's']}\nf.fuzzyMatch(`United Sheets of Antarctica`, `usa`);\n// {score: 2276, highlights: ['', 'U', 'nited ', 'S', 'heets of ', 'A', 'ntarctica']}\n```\n\n`Gobbling pup{usa}s` wins because 3 letter contiguous sequence yields a higher score.\n\n**NOTE**: `fuzzbunny` optmizes for meaningful results. It only does substring/prefix/acronym-matching, not greedy matching.\n\nThis is because humans brains are great at prefix recall.\ne.g words that start with \"ca\" are much easier to recall than words that contain the letters \"c\" and \"a\" somewhere.\nIt's easy to remember that `{usa}` stands for `{U}nited {S}tates of {A}merica`, not `F{u}ll Java{s}cript Fr{a}mework`\n\n## Performance\n\n`fuzzbunny` matches ~ million lines/second on modern hardware. Tested on 2018 MacBook Pro with 2.4Ghz CPU.\nSee [tests/performance.js](tests/performance.js)\n\n## Types\n\n`fuzzbunny` comes with autogenerated TypeScript types. See [index.d.ts](index.d.ts)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixpanel%2Ffuzzbunny","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmixpanel%2Ffuzzbunny","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixpanel%2Ffuzzbunny/lists"}