{"id":13412912,"url":"https://github.com/rjNemo/underscore","last_synced_at":"2025-03-14T18:32:42.069Z","repository":{"id":38257408,"uuid":"442608102","full_name":"rjNemo/underscore","owner":"rjNemo","description":"🌟 Useful functional programming helpers for Go","archived":false,"fork":false,"pushed_at":"2024-09-08T18:32:16.000Z","size":5713,"stargazers_count":110,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-09T19:33:32.743Z","etag":null,"topics":["functional","functional-programming","go","golang","library"],"latest_commit_sha":null,"homepage":"https://underscore.onrender.com/","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/rjNemo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"rjNemo"}},"created_at":"2021-12-28T23:23:16.000Z","updated_at":"2024-09-08T18:32:19.000Z","dependencies_parsed_at":"2024-01-08T15:02:51.816Z","dependency_job_id":"a15d08f9-a33f-44f3-b873-b79e2b3fe154","html_url":"https://github.com/rjNemo/underscore","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjNemo%2Funderscore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjNemo%2Funderscore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjNemo%2Funderscore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjNemo%2Funderscore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rjNemo","download_url":"https://codeload.github.com/rjNemo/underscore/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221495316,"owners_count":16832458,"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":["functional","functional-programming","go","golang","library"],"created_at":"2024-07-30T20:01:30.984Z","updated_at":"2025-03-14T18:32:42.062Z","avatar_url":"https://github.com/rjNemo.png","language":"Go","readme":"# \\_Underscore\n\n![License](https://img.shields.io/github/license/rjNemo/underscore?style=for-the-badge)\n[![Go version](https://img.shields.io/github/go-mod/go-version/rjNemo/underscore?style=for-the-badge\u0026logo=go)](https://pkg.go.dev/github.com/rjNemo/underscore)\n![Go report](https://goreportcard.com/badge/github.com/rjNemo/underscore?style=for-the-badge)\n![test coverage](https://img.shields.io/codecov/c/github/rjNemo/underscore?style=for-the-badge\u0026logo=codecov)\n[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9726/badge?style=for-the-badge)](https://www.bestpractices.dev/projects/9726)\n\n![underscore](https://socialify.git.ci/rjNemo/underscore/image?description=1\u0026font=KoHo\u0026language=1\u0026logo=https%3A%2F%2Fraw.githubusercontent.com%2FrjNemo%2Funderscore%2Fmain%2Fdocs%2Fstatic%2Flogo.png\u0026owner=1\u0026pattern=Floating%20Cogs\u0026stargazers=1\u0026theme=Dark)\n\n`underscore` is a `Go` library providing useful functional programming helpers without\nextending any built-in objects.\n\nIt is mostly a port from the `underscore.js` library based on generics brought by\n`Go 1.18`.\n\n## Usage\n\n📚 Follow this link for the [documentation](https://underscore.onrender.com/).\n\nInstall the library using\n\n```shell\ngo get github.com/rjNemo/underscore@0.4.0\n```\n\nPlease check out the [examples](examples) to see how to use the library.\n\n```go\npackage main\n\nimport (\n \"fmt\"\n u \"github.com/rjNemo/underscore\"\n)\n\nfunc main() {\n numbers := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}\n // filter even numbers from the slice\n evens := u.Filter(numbers, func(n int) bool { return n%2 == 0 })\n // square every number in the slice\n squares := u.Map(evens, func(n int) int { return n * n })\n // reduce to the sum\n res := u.Reduce(squares, func(n, acc int) int { return n + acc }, 0)\n\n fmt.Println(res) // 120\n}\n```\n\n## Getting Started\n\nThese instructions will get you a copy of the project up and running on your local\nmachine for development and testing purposes.\n\n### Prerequisites\n\nYou need at least `go1.18` for development. The project is shipped with a [Dockerfile](Dockerfile)\nbased on `go1.18`.\n\nIf you prefer local development, navigate to the [official\ndownload page](https://go.dev/dl/) and install version `1.18` or beyond.\n\n### Installing\n\nFirst clone the repository\n\n```shell\ngit clone https://github.com/rjNemo/underscore.git\n```\n\nInstall dependencies\n\n```shell\ngo mod download\n```\n\nAnd that's it.\n\n## Tests\n\nTo run the unit tests, you can simply run:\n\n```shell\nmake test\n```\n\n## Functions\n\n`underscore` provides many of functions that support your favorite functional helpers\n\n### Collections\n\n- `All`\n- `Any`\n- `Contains` (only numerics values at the moment)\n- `Each`\n- `Filter`\n- `Flatmap`\n- `GroupBy`\n- `Find`\n- `Map`\n- `Max`\n- `Min`\n- `Partition`\n- `Reduce`\n\n### Pipe\n\nCalling `NewPipe` will cause all future method calls to return wrapped values. When\nyou've finished the computation, call `Value` to retrieve the final value.\n\nMethods not returning a slice such as `Reduce`, `All`, `Any`, will break the `Chain`\nand return `Value` instantly.\n\n## Built With\n\n- [Go](https://go.dev/) - Build fast, reliable, and efficient software at scale\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct,\nand the process for submitting pull requests to us.\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see\nthe [tags on this repository](https://github.com/rjNemo/underscore/tags).\n\n## Authors\n\n- **Ruidy** - _Initial work_ - [Ruidy](https://github.com/rjNemo)\n\nSee also the list of [contributors](https://github.com/rjNemo/underscore/contributors)\nwho participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md)\nfile for details\n\n## Acknowledgments\n\nThis project is largely inspired by [Underscore.js](https://underscorejs.org/#)\nlibrary. Check out the original project if you don't already know it.\n","funding_links":["https://github.com/sponsors/rjNemo"],"categories":["Go","方法","Functional"],"sub_categories":["检索及分析资料库","Search and Analytic Databases","Advanced Console UIs"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FrjNemo%2Funderscore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FrjNemo%2Funderscore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FrjNemo%2Funderscore/lists"}