underscore/docs/content/collections/map.md
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

372 B

title date
Map 2022-03-21T13:32:10-04:00

Map produces a new slice of values by mapping each value in the slice through a transform function.

package main

import (
 "fmt"
 u "github.com/rjNemo/underscore"
)

func main() {
 nums := []int{1, 2, 3}
 toSquare := func(n int) int {
  return n * n
 }
 fmt.Println(u.Map(nums, toSquare)) // {1, 4, 9}
}