27 lines
419 B
Go
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
|
|
}
|