Files
ana-ledger/ledger/like.go
Bel LaPointe e5bc3b3840 impl all
2023-10-23 10:38:28 -06:00

27 lines
419 B
Go

package ledger
import "regexp"
type Like func(Delta) bool
type likes []Like
func LikeAcc(pattern string) Like {
return func(d Delta) bool {
return like(pattern, d.Account)
}
}
func like(pattern string, other string) bool {
return regexp.MustCompile(pattern).MatchString(other)
}
func (likes likes) all(delta Delta) bool {
for i := range likes {
if !likes[i](delta) {
return false
}
}
return true
}