aboutsummaryrefslogtreecommitdiff
path: root/pkg/u
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-12-12 15:05:26 +0100
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-12-12 15:05:26 +0100
commitfa7b51a709413a214fbd5157fe0f32138a889f0d (patch)
tree81fe7ab4e63ffc90d0392a17fadd7a79d893c95b /pkg/u
parent1059bc71871c14b813b0bb27b4601e2c2ac65acd (diff)
downloadcerrado-e25638d698b96ed9e46bcfbd58ce6ce1f439474a.tar.gz
cerrado-e25638d698b96ed9e46bcfbd58ce6ce1f439474a.tar.bz2
cerrado-e25638d698b96ed9e46bcfbd58ce6ce1f439474a.zip
feat: Filter private repository from the UIv0.0.17
Now the whole application takes public into account.
Diffstat (limited to 'pkg/u')
-rw-r--r--pkg/u/list.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/pkg/u/list.go b/pkg/u/list.go
index 39d7b11..835ecd2 100644
--- a/pkg/u/list.go
+++ b/pkg/u/list.go
@@ -1,5 +1,17 @@
package u
+func Filter[T any](v []T, f func(T) bool) []T {
+ var result []T
+
+ for _, s := range v {
+ if f(s) {
+ result = append(result, s)
+ }
+ }
+
+ return result
+}
+
func First[T any](v []T) (T, bool) {
if len(v) == 0 {
var zero T
@@ -25,7 +37,7 @@ func LastOrZero[T any](v []T) T {
}
func ChunkBy[T any](items []T, chunkSize int) [][]T {
- var chunks = make([][]T, 0, (len(items)/chunkSize)+1)
+ chunks := make([][]T, 0, (len(items)/chunkSize)+1)
for chunkSize < len(items) {
items, chunks = items[chunkSize:], append(chunks, items[0:chunkSize:chunkSize])
}