export ledger.Likes.Any, .All

This commit is contained in:
Bel LaPointe
2023-10-25 07:54:34 -06:00
parent 68fba6b746
commit 9e613f3a1b
4 changed files with 18 additions and 13 deletions

View File

@@ -6,7 +6,7 @@ import (
type Like func(Delta) bool
type likes []Like
type Likes []Like
func LikeBefore(date string) Like {
return func(d Delta) bool {
@@ -30,7 +30,16 @@ func like(pattern string, other string) bool {
return regexp.MustCompile(pattern).MatchString(other)
}
func (likes likes) all(delta Delta) bool {
func (likes Likes) Any(delta Delta) bool {
for i := range likes {
if likes[i](delta) {
return true
}
}
return false
}
func (likes Likes) All(delta Delta) bool {
for i := range likes {
if !likes[i](delta) {
return false