{"id":20556995,"url":"https://github.com/sharpvik/fungi","last_synced_at":"2025-04-14T13:20:52.270Z","repository":{"id":46786236,"uuid":"515241516","full_name":"sharpvik/fungi","owner":"sharpvik","description":"Functional stream processing primitives for Go","archived":false,"fork":false,"pushed_at":"2024-12-16T14:50:04.000Z","size":51,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T02:24:21.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/sharpvik.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":"2022-07-18T15:31:43.000Z","updated_at":"2024-12-16T14:50:01.000Z","dependencies_parsed_at":"2024-06-19T05:28:51.483Z","dependency_job_id":"70325b91-d57d-4e90-a0d9-eaf4fb0708a2","html_url":"https://github.com/sharpvik/fungi","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpvik%2Ffungi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpvik%2Ffungi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpvik%2Ffungi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpvik%2Ffungi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sharpvik","download_url":"https://codeload.github.com/sharpvik/fungi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248886334,"owners_count":21177645,"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-16T03:34:13.842Z","updated_at":"2025-04-14T13:20:52.241Z","avatar_url":"https://github.com/sharpvik.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fungi\n\n[![Go Reference](https://pkg.go.dev/badge/pkg.go.dev/github.com/sharpvik/fungi.svg)](https://pkg.go.dev/github.com/sharpvik/fungi@v1.0.0)\n\n**Fungi** provides a great suite of functional stream processing primitives that\ncan be used for a wide range of purposes. Use this library to describe your\nintent declaratively and produce elegant code that is easy to read and refactor.\n\n## Import\n\n```bash\ngo get github.com/sharpvik/fungi@latest\n```\n\n## Spread The Spores\n\nVery soon `fungi` will start popping up all over your codebase! And that is a\ngood thing. Here are some things it can help you with:\n\n1. [`Filter`][filter] out irrelevant items using a custom validation function.\n2. Apply custom transformations to stream items\n   ([`Map`][map], [`TryMap`][try_map]).\n3. Select a [`Range`][range] of items you're interested in.\n4. [`Sort`][sort] items with a generic comparator.\n5. [`Page`][page] items efficiently based on page number and size.\n6. [`Loop`][loop] through every item (see also [`ForEach`][for_each]).\n7. Collect items into a Go builtin `slice` or `map`\n   ([`CollectSlice`][slice], [`CollectMap`][hmap]).\n8. [`Find`][find] an item that fits a description.\n\n[filter]: ./filter.go\n[map]: ./map.go\n[try_map]: ./try_map.go\n[range]: ./range.go\n[sort]: ./sort.go\n[page]: ./page.go\n[loop]: ./loop.go\n[for_each]: ./for_each.go\n[slice]: ./slice.go\n[hmap]: ./hmap.go\n[find]: ./find.go\n\n## Don't Sweat\n\nFungi is very well-tested with a consistent test coverage of **over 95%**.\nSee for yourself:\n\n```bash\ngit clone git@github.com:sharpvik/fungi.git\ncd fungi\ngo test -cover\n```\n\n```text\n[6th of December 2022 checked out at v1.1.0]\nPASS\ncoverage: 98.1% of statements\nok      github.com/sharpvik/fungi       0.193s\n```\n\nMoreover, our tests can and _should_ be used as examples: they are written with\nclarity and readability in mind.\n\n\u003e Test files have the `_test.go` suffix. Browse through, don't be shy!\n\n## Make It Stream\n\nWritten with generics, `fungi` gives you the flexibility to apply it to any\niterator that implements the very simple [`fungi.Stream`](stream.go) interface.\n\nSuppose you already have multiple iterable `type`s that fetch elements using a\nmethod called `Recv`. Here's how you can write a converter function to make them\nall comply with the [`fungi.Stream`](stream.go) interface:\n\n```go\n// Every one of your iterable receivers follows this generic interface.\ntype Receiver[T any] interface {\n    Recv() (T, error)\n}\n\n// receiverStream implements fungi.Stream interface.\ntype receiverStream[T any] struct {\n    Receiver[T]\n}\n\n// Next wraps Recv method of the origincal Receiver.\nfunc (rs receiverStream[T]) Next() (T, error) {\n    return rs.Recv()\n}\n\n// ReceiverStream converts any Receiver into a fungi.Stream.\nfunc ReceiverStream[T any](r Receiver[T]) fungi.Stream[T] {\n    return receiverStream[T]{r}\n}\n```\n\n## Declare Elegance\n\nHere's how your code is going to look soon:\n\n```go\nfunc GetNamesOfMyDrinkingBuddies() ([]string, error) {\n    users := ReceiverStream[*User](GetMyFriends())\n    over18 := fungi.FilterMap(func(u *User) (name string, isLegal bool) {\n        return u.Name, u.Age \u003e= 18\n    })\n    sortAlphabetically := fungi.Sort(func(a, b string) bool { return a \u003c b })\n    return fungi.CollectSlice(sortAlphabetically(over18(users)))\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpvik%2Ffungi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsharpvik%2Ffungi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpvik%2Ffungi/lists"}