iterator_options.gno
0.57 Kb · 20 lines
1package commondao
2
3// IteratorOption configures iterators.
4type IteratorOption func(*Iterator)
5
6// WithOffset assigns a initial offset to start iterating DAOs.
7// Offset can be used to reduce the number of iterated DAOs for example during pagination.
8func WithOffset(offset uint) IteratorOption {
9 return func(it *Iterator) {
10 it.current = int(offset)
11 }
12}
13
14// WithCount assigns a number to limit the number of iterated DAOs.
15// A zero count means to iterates until the last DAO.
16func WithCount(count uint) IteratorOption {
17 return func(it *Iterator) {
18 it.count = int(count)
19 }
20}