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
15
api/slicesx/map.go
Normal file
15
api/slicesx/map.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package slicesx
|
||||
|
||||
// Map applies the given function to each element of the slice and returns a new slice with the results
|
||||
func Map[T, U any](s []T, f func(T) U) []U {
|
||||
result := make([]U, len(s))
|
||||
for i, v := range s {
|
||||
result[i] = f(v)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// FlatMap applies the given function to each element of the slice and returns a new slice with the flattened results
|
||||
func FlatMap[T, U any](s []T, f func(T) []U) []U {
|
||||
return Flatten(Map(s, f))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue