Skip to content

Commit

Permalink
rename WithIndex operator to Enumerate
Browse files Browse the repository at this point in the history
  • Loading branch information
b97tsk committed Apr 17, 2024
1 parent 967ba87 commit 08b7512
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ func RightOf[_ Pair[K, V], K, V any]() Operator[Pair[K, V], V] {
)
}

// WithIndex maps each value emitted by the source Observable to a Pair
// containing two elements: the Key field stores the index of each value
// starting from init; the Value field stores the value.
func WithIndex[V any, K constraints.Integer](init K) Operator[V, Pair[K, V]] {
// Enumerate maps each value emitted by the source Observable to a Pair
// where the Key field stores the index of each value starting from init
// and the Value field stores each value.
func Enumerate[V any, K constraints.Integer](init K) Operator[V, Pair[K, V]] {
return NewOperator(
func(source Observable[V]) Observable[Pair[K, V]] {
return func(c Context, o Observer[Pair[K, V]]) {
Expand Down
4 changes: 2 additions & 2 deletions pair_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ func TestWithIndex(t *testing.T) {
NewTestSuite[string](t).Case(
rx.Pipe3(
rx.Just("A", "B", "C"),
rx.WithIndex[string](1),
rx.Enumerate[string](1),
rx.Reduce(make(map[int]string), add),
ToString[map[int]string](),
),
"map[1:A 2:B 3:C]", ErrComplete,
).Case(
rx.Pipe3(
rx.Throw[string](ErrTest),
rx.WithIndex[string](1),
rx.Enumerate[string](1),
rx.Reduce(make(map[int]string), add),
ToString[map[int]string](),
),
Expand Down

0 comments on commit 08b7512

Please sign in to comment.