Skip to content

Commit

Permalink
fixup! #96 Add lint github action
Browse files Browse the repository at this point in the history
  • Loading branch information
meian committed Sep 8, 2022
1 parent 35472f7 commit dc11c51
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 46 deletions.
1 change: 1 addition & 0 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func testBeforeAndAfter[T any](t *testing.T, itb gcf.Iterable[T]) {
//
// - emptyIterable chaining
// - test any func chaining result from emptyIterable is emptyIterable or not.
//
// - no panic from empty
// - test that panic does not occurred when any func chaining from empty elements that are not emptyIterable.
func testEmpties(t *testing.T, f func(itb gcf.Iterable[int]) gcf.Iterable[int]) {
Expand Down
6 changes: 3 additions & 3 deletions concat.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ type concatIterator[T any] struct {

// Concat makes Iterable elements concatenated of itb1 and itb2.
//
// itb1 := gcf.FromSlice([]int{1, 2, 3})
// itb2 := gcf.FromSlice([]int{4, 5, 6})
// itbc := gcf.Concat(itb1, itb2)
// itb1 := gcf.FromSlice([]int{1, 2, 3})
// itb2 := gcf.FromSlice([]int{4, 5, 6})
// itbc := gcf.Concat(itb1, itb2)
func Concat[T any](itb1 Iterable[T], itb2 Iterable[T]) Iterable[T] {
if isEmpty(itb1) && isEmpty(itb2) {
return orEmpty(itb1)
Expand Down
4 changes: 2 additions & 2 deletions distinct.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type distinctIterator[T comparable] struct {
// Distinct makes Iterable contains unique elements.
// Inner elements is restrict by comparable constraint.
//
// itb := gcf.FromSlice([]int{1, 2, 3, 3, 4, 2, 5})
// itb = gcf.Distinct(itb)
// itb := gcf.FromSlice([]int{1, 2, 3, 3, 4, 2, 5})
// itb = gcf.Distinct(itb)
//
// Currently, result order is determined, but on spec, is undefined.
func Distinct[T comparable](itb Iterable[T]) Iterable[T] {
Expand Down
4 changes: 2 additions & 2 deletions filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type filterIterator[T any] struct {

// Filter makes Iterable with elements which filterFunc is true.
//
// itb := gcf.FromSlice([]int{1, 2, 3})
// itb = gcf.Filter(itb, func(v int) bool { return v%2 > 0 })
// itb := gcf.FromSlice([]int{1, 2, 3})
// itb = gcf.Filter(itb, func(v int) bool { return v%2 > 0 })
//
// If filterFunc is nil, returns original Iteratable.
func Filter[T any](itb Iterable[T], filterFunc func(v T) bool) Iterable[T] {
Expand Down
18 changes: 9 additions & 9 deletions map.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type mapIterator[T any, R any] struct {

// Map makes Iterable in elements convert by mapFunc.
//
// itbs := gcf.Func([]string{"a", "ab", "abc"})
// itbi := gcf.Map(itbs, func(v string) int { return len(v) })
// itbs := gcf.Func([]string{"a", "ab", "abc"})
// itbi := gcf.Map(itbs, func(v string) int { return len(v) })
//
// If mapFunc is nil, return Iterable in zero value elements.
func Map[T any, R any](itb Iterable[T], mapFunc func(v T) R) Iterable[R] {
Expand Down Expand Up @@ -65,13 +65,13 @@ type flatMapIterator[T any, R any] struct {

// FlatMap makes Iterable in elements in slice converted by mapFunc.
//
// itbs := gcf.Func([]string{"a", "ab", "abc"})
// itbi := gcf.Map(itbs, func(v string) int[] {
// var r := make([]int, 0)
// for _, c := range []rune(v) {
// r = append(r, int(c))
// }
// })
// itbs := gcf.Func([]string{"a", "ab", "abc"})
// itbi := gcf.Map(itbs, func(v string) int[] {
// var r := make([]int, 0)
// for _, c := range []rune(v) {
// r = append(r, int(c))
// }
// })
//
// If mapFunc is nil, return empty Iterable.
func FlatMap[T any, R any](itb Iterable[T], mapFunc func(v T) []R) Iterable[R] {
Expand Down
8 changes: 4 additions & 4 deletions repeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type repeatIterator[T any] struct {

// Repeat makes Iterable that repeat v a count times.
//
// itb = gcf.Repeat(1, 3)
// itb = gcf.Repeat(1, 3)
//
// If count is 0, returns empty Iterable.
// If count is negative, raises panic.
Expand Down Expand Up @@ -70,9 +70,9 @@ type repeatIterableIterator[T any] struct {

// RepeatIterable makes Iterable that repeat elements in itb a count times.
//
// s := []int{1, 2, 3}
// itb := gcf.FromSlice(s)
// itb = gcf.RepeatIterable(itb, 3)
// s := []int{1, 2, 3}
// itb := gcf.FromSlice(s)
// itb = gcf.RepeatIterable(itb, 3)
//
// If count is 0, returns empty Iterable.
// If count is negative, raises panic.
Expand Down
4 changes: 2 additions & 2 deletions reverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type reverseIterator[T any] struct {

// Reverse makes Iterable with reverse order elements.
//
// itb := gcf.FromSlice([]int{1, 2, 3})
// itb = gcf.Reverse(itb)
// itb := gcf.FromSlice([]int{1, 2, 3})
// itb = gcf.Reverse(itb)
func Reverse[T any](itb Iterable[T]) Iterable[T] {
if isEmpty(itb) {
return orEmpty(itb)
Expand Down
8 changes: 4 additions & 4 deletions skip.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type skipIterator[T any] struct {

// Skip makes Iterable with elements excepting counted elements from ahead.
//
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.Skip(itb, 2)
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.Skip(itb, 2)
//
// If count is 0, returns original Iterable.
// If count is negative, raises panic.
Expand Down Expand Up @@ -72,8 +72,8 @@ type skipWhileIterator[T any] struct {

// SkipWhile makes Iterable with elements excepting elements that whileFunc is true from ahead.
//
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.SkipWhile(itb, func(v int) bool { return v <= 2 })
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.SkipWhile(itb, func(v int) bool { return v <= 2 })
//
// If whileFunc is nil, returns original Iterable.
func SkipWhile[T any](itb Iterable[T], whileFunc func(v T) bool) Iterable[T] {
Expand Down
8 changes: 4 additions & 4 deletions skip_last.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type skipLastIterator[T any] struct {

// SkipLast makes Iterable with elements excepting counted elements from end.
//
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.SkipLast(itb, 2)
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.SkipLast(itb, 2)
//
// If count is 0, returns original Iterable.
// If count is negative, raises panic.
Expand Down Expand Up @@ -86,8 +86,8 @@ type skipLastWhileIterator[T any] struct {

// SkipLastWhile makes Iterable with elements excepting elements that whileFunc is true from end.
//
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.SkipLastWhile(itb, func(v int) bool { return v <= 2 })
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.SkipLastWhile(itb, func(v int) bool { return v <= 2 })
//
// If whileFunc is nil, returns original Iterable.
func SkipLastWhile[T any](itb Iterable[T], whileFunc func(v T) bool) Iterable[T] {
Expand Down
12 changes: 6 additions & 6 deletions slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type sliceIterator[T any] struct {

// FromSlice makes Iterable from slice.
//
// s := []int{1, 2, 3}
// itb := gcf.FromSlice(s)
// s := []int{1, 2, 3}
// itb := gcf.FromSlice(s)
//
// By change elements in base slice afrer this called, change is affected to Iterator.
// If you want no affects by change, you can use FromSliceImmutable.
Expand All @@ -26,8 +26,8 @@ func FromSlice[T any](s []T) Iterable[T] {

// FromSliceImmutable makes Iterable from slice with immutable.
//
// s := []int{1, 2, 3}
// itb := gcf.FromSliceImmutable(s)
// s := []int{1, 2, 3}
// itb := gcf.FromSliceImmutable(s)
//
// Input slice is duplicated to make immutable, so have some performance bottleneck.
func FromSliceImmutable[T any](s []T) Iterable[T] {
Expand Down Expand Up @@ -63,8 +63,8 @@ func (it *sliceIterator[T]) Current() T {

// ToSlice makes slice of elements listed in Iterable.
//
// itb := gcf.FromSlice([]int{1, 2, 3})
// s := gcf.ToSlice(itb)
// itb := gcf.FromSlice([]int{1, 2, 3})
// s := gcf.ToSlice(itb)
func ToSlice[T any](itb Iterable[T]) []T {
// shortcut for emptyIterable
if _, ok := itb.(emptyIterable[T]); ok {
Expand Down
4 changes: 2 additions & 2 deletions slice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestFromSliceImmutable(t *testing.T) {
actual := ""
it := itb.Iterator()
for it.MoveNext() {
actual = actual + it.Current()
actual += it.Current()
}
assert.Equal(tt.want, actual)
})
Expand All @@ -139,7 +139,7 @@ func TestFromSliceImmutable(t *testing.T) {
actual := ""
it := itb.Iterator()
for it.MoveNext() {
actual = actual + it.Current()
actual += it.Current()
}
assert.Empty(t, actual)
})
Expand Down
8 changes: 4 additions & 4 deletions take.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type takeIterator[T any] struct {

// Take makes Iterable with count elements from ahead.
//
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.Take(itb, 2)
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.Take(itb, 2)
//
// If count is 0, returns empty Iterable.
// If count is negative, raises panic.
Expand Down Expand Up @@ -73,8 +73,8 @@ type takeWhileIterator[T any] struct {

// TakeWhile makes Iterable with elements in which whileFunc is true from ahead.
//
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.TakeWhile(itb, func(v int) bool { return v <= 2 })
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.TakeWhile(itb, func(v int) bool { return v <= 2 })
//
// If whileFunc is nil, returns empty Iterable.
func TakeWhile[T any](itb Iterable[T], whileFunc func(v T) bool) Iterable[T] {
Expand Down
8 changes: 4 additions & 4 deletions take_last.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type takeLastIterator[T any] struct {

// TakeLast makes Iterable with count elements from end.
//
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.TakeLast(itb, 2)
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.TakeLast(itb, 2)
//
// If count is 0, returns empty Iterable.
// If count is negative, raises panic.
Expand Down Expand Up @@ -83,8 +83,8 @@ type takeLastWhileIterator[T any] struct {

// TakeLastWhile makes Iterable with elements in which whileFunc is true from end.
//
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.TakeLastWhile(itb, func(v int) bool { return v >= 2 })
// itb := gcf.FromSlice([]{1, 2, 3})
// itb = gcf.TakeLastWhile(itb, func(v int) bool { return v >= 2 })
//
// If whileFunc is nil, returns empty Iterable.
func TakeLastWhile[T any](itb Iterable[T], whileFunc func(v T) bool) Iterable[T] {
Expand Down

0 comments on commit dc11c51

Please sign in to comment.