https://github.com/hirokisan/witer
witer is a wrapper around Go's iter package, designed to simplify and extend its functionality for more convenient iteration handling
https://github.com/hirokisan/witer
go golang iterator wrapper
Last synced: 6 months ago
JSON representation
witer is a wrapper around Go's iter package, designed to simplify and extend its functionality for more convenient iteration handling
- Host: GitHub
- URL: https://github.com/hirokisan/witer
- Owner: hirokisan
- License: mit
- Created: 2024-09-26T12:10:04.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-09-27T03:24:47.000Z (9 months ago)
- Last Synced: 2024-12-06T13:29:18.308Z (6 months ago)
- Topics: go, golang, iterator, wrapper
- Language: Go
- Homepage: https://pkg.go.dev/github.com/hirokisan/witer
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://goreportcard.com/report/github.com/hirokisan/witer)
[](https://github.com/hirokisan/witer/actions/workflows/test.yml)# witer
witer is a wrapper around Go's iter package, designed to simplify and extend its functionality for more convenient iteration handling.
## Usage
### Filter
```golang
import "github.com/hirokisan/witer"iter := witer.New(slices.Values([]int64{1, 2, 3}))
items := iter.Filter(func(v int64) bool {
return v%2 == 0
}).Collect()
``````golang
import "github.com/hirokisan/witer"iter := witer.New2(maps.All(map[int64]string{
0: "a",
1: "b",
2: "c",
}))
items := maps.Collect(iter.Filter(func(k int64, v string) bool {
return k%2 == 0 && v == "a"
}).Iter())
```### Apply
```golang
import "github.com/hirokisan/witer"iter := witer.New(slices.Values([]int64{1, 2, 3}))
items := iter.Apply(func(v int64) int64 {
return v * 10
}).Collect()
``````golang
import "github.com/hirokisan/witer"iter := witer.New2(maps.All(map[int64]string{
0: "a",
1: "b",
2: "c",
}))
items := maps.Collect(iter.Apply(func(k int64, v string) (int64, string) {
return k * 10, v
}).Iter())
```