Skip to content

Commit

Permalink
fix(pkg): changed package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
vkumbhar94 committed Mar 28, 2024
1 parent 64f0c73 commit 382d3e2
Show file tree
Hide file tree
Showing 14 changed files with 560 additions and 570 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ package main

import (
"fmt"
"github.com/vkumbhar94/go-streams"

"github.com/vkumbhar94/go-streams/pkg/streams"
)

func main() {
stream := streams.New(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
filtered := streams.Filter(stream, func(i int) bool {
return i%2 == 0
})
mapped := streams.Map(filtered, func(i int) int {
return i * 2
})
limited := streams.Limit(mapped, 3)

collected := streams.Collect(limited)
fmt.Println(collected)
result := streams.New(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).
Filter(
func(i int) bool {
return i%2 == 0
}).
Map(func(i int) int {
return i * 2
}).
Limit(3).
Collect()
fmt.Println(result)
}

```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22

require (
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f h1:3CW0unweImhOzd5FmYuRsD4Y4oQFKZIjAnKbjV4WIrw=
golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw=
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions map.go → pkg/streams/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func MNew[K comparable, V any](data map[K]V) *Stream[MapEntry[K, V]] {
}
}

func MKeys[K comparable, V any](data map[K]V) *Stream[K] {
func MNewKeys[K comparable, V any](data map[K]V) *Stream[K] {
ch := make(chan K)
return &Stream[K]{
data: ch,
Expand All @@ -53,7 +53,7 @@ func MKeys[K comparable, V any](data map[K]V) *Stream[K] {
}
}

func MValues[K comparable, V any](data map[K]V) *Stream[V] {
func MNewValues[K comparable, V any](data map[K]V) *Stream[V] {
ch := make(chan V)
return &Stream[V]{
data: ch,
Expand Down
8 changes: 4 additions & 4 deletions map_test.go → pkg/streams/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestMStreamSorted(t *testing.T) {
}

func TestMStreamKeys(t *testing.T) {
stream := MKeys(map[string]int64{
stream := MNewKeys(map[string]int64{
"abc": 2,
"xyz": 4,
"ijk": 3,
Expand All @@ -97,7 +97,7 @@ func TestMStreamKeys(t *testing.T) {
}

func TestMStreamValues(t *testing.T) {
stream := MValues(map[string]int64{
stream := MNewValues(map[string]int64{
"abc": 2,
"xyz": 4,
"ijk": 3,
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestMStreamReduceStringKeysToString(t *testing.T) {
}

func TestMStreamSum(t *testing.T) {
stream := MValues(map[string]int64{
stream := MNewValues(map[string]int64{
"abc": 2,
"xyz": 4,
"ijk": 3,
Expand All @@ -171,7 +171,7 @@ func TestMStreamSum(t *testing.T) {
}

func TestMStreamCount(t *testing.T) {
stream := MValues(map[string]int64{
stream := MNewValues(map[string]int64{
"abc": 2,
"xyz": 4,
"ijk": 3,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 382d3e2

Please sign in to comment.