mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +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`.
20 lines
327 B
Markdown
20 lines
327 B
Markdown
---
|
|
title: "ContainsBy"
|
|
date: 2025-09-01T00:00:00-00:00
|
|
---
|
|
|
|
`ContainsBy` returns true if any element satisfies the predicate.
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
u "github.com/rjNemo/underscore"
|
|
)
|
|
|
|
func main() {
|
|
nums := []int{1, 3, 5, 8}
|
|
fmt.Println(u.ContainsBy(nums, func(n int) bool { return n%2 == 0 })) // true
|
|
}
|
|
```
|