mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
feat(app/edge-stacks): summarize the edge stack statuses in the backend (#818)
This commit is contained in:
parent
363a62d885
commit
e1c480d3c3
21 changed files with 645 additions and 312 deletions
17
api/slicesx/includes.go
Normal file
17
api/slicesx/includes.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package slicesx
|
||||
|
||||
import "slices"
|
||||
|
||||
// Checks if predicate returns truthy for any element of input. Iteration is stopped once predicate returns truthy.
|
||||
func Some[T any](input []T, predicate func(T) bool) bool {
|
||||
return slices.ContainsFunc(input, predicate)
|
||||
}
|
||||
|
||||
// Checks if predicate returns truthy for all elements of input. Iteration is stopped once predicate returns falsey.
|
||||
//
|
||||
// Note: This method returns true for empty collections because everything is true of elements of empty collections.
|
||||
// https://en.wikipedia.org/wiki/Vacuous_truth
|
||||
func Every[T any](input []T, predicate func(T) bool) bool {
|
||||
// if the slice doesn't contain an inverted predicate then all items follow the predicate
|
||||
return !slices.ContainsFunc(input, func(t T) bool { return !predicate(t) })
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue