lodash

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package lodash provides Go adapters for commonly used lodash/lodash-es functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelCase

func CamelCase(s string) string

CamelCase converts a string to camelCase.

func Capitalize

func Capitalize(s string) string

Capitalize capitalizes the first letter.

func Chunk

func Chunk[T any](arr []T, size int) [][]T

Chunk splits a slice into groups of the given size.

func Clamp

func Clamp(n, lower, upper float64) float64

Clamp clamps a number within the inclusive range.

func Compact

func Compact[T comparable](arr []T) []T

Compact removes zero-value elements.

func Debounce

func Debounce(fn func(), waitMs int) func()

Debounce returns a function that delays invoking fn until after wait milliseconds.

func Difference

func Difference[T comparable](a []T, others ...[]T) []T

Difference returns elements in a that are not in others.

func Flatten

func Flatten[T any](arr [][]T) []T

Flatten flattens one level of nesting.

func GroupBy

func GroupBy[T any, K comparable](arr []T, fn func(T) K) map[K][]T

GroupBy groups elements by a key function.

func Intersection

func Intersection[T comparable](arrs ...[]T) []T

Intersection returns elements present in all slices.

func IsEmpty

func IsEmpty(v any) bool

IsEmpty checks if a value is "empty" (nil, zero-length, zero value).

func KebabCase

func KebabCase(s string) string

KebabCase converts a string to kebab-case.

func KeyBy

func KeyBy[T any, K comparable](arr []T, fn func(T) K) map[K]T

KeyBy creates a map keyed by the result of a function.

func Omit

func Omit[V any](obj map[string]V, keys ...string) map[string]V

Omit returns a map without the specified keys.

func Pick

func Pick[V any](obj map[string]V, keys ...string) map[string]V

Pick returns a map with only the specified keys.

func Range

func Range(args ...int) []int

Range generates a sequence of numbers.

func SnakeCase

func SnakeCase(s string) string

SnakeCase converts a string to snake_case.

func SortBy

func SortBy[T any](arr []T, fn func(T) float64) []T

SortBy sorts a slice by a numeric key function.

func Throttle

func Throttle(fn func(), waitMs int) func()

Throttle returns a function that only invokes fn at most once per wait milliseconds.

func Truncate

func Truncate(s string, length int) string

Truncate truncates a string to the given length, adding "..." if truncated.

func Uniq

func Uniq[T comparable](arr []T) []T

Uniq returns unique elements.

func UniqBy

func UniqBy[T any, K comparable](arr []T, fn func(T) K) []T

UniqBy returns unique elements using a key function.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL