status-go/vendor/github.com/anacrolix/missinggo/v2/iter/head.go

17 lines
203 B
Go
Raw Normal View History

2022-03-10 09:44:48 +00:00
package iter
func Head(n int, f Func) Func {
return func(cb Callback) {
if n <= 0 {
return
}
f(func(v interface{}) bool {
n--
if !cb(v) {
return false
}
return n > 0
})
}
}