{"id":16893779,"url":"https://github.com/ad1992/fuzzify","last_synced_at":"2025-04-05T08:09:56.110Z","repository":{"id":250172983,"uuid":"830452856","full_name":"ad1992/fuzzify","owner":"ad1992","description":"A tiny lightweight library for Fuzzy Search","archived":false,"fork":false,"pushed_at":"2025-02-17T17:21:13.000Z","size":75,"stargazers_count":88,"open_issues_count":3,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T07:07:24.876Z","etag":null,"topics":["fuzz","fuzzy","fuzzy-logic","fuzzy-search","hacktoberfest","lightweight","search","typescript"],"latest_commit_sha":null,"homepage":"https://fuzzify.vercel.app","language":"TypeScript","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/ad1992.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"ad1992"}},"created_at":"2024-07-18T09:53:08.000Z","updated_at":"2025-02-17T17:21:17.000Z","dependencies_parsed_at":"2024-10-26T21:17:46.565Z","dependency_job_id":"ed4ab00b-8107-4716-abac-e34b9ee02c0c","html_url":"https://github.com/ad1992/fuzzify","commit_stats":null,"previous_names":["ad1992/fuzzify"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad1992%2Ffuzzify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad1992%2Ffuzzify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad1992%2Ffuzzify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad1992%2Ffuzzify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ad1992","download_url":"https://codeload.github.com/ad1992/fuzzify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305935,"owners_count":20917208,"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":["fuzz","fuzzy","fuzzy-logic","fuzzy-search","hacktoberfest","lightweight","search","typescript"],"created_at":"2024-10-13T17:16:22.351Z","updated_at":"2025-04-05T08:09:56.073Z","avatar_url":"https://github.com/ad1992.png","language":"TypeScript","funding_links":["https://github.com/sponsors/ad1992"],"categories":[],"sub_categories":[],"readme":"# fuzzify\n\nA tiny lightweight library for Fuzzy Search.\n\n## Why\n\nI made this library as a result of learning about [Levenshtein Distance](https://en.wikipedia.org/wiki/Levenshtein_distance) algorithm to calculate the minimum number of single-character edits (insertions, deletions or substitutions) required to transform one word to another by [Vladimir Levenshtein](https://en.wikipedia.org/wiki/Vladimir_Levenshtein).\n\n\u003e [!NOTE]  \n\u003e Note: The library is at a very early stage so if you want to\n\u003e To help improve it, please open an [issue](https://github.com/ad1992/fuzzify/issues).\n\n## Live Demo\n\nYou can check the demo [here](https://fuzzify.vercel.app/).\n\n\n## Installation\n\nwith `yarn`\n\n```bash\nyarn add fuzzify\n```\n\nwith `npm`\n\n```bash\nnpm install fuzzify\n```\n\n## Usage\n\n```js\nimport Fuzzy from \"fuzzify\";\n\nconst countries = [\n  \"Australia\",\n  \"France\",\n  \"Germany\",\n  \"Hungary\",\n  \"Iceland\",\n  \"India\",\n  \"Israel\",\n  \"Italy\",\n  \"Japan\",\n  \"Malawi\",\n  \"Malaysia\",\n  \"Maldives\",\n];\nconst fuzzy = new Fuzzy(countries);\n\nconst query = \"ala\";\nconst results = fuzzy.search(query);\n\nconsole.log(\"RESULTS\", results);\n```\n\nThe `search` API gives approximate matched strings with the passed query in the below format.\n\n| Attributes | Description                                                                                                        |\n| ---------- | ------------------------------------------------------------------------------------------------------------------ |\n| text       | The target string against which the query is matched                                                                   |\n| distance   | The minimum number of edits (Insertion / Deletion / Substitutions) required to transform the query to target text. |\n\n```js\n[\n  {\n    text: \"Malawi\",\n    distance: 3,\n  },\n  {\n    text: \"Malaysia\",\n    distance: 5,\n  },\n  {\n    text: \"Australia\",\n    distance: 6,\n  },\n  {\n    text: \"Italy\",\n    distance: 3,\n  },\n  {\n    text: \"Japan\",\n    distance: 3,\n  },\n  {\n    text: \"Iceland\",\n    distance: 5,\n  },\n  {\n    text: \"Maldives\",\n    distance: 6,\n  },\n  {\n    text: \"Israel\",\n    distance: 5,\n  },\n  {\n    text: \"India\",\n    distance: 4,\n  },\n  {\n    text: \"France\",\n    distance: 5,\n  },\n  {\n    text: \"Germany\",\n    distance: 6,\n  },\n  {\n    text: \"Hungary\",\n    distance: 6,\n  },\n];\n```\n\n## Options\n\n### `includeMatches`\n\n`includeMatches` - Determines whether the `indices` at which characters match should be returned in the response. \nEach `match` element consists of two indices -\n\n1. The index of query string where match is found.\n2. The index of target string where a match is found.\n\nExample :point_down:\n\n```js\nquery = \"ala\", target string = \"Australia\"\nmatches: [\n  [0, 5],\n  [1, 6],\n  [2, 8],\n],\n```\n\nIn the above example :point_down: matches are found\n\n1. character `a` at `0th` index in `ala` matches with characater `a` at `5th` index in `Australia`\n2. character `l` at `1st` index in `ala` matches with characater `a` at `6th` index in `Australia`\n3. character `a` at `2nd` index in `ala` matches with characater `a` at `8th` index in `Australia`\n\nThe complete response would be :point_down:\n\n```js\n[\n  {\n    text: \"Malawi\",\n    distance: 3,\n    matches: [\n      [0, 1],\n      [1, 2],\n      [2, 3],\n    ],\n  },\n  {\n    text: \"Malaysia\",\n    distance: 5,\n    matches: [\n      [0, 1],\n      [1, 2],\n      [2, 7],\n    ],\n  },\n  {\n    text: \"Australia\",\n    distance: 6,\n    matches: [\n      [0, 5],\n      [1, 6],\n      [2, 8],\n    ],\n  },\n  {\n    text: \"Italy\",\n    distance: 3,\n    matches: [\n      [0, 2],\n      [1, 3],\n    ],\n  },\n  {\n    text: \"Japan\",\n    distance: 3,\n    matches: [\n      [0, 1],\n      [2, 3],\n    ],\n  },\n  {\n    text: \"Iceland\",\n    distance: 5,\n    matches: [\n      [1, 3],\n      [2, 4],\n    ],\n  },\n  {\n    text: \"Maldives\",\n    distance: 6,\n    matches: [\n      [0, 1],\n      [1, 2],\n    ],\n  },\n  {\n    text: \"Israel\",\n    distance: 5,\n    matches: [\n      [0, 3],\n      [1, 5],\n    ],\n  },\n  {\n    text: \"India\",\n    distance: 4,\n    matches: [[2, 4]],\n  },\n  {\n    text: \"France\",\n    distance: 5,\n    matches: [[2, 2]],\n  },\n  {\n    text: \"Germany\",\n    distance: 6,\n    matches: [[2, 4]],\n  },\n  {\n    text: \"Hungary\",\n    distance: 6,\n    matches: [[2, 4]],\n  },\n];\n```\n\n### `includeScore`\n\nDetermines whether a score should be added in the result. A score of `1` means an exact match, however a score of `0` means\nno match and those options are removed from the result.\nIf you want to get all the options in the result, please open an [issue](https://github.com/ad1992/fuzzy/issues) and let's discuss.\n\n### `caseSensitive`\n\nDetermines whether the query should be case-sensitive or not.\nBy default, this option is `false`.\n\n## Set up\n\nInstall packages:\n\n```\nyarn\n```\n\nStart development playground:\n\n```\nyarn start\n```\n\nBuild command:\n\n```\nyarn build\n```\n\n## Contributing\n\nPlease open an [issue](https://github.com/ad1992/fuzzify/issues) so we can start discussing. Any help to improve the library is most welcome :).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fad1992%2Ffuzzify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fad1992%2Ffuzzify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fad1992%2Ffuzzify/lists"}