underscore/contains.go
Ruidy 1031038d42
feat: add Chunk, ContainsBy, UniqueBy, ParallelMap, map helpers
- Add `Chunk` to split slices into groups of size n.
- Add `ContainsBy` for predicate-based containment checks.
- Add `UniqueBy` to deduplicate slices by key selector.
- Add `ParallelMap` for concurrent mapping with context and error
handling.
- Add `maps.Keys` and `maps.Values` helpers for extracting map
keys/values.
- Update README and docs for new features.
- Refactor `Contains` to use `slices.Contains`.
2025-09-01 18:03:38 -04:00

13 lines
392 B
Go

package underscore
import "slices"
// Contains returns true if the value is present in the slice
func Contains[T comparable](values []T, value T) bool {
return slices.Contains(values, value)
}
// ContainsBy returns true if any element in the slice satisfies the predicate.
func ContainsBy[T any](values []T, predicate func(T) bool) bool {
return slices.ContainsFunc(values, predicate)
}