summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-03-19 12:26:30 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-24 20:14:41 +1100
commitc7a629c4401ae0d4aad06767c88ce1e9e418dbf3 (patch)
tree2ff5599041030a423e02214989f07129772337c6 /vendor
parentdde30fa104347ab9c01f82b7886864b473e6f51c (diff)
make more use of generics
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/jesseduffield/generics/LICENSE21
-rw-r--r--vendor/github.com/jesseduffield/generics/hashmap/functions.go35
-rw-r--r--vendor/github.com/jesseduffield/generics/list/comparable_list.go49
-rw-r--r--vendor/github.com/jesseduffield/generics/list/functions.go72
-rw-r--r--vendor/github.com/jesseduffield/generics/list/list.go117
-rw-r--r--vendor/github.com/jesseduffield/generics/set/set.go49
-rw-r--r--vendor/github.com/samber/lo/.gitignore36
-rw-r--r--vendor/github.com/samber/lo/CHANGELOG.md71
-rw-r--r--vendor/github.com/samber/lo/Dockerfile8
-rw-r--r--vendor/github.com/samber/lo/LICENSE21
-rw-r--r--vendor/github.com/samber/lo/Makefile51
-rw-r--r--vendor/github.com/samber/lo/README.md981
-rw-r--r--vendor/github.com/samber/lo/condition.go99
-rw-r--r--vendor/github.com/samber/lo/constraints.go6
-rw-r--r--vendor/github.com/samber/lo/docker-compose.yml9
-rw-r--r--vendor/github.com/samber/lo/drop.go65
-rw-r--r--vendor/github.com/samber/lo/find.go157
-rw-r--r--vendor/github.com/samber/lo/intersect.go131
-rw-r--r--vendor/github.com/samber/lo/map.go72
-rw-r--r--vendor/github.com/samber/lo/pointers.go19
-rw-r--r--vendor/github.com/samber/lo/retry.go19
-rw-r--r--vendor/github.com/samber/lo/slice.go242
-rw-r--r--vendor/github.com/samber/lo/tuples.go413
-rw-r--r--vendor/github.com/samber/lo/types.go83
-rw-r--r--vendor/github.com/samber/lo/util.go50
-rw-r--r--vendor/modules.txt8
26 files changed, 2884 insertions, 0 deletions
diff --git a/vendor/github.com/jesseduffield/generics/LICENSE b/vendor/github.com/jesseduffield/generics/LICENSE
new file mode 100644
index 000000000..2a7175dcc
--- /dev/null
+++ b/vendor/github.com/jesseduffield/generics/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2022 Jesse Duffield
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/jesseduffield/generics/hashmap/functions.go b/vendor/github.com/jesseduffield/generics/hashmap/functions.go
new file mode 100644
index 000000000..526222b1f
--- /dev/null
+++ b/vendor/github.com/jesseduffield/generics/hashmap/functions.go
@@ -0,0 +1,35 @@
+package hashmap
+
+func Keys[Key comparable, Value any](m map[Key]Value) []Key {
+ keys := make([]Key, 0, len(m))
+ for key := range m {
+ keys = append(keys, key)
+ }
+ return keys
+}
+
+func Values[Key comparable, Value any](m map[Key]Value) []Value {
+ values := make([]Value, 0, len(m))
+ for _, value := range m {
+ values = append(values, value)
+ }
+ return values
+}
+
+func TransformValues[Key comparable, Value any, NewValue any](
+ m map[Key]Value, fn func(Value) NewValue,
+) map[Key]NewValue {
+ output := make(map[Key]NewValue)
+ for key, value := range m {
+ output[key] = fn(value)
+ }
+ return output
+}
+
+func TransformKeys[Key comparable, Value any, NewKey comparable](m map[Key]Value, fn func(Key) NewKey) map[NewKey]Value {
+ output := make(map[NewKey]Value)
+ for key, value := range m {
+ output[fn(key)] = value
+ }
+ return output
+}
diff --git a/vendor/github.com/jesseduffield/generics/list/comparable_list.go b/vendor/github.com/jesseduffield/generics/list/comparable_list.go
new file mode 100644
index 000000000..21d56a80b
--- /dev/null
+++ b/vendor/github.com/jesseduffield/generics/list/comparable_list.go
@@ -0,0 +1,49 @@
+package list
+
+import (
+ "golang.org/x/exp/slices"
+)
+
+type ComparableList[T comparable] struct {
+ *List[T]
+}
+
+func NewComparable[T comparable]() *ComparableList[T] {
+ return &ComparableList[T]{List: New[T]()}
+}
+
+func NewComparableFromSlice[T comparable](slice []T) *ComparableList[T] {
+ return &ComparableList[T]{List: NewFromSlice(slice)}
+}
+
+func (l *ComparableList[T]) Equal(other *ComparableList[T]) bool {
+ return l.EqualSlice(other.ToSlice())
+}
+
+func (l *ComparableList[T]) EqualSlice(other []T) bool {
+ return slices.Equal(l.ToSlice(), other)
+}
+
+func (l *ComparableList[T]) Compact() {
+ l.slice = slices.Compact(l.slice)
+}
+
+func (l *ComparableList[T]) Index(needle T) int {
+ return slices.Index(l.slice, needle)
+}
+
+func (l *ComparableList[T]) Contains(needle T) bool {
+ return slices.Contains(l.slice, needle)
+}
+
+func (l *ComparableList[T]) SortFuncInPlace(test func(a T, b T) bool) {
+ slices.SortFunc(l.slice, test)
+}
+
+func (l *ComparableList[T]) SortFunc(test func(a T, b T) bool) *ComparableList[T] {
+ newSlice := slices.Clone(l.slice)
+
+ slices.SortFunc(newSlice, test)
+
+ return NewComparableFromSlice(newSlice)
+}
diff --git a/vendor/github.com/jesseduffield/generics/list/functions.go b/vendor/github.com/jesseduffield/generics/list/functions.go
new file mode 100644
index 000000000..21578b82f
--- /dev/null
+++ b/vendor/github.com/jesseduffield/generics/list/functions.go
@@ -0,0 +1,72 @@
+package list
+
+func Some[T any](slice []T, test func(T) bool) bool {
+ for _, value := range slice {
+ if test(value) {
+ return true
+ }
+ }
+
+ return false
+}
+
+func Every[T any](slice []T, test func(T) bool) bool {
+ for _, value := range slice {
+ if !test(value) {
+ return false
+ }
+ }
+
+ return true
+}
+
+func Map[T any, V any](slice []T, f func(T) V) []V {
+ result := make([]V, len(slice))
+ for i, value := range slice {
+ result[i] = f(value)
+ }
+
+ return result
+}
+
+func MapInPlace[T any](slice []T, f func(T) T) {
+ for i, value := range slice {
+ slice[i] = f(value)
+ }
+}
+
+func Filter[T any](slice []T, test func(T) bool) []T {
+ result := make([]T, 0)
+ for _, element := range slice {
+ if test(element) {
+ result = append(result, element)
+ }
+ }
+ return result
+}
+
+func FilterInPlace[T any](slice []T, test func(T) bool) []T {
+ newLength := 0
+ for _, element := range slice {
+ if test(element) {
+ slice[newLength] = element
+ newLength++
+ }
+ }
+
+ return slice[:newLength]
+}
+
+func Reverse[T any](slice []T) []T {
+ result := make([]T, len(slice))
+ for i := range slice {
+ result[i] = slice[len(slice)-1-i]
+ }
+ return result
+}
+
+func ReverseInPlace[T any](slice []T) {
+ for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
+ slice[i], slice[j] = slice[j], slice[i]
+ }
+}
diff --git a/vendor/github.com/jesseduffield/generics/list/list.go b/vendor/github.com/jesseduffield/generics/list/list.go
new file mode 100644
index 000000000..2b0f43010
--- /dev/null
+++ b/vendor/github.com/jesseduffield/generics/list/list.go
@@ -0,0 +1,117 @@
+package list
+
+import (
+ "golang.org/x/exp/slices"
+)
+
+type List[T any] struct {
+ slice []T
+}
+
+func New[T any]() *List[T] {
+ return &List[T]{}
+}
+
+func NewFromSlice[T any](slice []T) *List[T] {
+ return &List[T]{slice: slice}
+}
+
+func (l *List[T]) ToSlice() []T {
+ return l.slice
+}
+
+// Mutative methods
+
+func (l *List[T]) Push(v T) {
+ l.slice = append(l.slice, v)
+}
+
+func (l *List[T]) Pop() {
+ l.slice = l.slice[0 : len(l.slice)-1]
+}
+
+func (l *List[T]) Insert(index int, values ...T) {
+ l.slice = slices.Insert(l.slice, index, values...)
+}
+
+func (l *List[T]) Append(values ...T) {
+ l.slice = append(l.slice, values...)
+}
+
+func (l *List[T]) Prepend(values ...T) {
+ l.slice = append(values, l.slice...)
+}
+
+func (l *List[T]) Remove(index int) {
+ l.Delete(index, index+1)
+}
+
+func (l *List[T]) Delete(from int, to int) {
+ l.slice = slices.Delete(l.slice, from, to)
+}
+
+func (l *List[T]) FilterInPlace(test func(value T) bool) {
+ l.slice = FilterInPlace(l.slice, test)
+}
+
+func (l *List[T]) MapInPlace(f func(value T) T) {
+ MapInPlace(l.slice, f)
+}
+
+func (l *List[T]) ReverseInPlace() {
+ ReverseInPlace(l.slice)
+}
+
+// Non-mutative methods
+
+// Similar to Append but we leave the original slice untouched and return a new list
+func (l *List[T]) Concat(values ...T) *List[T] {
+ newSlice := make([]T, 0, len(l.slice)+len(values))
+ newSlice = append(newSlice, l.slice...)
+ newSlice = append(newSlice, values...)
+ return &List[T]{slice: newSlice}
+}
+
+func (l *List[T]) Filter(test func(value T) bool) *List[T] {
+ return NewFromSlice(Filter(l.slice, test))
+}
+
+// Unfortunately this does not support mapping from one type to another
+// because Go does not yet (and may never) support methods defining their own
+// type parameters. For that functionality you'll need to use the standalone
+// Map function instead
+func (l *List[T]) Map(f func(value T) T) *List[T] {
+ return NewFromSlice(Map(l.slice, f))
+}
+
+func (l *List[T]) Clone() *List[T] {
+ return NewFromSlice(slices.Clone(l.slice))
+}
+
+func (l *List[T]) Some(test func(value T) bool) bool {
+ return Some(l.slice, test)
+}
+
+func (l *List[T]) Every(test func(value T) bool) bool {
+ return Every(l.slice, test)
+}
+
+func (l *List[T]) IndexFunc(f func(T) bool) int {
+ return slices.IndexFunc(l.slice, f)
+}
+
+func (l *List[T]) ContainsFunc(f func(T) bool) bool {
+ return l.IndexFunc(f) != -1
+}
+
+func (l *List[T]) Reverse() *List[T] {
+ return NewFromSlice(Reverse(l.slice))
+}
+
+func (l *List[T]) IsEmpty() bool {
+ return len(l.slice) == 0
+}
+
+func (l *List[T]) Len() int {
+ return len(l.slice)
+}
diff --git a/vendor/github.com/jesseduffield/generics/set/set.go b/vendor/github.com/jesseduffield/generics/set/set.go
new file mode 100644
index 000000000..3e9b9d9bf
--- /dev/null
+++ b/vendor/github.com/jesseduffield/generics/set/set.go
@@ -0,0 +1,49 @@
+package set
+
+import "github.com/jesseduffield/generics/hashmap"
+
+type Set[T comparable] struct {
+ hashMap map[T]bool
+}
+
+func New[T comparable]() *Set[T] {
+ return &Set[T]{hashMap: make(map[T]bool)}
+}
+
+func NewFromSlice[T comparable](slice []T) *Set[T] {
+ hashMap := make(map[T]bool)
+ for _, value := range slice {
+ hashMap[value] = true
+ }
+
+ return &Set[T]{hashMap: hashMap}
+}
+
+func (s *Set[T]) Add(value T) {
+ s.hashMap[value] = true
+}
+
+func (s *Set[T]) AddSlice(slice []T) {
+ for _, value := range slice {
+ s.Add(value)
+ }
+}
+
+func (s *Set[T]) Remove(value T) {
+ delete(s.hashMap, value)
+}
+
+func (s *Set[T]) RemoveSlice(slice []T) {
+ for _, value := range slice {
+ s.Remove(value)
+ }
+}
+
+func (s *Set[T]) Includes(value T) bool {
+ return s.hashMap[value]
+}
+
+// output slice is not necessarily in the same order that items were added
+func (s *Set[T]) ToSlice() []T {
+ return hashmap.Keys(s.hashMap)
+}
diff --git a/vendor/github.com/samber/lo/.gitignore b/vendor/github.com/samber/lo/.gitignore
new file mode 100644
index 000000000..3aa3a0ad4
--- /dev/null
+++ b/vendor/github.com/samber/lo/.gitignore
@@ -0,0 +1,36 @@
+
+# Created by https://www.toptal.com/developers/gitignore/api/go
+# Edit at https://www.toptal.com/developers/gitignore?templates=go
+
+### Go ###
+# If you prefer the allow list template instead of the deny list, see community template:
+# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
+#
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+
+# Test binary, built with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Dependency directories (remove the comment below to include it)
+# vendor/
+
+# Go workspace file
+go.work
+
+### Go Patch ###
+/vendor/
+/Godeps/
+
+# End of https://www.toptal.com/developers/gitignore/api/go
+
+cover.out
+cover.html
+.vscode
diff --git a/vendor/github.com/samber/lo/CHANGELOG.md b/vendor/github.com/samber/lo/CHANGELOG.md
new file mode 100644
index 000000000..aabeed120
--- /dev/null
+++ b/vendor/github.com/samber/lo/CHANGELOG.md
@@ -0,0 +1,71 @@
+# Changelog
+
+## 1.3.0 (2022-03-03)
+
+Last and Nth return errors
+
+## 1.2.0 (2022-03-03)
+
+Adding `lop.Map` and `lop.ForEach`.
+
+## 1.1.0 (2022-03-03)
+
+Adding `i int` param to `lo.Map()`, `lo.Filter()`, `lo.ForEach()` and `lo.Reduce()` predicates.
+
+## 1.0.0 (2022-03-02)
+
+*Initial release*
+
+Supported helpers for slices:
+
+- Filter
+- Map
+- Reduce
+- ForEach
+- Uniq
+- UniqBy
+- GroupBy
+- Chunk
+- Flatten
+- Shuffle
+- Reverse
+- Fill
+- ToMap
+
+Supported helpers for maps:
+
+- Keys
+- Values
+- Entries
+- FromEntries
+- Assign (maps merge)
+
+Supported intersection helpers:
+
+- Contains
+- Every
+- Some
+- Intersect
+- Difference
+
+Supported search helpers:
+
+- IndexOf
+- LastIndexOf
+- Find
+- Min
+- Max
+- Last
+- Nth
+
+Other functional programming helpers:
+
+- Ternary (1 line if/else statement)
+- If / ElseIf / Else
+- Switch / Case / Default
+- ToPtr
+- ToSlicePtr
+
+Constraints:
+
+- Clonable
diff --git a/vendor/github.com/samber/lo/Dockerfile b/vendor/github.com/samber/lo/Dockerfile
new file mode 100644
index 000000000..9f9f87192
--- /dev/null
+++ b/vendor/github.com/samber/lo/Dockerfile
@@ -0,0 +1,8 @@
+
+FROM golang:1.18rc1-bullseye
+
+WORKDIR /go/src/github.com/samber/lo
+
+COPY Makefile go.* /go/src/github.com/samber/lo/
+
+RUN make tools
diff --git a/vendor/github.com/samber/lo/LICENSE b/vendor/github.com/samber/lo/LICENSE
new file mode 100644
index 000000000..c3dc72d9a
--- /dev/null
+++ b/vendor/github.com/samber/lo/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2022 Samuel Berthe
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/samber/lo/Makefile b/vendor/github.com/samber/lo/Makefile
new file mode 100644
index 000000000..11b09cd25
--- /dev/null
+++ b/vendor/github.com/samber/lo/Makefile
@@ -0,0 +1,51 @@
+
+BIN=go
+# BIN=go1.18beta1
+
+go1.18beta1:
+ go install golang.org/dl/go1.18beta1@latest
+ go1.18beta1 download
+
+build:
+ ${BIN} build -v ./...
+
+test:
+ go test -race -v ./...
+watch-test:
+ reflex -R assets.go -t 50ms -s -- sh -c 'gotest -race -v ./...'
+
+bench:
+ go test -benchmem -count 3 -bench ./...
+watch-bench:
+ reflex -R assets.go -t 50ms -s -- sh -c 'go test -benchmem -count 3 -bench ./...'
+
+coverage:
+ ${BIN} test -v -coverprofile cover.out .
+ ${BIN} tool cover -html=cover.out -o cover.html
+
+# tools
+tools:
+ ${BIN} install github.com/cespare/reflex@latest
+ ${BIN} install github.com/rakyll/gotest@latest
+ ${BIN} install github.com/psampaz/go-mod-outdated@latest
+ ${BIN} install github.com/jondot/goweight@latest
+ ${BIN} install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
+ ${BIN} get -t -u golang.org/x/tools/cmd/cover
+ ${BIN} get -t -u github.com/sonatype-nexus-community/nancy@latest
+ go mod tidy
+
+lint:
+ golangci-lint run --timeout 60s --max-same-issues 50 ./...
+lint-fix:
+ golangci-lint run --timeout 60s --max-same-issues 50 --fix ./...
+
+audit: tools
+ ${BIN} mod tidy
+ ${BIN} list -json -m all | nancy sleuth
+
+outdated: tools
+ ${BIN} mod tidy
+ ${BIN} list -u -m -json all | go-mod-outdated -update -direct
+
+weight: tools
+ goweight
diff --git a/vendor/github.com/samber/lo/README.md b/vendor/github.com/samber/lo/README.md
new file mode 100644
index 000000000..48dfdc004
--- /dev/null
+++ b/vendor/github.com/samber/lo/README.md
@@ -0,0 +1,981 @@
+# lo
+
+![Build Status](https://github.com/samber/lo/actions/workflows/go.yml/badge.svg)
+[![GoDoc](https://godoc.org/github.com/samber/lo?status.svg)](https://pkg.go.dev/github.com/samber/lo)
+[![Go report](https://goreportcard.com/badge/github.com/samber/lo)](https://goreportcard.com/report/github.com/samber/lo)
+
+✨ **`lo` is a Lodash-style Go library based on Go 1.18+ Generics.**
+
+This project started as an experiment with the new generics implementation. It may look like [Lodash](https://github.com/lodash/lodash) in some aspects. I used to code with the fantastic ["go-funk"](https://github.com/thoas/go-funk) package, but "go-funk" uses reflection and therefore is not typesafe.
+
+As expected, benchmarks demonstrate that generics will be much faster than implementations based on the "reflect" package. Benchmarks also show similar performance gains compared to pure `for` loops. [See below](#-benchmark).
+
+In the future, 5 to 10 helpers will overlap with those coming into the Go standard library (under package names `slices` and `maps`). I feel this library is legitimate and offers many more valuable abstractions.
+
+### Why this name?
+
+I wanted a **short name**, similar to "Lodash" and no Go package currently uses this name.
+
+## 🚀 Install
+
+```sh
+go get github.com/samber/lo
+```
+
+## 💡 Usage
+
+You can import `lo` using:
+
+```go
+import (
+ "github.com/samber/lo"
+ lop "github.com/samber/lo/parallel"
+)
+```
+
+Then use one of the helpers below:
+
+```go
+names := lo.Uniq[string]([]string{"Samuel", "Marc", "Samuel"})
+// []string{"Samuel", "Marc"}
+```
+
+Most of the time, the compiler will be able to infer the type so that you can call: `lo.Uniq([]string{...})`.
+
+## 🤠 Spec
+
+GoDoc: [https://godoc.org/github.com/samber/lo](https://godoc.org/github.com/samber/lo)
+
+Supported helpers for slices:
+
+- Filter
+- Map
+- FlatMap
+- Reduce
+- ForEach
+- Times
+- Uniq
+- UniqBy
+- GroupBy
+- Chunk
+- PartitionBy
+- Flatten
+- Shuffle
+- Reverse
+- Fill
+- Repeat
+- KeyBy
+- Drop
+- DropRight
+- DropWhile
+- DropRightWhile
+
+Supported helpers for maps:
+
+- Keys
+- Values
+- Entries
+- FromEntries
+- Assign (merge of maps)
+- MapValues
+
+Supported helpers for tuples:
+
+- Zip2 -> Zip9
+- Unzip2 -> Unzip9
+
+Supported intersection helpers:
+
+- Contains
+- ContainsBy
+- Every
+- Some
+- Intersect
+- Difference
+- Union
+
+Supported search helpers:
+
+- IndexOf
+- LastIndexOf
+- Find
+- Min
+- Max
+- Last
+- Nth
+- Sample
+- Samples
+
+Other functional programming helpers:
+
+- Ternary (1 line if/else statement)
+- If / ElseIf / Else
+- Switch / Case / Default
+- ToPtr
+- ToSlicePtr
+- Attempt
+- Range / RangeFrom / RangeWithSteps
+
+Constraints:
+
+- Clonable
+
+### Map
+
+Manipulates a slice of one type and transforms it into a slice of another type:
+
+```go
+import "github.com/samber/lo"
+
+lo.Map[int64, string]([]int64{1, 2, 3, 4}, func(x int64, _ int) string {
+ return strconv.FormatInt(x, 10)
+})
+// []string{"1", "2", "3", "4"}
+```
+
+Parallel processing: like `lo.Map()`, but the mapper function is called in a goroutine. Results are returned in the same order.
+
+```go
+import lop "github.com/samber/lo/parallel"
+
+lop.Map[int64, string]([]int64{1, 2, 3, 4}, func(x int64, _ int) string {
+ return strconv.FormatInt(x, 10)
+})
+// []string{"1", "2", "3", "4"}
+```
+
+### FlatMap
+
+Manipulates a slice and transforms and flattens it to a slice of another type.
+
+```go
+lo.FlatMap[int, string]([]int{0, 1, 2}, func(x int, _ int) []string {
+ return []string{
+ strconv.FormatInt(x, 10),
+ strconv.FormatInt(x, 10),
+ }
+})
+// []string{"0", "0", "1", "1", "2", "2"}
+```
+
+### Filter
+
+Iterates over a collection and returns an array of all the elements the predicate function returns `true` for.
+
+```go
+even := lo.Filter[int]([]int{1, 2, 3, 4}, func(x int, _ int) bool {
+ return x%2 == 0
+})
+// []int{2, 4}
+```
+
+### Contains
+
+Returns true if an element is present in a collection.
+
+```go
+present := lo.Contains[int]([]int{0, 1, 2, 3, 4, 5}, 5)
+// true
+```
+
+### Contains
+
+Returns true if the predicate function returns `true`.
+
+```go
+present := lo.ContainsBy[int]([]int{0, 1, 2, 3, 4, 5}, func(x int) bool {
+ return x == 3
+})
+// true
+```
+
+### Reduce
+
+Reduces a collection to a single value. The value is calculated by accumulating the result of running each element in the collection through an accumulator function. Each successive invocation is supplied with the return value returned by the previous call.
+
+```go
+sum := lo.Reduce[int, int]([]int{1, 2, 3, 4}, func(agg int, item int, _ int) int {
+ return agg + item
+}, 0)
+// 10
+```
+
+### ForEach
+
+Iterates over elements of a collection and invokes the function over each element.
+
+```go
+import "github.com/samber/lo"
+
+lo.ForEach[string]([]string{"hello", "world"}, func(x string, _ int) {
+ println(x)
+})
+// prints "hello\nworld\n"
+```
+
+Parallel processing: like `lo.ForEach()`, but the callback is called as a goroutine.
+
+```go
+import lop "github.com/samber/lo/parallel"
+
+lop.ForEach[string]([]string{"hello", "world"}, func(x string, _ int) {
+ println(x)
+})
+// prints "hello\nworld\n" or "world\nhello\n"
+```
+
+### Times
+
+Times invokes the iteratee n times, returning an array of the results of each invocation. The iteratee is invoked with index as argument.
+
+```go
+import "github.com/samber/lo"
+
+lo.Times[string](3, func(i int) string {
+ return strconv.FormatInt(int64(i), 10)
+})
+// []string{"0", "1", "2"}
+```
+
+Parallel processing: like `lo.Times()`, but callback is called in goroutine.
+
+```go
+import lop "github.com/samber/lo/parallel"
+
+lop.Times[string](3, func(i int) string {
+ return strconv.FormatInt(int64(i), 10)
+})
+// []string{"0", "1", "2"}
+```
+
+### Uniq
+
+Returns a duplicate-free version of an array, in which only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the array.
+
+```go
+uniqValues := lo.Uniq[int]([]int{1, 2, 2, 1})
+// []int{1, 2}
+```
+
+### UniqBy
+
+Returns a duplicate-free version of an array, in which only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the array. It accepts `iteratee` which is invoked for each element in array to generate the criterion by which uniqueness is computed.
+
+```go
+uniqValues := lo.UniqBy[int, int]([]int{0, 1, 2, 3, 4, 5}, func(i int) int {
+ return i%3
+})
+// []int{0, 1, 2}
+```
+
+### GroupBy
+
+Returns an object composed of keys generated from the results of running each element of collection through iteratee.
+
+```go
+import lo "github.com/samber/lo"
+
+groups := lo.GroupBy[int, int]([]int{0, 1, 2, 3, 4, 5}, func(i int) int {
+ return i%3
+})
+// map[int][]int{0: []int{0, 3}, 1: []int{1, 4}, 2: []int{2, 5}}
+```
+
+Parallel processing: like `lo.GroupBy()`, but callback is called in goroutine.
+
+```go
+import lop "github.com/samber/lo/parallel"
+
+lop.GroupBy[int, int]([]int{0, 1, 2, 3, 4, 5}, func(i int) int {
+ retu