Skip to content

Commit 65b0731

Browse files
authored
Merge pull request #132 from winebarrel/IterFrom_Iter
IterFrom -> Iter
2 parents 0ad24d6 + a06ecfd commit 65b0731

File tree

6 files changed

+26
-8
lines changed

6 files changed

+26
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [2.1.2] - 2025-11-16
4+
5+
### Changed
6+
7+
* [breaking change] Rename `IterFrom()` to `Iter()`. [pull#132](https://github.com/winebarrel/cronplan/pull/132)
8+
39
## [2.1.1] - 2025-11-16
410

511
### Added

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,20 @@ func main() {
7474
)
7575
//=> [2022-11-03 10:00:00 +0000 UTC 2022-11-04 10:00:00 +0000 UTC]
7676

77-
iter := cron.IterFrom(time.Date(2022, 11, 3, 10, 0, 0, 0, time.UTC))
77+
iter := cron.Iter(time.Date(2022, 11, 3, 10, 0, 0, 0, time.UTC))
7878

7979
for i := range 3 {
8080
fmt.Println(i, iter.Next())
8181
//=> 0 2022-11-03 10:00:00 +0000 UTC
8282
//=> 1 2022-11-04 10:00:00 +0000 UTC
8383
//=> 2 2022-11-05 10:00:00 +0000 UTC
8484
}
85+
86+
for next := range iter.Seq() {
87+
fmt.Println(next)
88+
//=> 2022-11-03 10:00:00 +0000 UTC
89+
break
90+
}
8591
}
8692
```
8793

_example/basic/main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,18 @@ func main() {
3939
)
4040
//=> [2022-11-03 10:00:00 +0000 UTC 2022-11-04 10:00:00 +0000 UTC]
4141

42-
iter := cron.IterFrom(time.Date(2022, 11, 3, 10, 0, 0, 0, time.UTC))
42+
iter := cron.Iter(time.Date(2022, 11, 3, 10, 0, 0, 0, time.UTC))
4343

4444
for i := range 3 {
4545
fmt.Println(i, iter.Next())
4646
//=> 0 2022-11-03 10:00:00 +0000 UTC
4747
//=> 1 2022-11-04 10:00:00 +0000 UTC
4848
//=> 2 2022-11-05 10:00:00 +0000 UTC
4949
}
50+
51+
for next := range iter.Seq() {
52+
fmt.Println(next)
53+
//=> 2022-11-03 10:00:00 +0000 UTC
54+
break
55+
}
5056
}

_example/cron/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func cron(expr string, from time.Time, proc func()) (<-chan struct{}, error) {
1717
waiter := make(chan struct{})
1818

1919
go func() {
20-
for next := range cron.IterFrom(from).Seq() {
20+
for next := range cron.Iter(from).Seq() {
2121
<-time.After(time.Until(next))
2222
go proc()
2323
}

iter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (iter *Iterator) Seq() iter.Seq[time.Time] {
3737
}
3838
}
3939

40-
func (v *Expression) IterFrom(from time.Time) *Iterator {
40+
func (v *Expression) Iter(from time.Time) *Iterator {
4141
iter := &Iterator{
4242
expr: v,
4343
from: from,

test/cronplan/iter_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/winebarrel/cronplan/v2"
1010
)
1111

12-
func TestIterFrom(t *testing.T) {
12+
func TestIter(t *testing.T) {
1313
assert := assert.New(t)
1414

1515
tt := []struct {
@@ -207,7 +207,7 @@ func TestIterFrom(t *testing.T) {
207207
for _, test := range tt {
208208
cron, err := cronplan.Parse(test.exp)
209209
assert.NoError(err)
210-
iter := cron.IterFrom(test.from)
210+
iter := cron.Iter(test.from)
211211

212212
for _, e := range test.expected {
213213
next := iter.Next()
@@ -244,7 +244,7 @@ func TestIterHasNext(t *testing.T) {
244244
for _, test := range tt {
245245
cron, err := cronplan.Parse(test.exp)
246246
assert.NoError(err)
247-
iter := cron.IterFrom(test.from)
247+
iter := cron.Iter(test.from)
248248

249249
for _, e := range test.expected {
250250
next := iter.HasNext()
@@ -447,7 +447,7 @@ func TestIterSeq(t *testing.T) {
447447
for _, test := range tt {
448448
cron, err := cronplan.Parse(test.exp)
449449
assert.NoError(err)
450-
iter := cron.IterFrom(test.from)
450+
iter := cron.Iter(test.from)
451451

452452
i := 0
453453

0 commit comments

Comments
 (0)