{"id":19140748,"url":"https://github.com/tijn/fuzzy","last_synced_at":"2025-06-15T12:37:51.896Z","repository":{"id":66758495,"uuid":"135813731","full_name":"tijn/fuzzy","owner":"tijn","description":"Fuzzy finder algorithm for Crystal Lang","archived":false,"fork":false,"pushed_at":"2018-06-02T12:00:56.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-07T17:08:33.179Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/tijn.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":"2018-06-02T11:55:16.000Z","updated_at":"2018-06-02T12:00:57.000Z","dependencies_parsed_at":"2023-04-04T14:32:59.688Z","dependency_job_id":null,"html_url":"https://github.com/tijn/fuzzy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tijn/fuzzy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tijn%2Ffuzzy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tijn%2Ffuzzy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tijn%2Ffuzzy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tijn%2Ffuzzy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tijn","download_url":"https://codeload.github.com/tijn/fuzzy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tijn%2Ffuzzy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259977525,"owners_count":22941114,"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-11-09T07:18:38.451Z","updated_at":"2025-06-15T12:37:51.720Z","avatar_url":"https://github.com/tijn.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fuzzy\n\nFuzzy finder algorithm. Fuzzy like [fzf](https://github.com/junegunn/fzf) or ctrl+t in vim or cmd+p in Sublime Text or Visual Studio. It's not [blue](https://www.youtube.com/watch?v=2NSdNtOktHE) though.\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  fuzzy:\n    github: tijn/fuzzy\n```\n\n## Usage\n\nYou can use a `Fuzzy::Pattern` like a `Regex`. It supports a similar interface:\n\n```crystal\nrequire \"fuzzy\"\n\npattern = Fuzzy::Pattern.new(\"needle\") # a needle in a haystack\n\n# see if it matches a string\npattern.match? \"this needle cushion\" # =\u003e true\npattern.match? \"foo\" # =\u003e false\n\npattern =~ \"that needle cushion\" # =\u003e true\npattern =~ \"bar\" # =\u003e false\n\n# see which characters are matched\npattern.match \"those needle cushions\" # =\u003e [6, 7, 8, 9, 10, 11]\nFuzzy::Pattern.new(\"foo\").match(\"reforestation\") # =\u003e [2, 3, 11]\nFuzzy::Pattern.new(\"foo\").match(\"bar\") # =\u003e nil\n\n# case equality\nSTDIN.each_line do |line|\ncase line\nwhen ''\n  # empty line\nwhen pattern\n  # it matches your pattern (needle)\nelse\n  # dunno?\nend\n```\n\n## Development\n\nI experimented with several variations of the algorithm. You can find them in `benchmarks/fuzzy_benchmark.cr`.\n\nThere isn't much variation in the results. Typical output on my computer looks like this:\n\n```\nASCII:\n      naive  48.75M ( 20.51ns) (± 3.62%)       fastest\n   iterator   4.11M (243.49ns) (± 5.99%) 11.87× slower\n  iterator2   4.34M ( 230.2ns) (± 5.04%) 11.22× slower\n      array   3.68M (271.78ns) (± 2.39%) 13.25× slower\n codepoints   3.61M (277.14ns) (± 4.17%) 13.51× slower\nchar_reader   6.84M (146.24ns) (± 1.23%)  7.13× slower\n\nUnicode:\n      naive   4.56M (219.37ns) (± 1.42%)  1.41× slower\n   iterator   3.72M ( 268.8ns) (± 3.52%)  1.72× slower\n  iterator2   3.83M (261.27ns) (± 4.94%)  1.67× slower\n      array   2.99M (334.87ns) (± 5.24%)  2.14× slower\n codepoints   2.99M (334.19ns) (± 4.83%)  2.14× slower\nchar_reader   6.41M (156.13ns) (± 2.33%)       fastest\n```\n\nI decided to keep the naive algorithm for now. I might try to switch to a hybrid solution (naive and char_reader) in the future.\n\n## Contributing\n\n1. Fork it ( https://github.com/tijn/fuzzy/fork )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n- [tijn](https://github.com/tijn) Tijn Schuurmans - creator, maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftijn%2Ffuzzy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftijn%2Ffuzzy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftijn%2Ffuzzy/lists"}