{"id":38900360,"url":"https://github.com/dev-parvej/js_array_method","last_synced_at":"2026-01-17T15:02:45.424Z","repository":{"id":61629082,"uuid":"552000679","full_name":"dev-parvej/js_array_method","owner":"dev-parvej","description":"Map filter reduce in golang","archived":false,"fork":false,"pushed_at":"2025-07-26T07:47:17.000Z","size":25,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-02T11:42:12.127Z","etag":null,"topics":["every","filter","find","findindex","golang","helper-functions","helpers","map","reduce","slice","some"],"latest_commit_sha":null,"homepage":"","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/dev-parvej.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-15T15:32:40.000Z","updated_at":"2025-08-08T09:56:07.000Z","dependencies_parsed_at":"2023-01-22T21:15:15.406Z","dependency_job_id":null,"html_url":"https://github.com/dev-parvej/js_array_method","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dev-parvej/js_array_method","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-parvej%2Fjs_array_method","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-parvej%2Fjs_array_method/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-parvej%2Fjs_array_method/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-parvej%2Fjs_array_method/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dev-parvej","download_url":"https://codeload.github.com/dev-parvej/js_array_method/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-parvej%2Fjs_array_method/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28510928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["every","filter","find","findindex","golang","helper-functions","helpers","map","reduce","slice","some"],"created_at":"2026-01-17T15:02:45.333Z","updated_at":"2026-01-17T15:02:45.412Z","avatar_url":"https://github.com/dev-parvej.png","language":"Go","readme":"# go-js-array-methods\n\nThis package is to implement javacript array methods which is missing in golang\n\n## Installation\n\n```\ngo get github.com/dev-parvej/js_array_method\n```\n\n## Usage\n\n```\nimport js \"github.com/dev-parvej/js_array_method\"\n\ntype User struct {\n\tId   int\n\tName string\n}\n\ntype Foo struct {\n\tBar string\n}\n\nusers := []User{{Id: 10, Name: \"Go\"}, {Id: 11, Name: \"Lang\"}}\n\n```\n\n### Find\n\n```\nuser, err := js.Find(users, func(user User, index int) bool {\n    return user.Id == 10\n})\n// {Id: 10, Name: \"Go\"}\n\n```\n\n### Filter\n\n```\nfilteredUsers := js.Filter(users, func(user User, index int) bool {\n    return user.Id == 10\n})\n// {{Id: 10, Name: \"Go\"}}\n\n```\n\n### Map\n\n```\njs.Map(users, func(user User, index int) Foo {\n    return Foo{\n        Bar: fmt.Sprintf(\"%d %s\", user.Id, user.Name),\n    }\n})\n// {{Bar: \"10 Go\"}, {Bar: \"11 Lang\"}}\n\n```\n\n### Reduce \n```\nnumbers := []int{10, 11, 12, 13}\njs.Reduce(numbers, func(s int, n int, i int) int {\n    return s + n\n}, 0)\n\n// 46\n```\n\n### Every\n\n```\nusers := []User{{Id: 12, Name: \"Go\"}, {Id: 14, Name: \"Go\"}}\nresultTrue := Every(users, func(user User, _ int) bool {\n    return user.Name == \"Go\"\n})\n// true\n\nEvery([]string{\"hey\", \"hi\"}, \"hi\")\n// false\n```\n\n### Foreach\n```\nvar slices = []string{\"Go\", \"Typescript\", \"Nodejs\"}\n\nForeach(slices, func(ln string, index int) {\n    // ln contains the item of the slice\n    // index contains item index\n})\n```\n\n### Includes\n\n```\nlanguages := []User{{Id: 12, Name: \"Go\"}, {Id: 14, Name: \"Lang\"}, {Id: 15, Name: \"Typescript\"}}\n\nIncludes(languages, func(ln User, _ int) bool { return ln.Name == \"Go\" })\n//true\nIncludes(languages, func(ln User, _ int) bool { return ln.Name == \"MySql\" })\n//false\n\nlanguages := []string{\"go\", \"PHP\", \"MySql\", \"TypeScript\"}\nIncludes(languages, \"TypeScript\").\n//true\n\n```\n### Includes\n\n```\nusers := []User{{Id: 10, Name: \"John\"}, {Id: 11, Name: \"Doe\"}, {Id: 12, Name: \"Sabrina\"}}\nReverse(users)\n// {{Id: 12, Name: \"Sabrina\"}, {Id: 11, Name: \"Doe\"}, {Id: 10, Name: \"John\"}}\n```\n\n### FindIndex\n\n```\nusers := []User{{Id: 10, Name: \"John\"}, {Id: 11, Name: \"Doe\"}, {Id: 12, Name: \"Sabrina\"}}\nFindIndex(users, func(user User, _ int) bool {\n    return user.Name == \"Doe\"\n})\n// 2\n\nusers := []string{\"User1\", \"User2\", \"User3\", \"User4\"}\n\nFindIndex(users, \"User1\")\n//0\nFindIndex(users, \"User5\")\n//-1\n\n```\nIf you find it usefull make sure you star the repo\n\n[Buy me a coffe](https://www.buymeacoffee.com/parvejcode)\n","funding_links":["https://www.buymeacoffee.com/parvejcode"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-parvej%2Fjs_array_method","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev-parvej%2Fjs_array_method","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-parvej%2Fjs_array_method/lists"}