{"id":13878654,"url":"https://github.com/maxim/enum_utils","last_synced_at":"2025-07-20T21:32:35.475Z","repository":{"id":59153637,"uuid":"466000337","full_name":"maxim/enum_utils","owner":"maxim","description":"Functions for mixing and matching lazy, potentially infinite enumerables.","archived":false,"fork":false,"pushed_at":"2022-07-18T01:32:46.000Z","size":16,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-19T08:45:43.312Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/maxim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-04T05:54:42.000Z","updated_at":"2022-10-31T17:26:23.000Z","dependencies_parsed_at":"2022-09-13T11:01:18.126Z","dependency_job_id":null,"html_url":"https://github.com/maxim/enum_utils","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/maxim/enum_utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxim%2Fenum_utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxim%2Fenum_utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxim%2Fenum_utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxim%2Fenum_utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxim","download_url":"https://codeload.github.com/maxim/enum_utils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxim%2Fenum_utils/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266080436,"owners_count":23873505,"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-08-06T08:01:55.782Z","updated_at":"2025-07-20T21:32:35.450Z","avatar_url":"https://github.com/maxim.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# EnumUtils\n\nFunctions for mixing and matching lazy, potentially infinite enumerables.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'enum_utils'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install enum_utils\n\n## Usage\n\n### EnumUtils.sorted_intersection\n\nGiven N consistently-sorted enums, return unique values that appear in at least\n[degree] number of different enums, preserving the global order, until all enums\nare depleted. By default a value must appear in all of them.\n\n```ruby\n# 3 ascending enums\nEnumUtils.sorted_intersection(\n  [1,2].each,\n  [2,3].each,\n  [1,2,5].each\n).to_a # =\u003e [2]\n\n# 3 descending enums\nEnumUtils.sorted_intersection(\n  [2,1].each,\n  [3,2].each,\n  [5,2,1].each,\n  compare: -\u003e a, b { b \u003c=\u003e a } # reverse order comparison\n).to_a # =\u003e [2]\n\n# 3 ascending enums with degree 2\nEnumUtils.sorted_intersection(\n  [1,2].each,\n  [2,3].each,\n  [1,2,5].each,\n  degree: 2\n).to_a # =\u003e [1, 2]\n```\n\n### EnumUtils.sorted_union\n\nGiven N consistently-sorted enums, return all their unique values while\npreserving their global order. If `with_index: true` is given, also return index\nof the enum in which the corresponding value was first seen.\n\n```ruby\n# 3 ascending enums\nEnumUtils.sorted_union(\n  [1,2].each,\n  [2,3].each,\n  [1,2,5].each\n).to_a # =\u003e [1,2,3,5]\n\n# 3 descending enums\nEnumUtils.sorted_union(\n  [2,1].each,\n  [3,2].each,\n  [5,2,1].each,\n  compare: -\u003e a, b { b \u003c=\u003e a } # reverse order comparison\n).to_a # =\u003e [5,3,2,1]\n\n# 3 ascending enums with index\nEnumUtils.sorted_union(\n  [1,2].each,\n  [2,3].each,\n  [1,2,5].each,\n  with_index: true\n).to_a # =\u003e [[1,0], [2,0], [3,1], [5,2]]\n```\n\n### EnumUtils.sorted_merge\n\nGiven N consistently-sorted enums, return all their values while preserving the\nglobal order. If `with_index: true` is given, also return index in the enum that\noriginated the value.\n\n```ruby\n## 3 ascending enums\nEnumUtils.sorted_merge(\n  [1,2].each,\n  [2,3].each,\n  [1,2,5].each\n).to_a # =\u003e [1,1,2,2,2,3,5]\n\n## 3 descending enums\nEnumUtils.sorted_merge(\n  [2,1].each,\n  [3,2].each,\n  [5,2,1].each,\n  compare: -\u003e a, b { b \u003c=\u003e a } # reverse order comparison\n).to_a # =\u003e [5,3,2,2,2,1,1]\n\n## 3 ascending enums with index\nEnumUtils.sorted_union(\n  [1,2].each,\n  [2,3].each,\n  [1,2,5].each,\n  with_index: true\n).to_a # =\u003e [[1,0], [1,2], [2,0], [2,1], [2,2], [3,1], [5,2]]\n```\n\n### EnumUtils.round_robin\n\nGiven N enums, return all their values by taking one value from each enum in\nturn, until all are exhausted. If `with_index: true` is given, also return index\nof the enum that originated the value.\n\n```ruby\n## 3 enums\nEnumUtils.round_robin(\n  [3,2].each,\n  [1,3].each,\n  [5,3,4].each\n).to_a # =\u003e [3,1,5,2,3,3,4]\n\n## 3 enums with index\nEnumUtils.round_robin(\n  [3,2].each,\n  [1,3].each,\n  [5,3,4].each,\n  with_index: true\n).to_a # =\u003e [[3,0], [1,1], [5,2], [2,0], [3,1], [3,2], [4,2]]\n```\n\n### EnumUtils.concat\n\nGiven N enums, return a new enum which lazily exhausts every enum.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run\n`rake test` to run the tests. You can also run `bin/console` for an interactive\nprompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To\nrelease a new version, update the version number in `version.rb`, and then run\n`bundle exec rake release`, which will create a git tag for the version, push\ngit commits and the created tag, and push the `.gem` file to\n[rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at\nhttps://github.com/maxim/enum_utils. This project is intended to be a safe,\nwelcoming space for collaboration, and contributors are expected to adhere to\nthe [code of\nconduct](https://github.com/maxim/enum_utils/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the EnumUtils project's codebases, issue trackers, chat\nrooms and mailing lists is expected to follow the [code of\nconduct](https://github.com/maxim/enum_utils/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxim%2Fenum_utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxim%2Fenum_utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxim%2Fenum_utils/lists"}