mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 10:36:43 +00:00
- 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`.
13 lines
392 B
Go
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)
|
|
}
|