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`.
19 lines
424 B
Go
19 lines
424 B
Go
package maps
|
|
|
|
// Keys returns the keys of the provided map in unspecified order.
|
|
func Keys[K comparable, V any](m map[K]V) []K {
|
|
ks := make([]K, 0, len(m))
|
|
for k := range m {
|
|
ks = append(ks, k)
|
|
}
|
|
return ks
|
|
}
|
|
|
|
// Values returns the values of the provided map in unspecified order.
|
|
func Values[K comparable, V any](m map[K]V) []V {
|
|
vs := make([]V, 0, len(m))
|
|
for _, v := range m {
|
|
vs = append(vs, v)
|
|
}
|
|
return vs
|
|
}
|