Documentation ¶
Overview ¶
This is lodash golang version. A modern Golang utility library delivering modularity, performance & extras.
Index ¶
- func CamelCase(str string) (string, error)
- func CamelCaseWithInit(str string, upperCase InitCamelCase) (string, error)
- func Capitalize(str string) string
- func CountBy(items DashSlice, iteratee Iteratee) map[interface{}]int
- func EndsWith(str string, target string) bool
- func EndsWithFrom(str string, target string, position int) bool
- func Escape(str string) string
- func EscapeRegExp(str string) string
- func Every(items DashSlice, predicate Predicate) bool
- func Fill(items DashSlice, fillValue interface{})
- func FillInRange(items DashSlice, value interface{}, start int, end int)
- func Find(items DashSlice, predicate Predicate) (interface{}, bool)
- func FindFrom(items DashSlice, predicate Predicate, start int) (interface{}, bool)
- func FindIndex(items DashSlice, predicate Predicate) (int, bool)
- func FindIndexWith(items DashSlice, element interface{}, comparison Comparison) (int, bool)
- func FindLast(items DashSlice, predicate Predicate) (interface{}, bool)
- func FindLastFrom(items DashSlice, predicate Predicate, start int) (interface{}, bool)
- func FindLastIndex(items DashSlice, predicate Predicate) (int, bool)
- func FindLastIndexWith(items DashSlice, element interface{}, comparison Comparison) (int, bool)
- func First(items DashSlice) interface{}
- func FromPairs(pairs []DashSlice) map[interface{}]interface{}
- func GroupBy(items DashSlice, iteratee Iteratee) map[interface{}]DashSlice
- func Head(items DashSlice) interface{}
- func Identity(i interface{}) interface{}
- func IdentityFloat64(i interface{}) float64
- func IdentityInt(i interface{}) int
- func IdentityString(i interface{}) string
- func Includes(items DashSlice, value interface{}) bool
- func IndexOf(items DashSlice, element interface{}) (int, bool)
- func Join(items DashSlice, separator string) string
- func Last(items DashSlice) interface{}
- func LastIndexOf(items DashSlice, element interface{}) (int, bool)
- func LowerFirst(str string) string
- func Nth(items DashSlice, n int) interface{}
- func Pad(str string, length int) string
- func PadLeft(str string, length int) string
- func PadLeftWith(str string, length int, padChars string) string
- func PadRight(str string, length int) string
- func PadRightWith(str string, length int, padChars string) string
- func PadWith(str string, length int, padChars string) string
- func Reduce(items DashSlice, reducer Reducer) interface{}
- func ReduceRight(items DashSlice, reducer Reducer) interface{}
- func ReduceRightWithInitial(items DashSlice, reducer Reducer, initial interface{}) interface{}
- func ReduceWithInitial(items DashSlice, reducer Reducer, initial interface{}) interface{}
- func Repeat(str string, count int) string
- func Replace(source string, target string, newStr string) string
- func ReplaceRegx(source string, pattern string, newStr string) (string, error)
- func Sample(items DashSlice) interface{}
- func Size(items DashSlice) int
- func Some(items DashSlice, predicate Predicate) bool
- func Split(str string, separator string) []string
- func SplitWithCountLimit(str string, separator string, n int) []string
- func StartsWith(str string, target string) bool
- func StartsWithFrom(str string, target string, position int) bool
- func Ternary(satisfy bool, truthyValue interface{}, falsyValue interface{}) interface{}
- func ToLower(str string) string
- func ToUpper(str string) string
- func Trim(str string) string
- func TrimEnd(str string) string
- func TrimEndWith(str string, trimChars string) string
- func TrimStart(str string) string
- func TrimStartWith(str string, trimChars string) string
- func TrimWith(str string, trimChars string) string
- func Unescape(str string) string
- func UpperFirst(str string) string
- type Action
- type Comparison
- type DashSlice
- func Chunk(items DashSlice, size int) []DashSlice
- func Compact(items DashSlice) DashSlice
- func Concat(items DashSlice, newItems ...interface{}) DashSlice
- func ConcatSlices(slices ...DashSlice) DashSlice
- func Difference(items DashSlice, itemsToCompare ...interface{}) DashSlice
- func DifferenceBy(items DashSlice, itemsToCompare DashSlice, iteratee Iteratee) DashSlice
- func DifferenceWith(items DashSlice, itemsToCompare DashSlice, comparison Comparison) DashSlice
- func Drop(items DashSlice, count int) DashSlice
- func DropRight(items DashSlice, count int) DashSlice
- func DropWhile(items DashSlice, predicate Predicate) DashSlice
- func Each(items DashSlice, action Action) DashSlice
- func EachRight(items DashSlice, action Action) DashSlice
- func Filter(items DashSlice, predicate Predicate) DashSlice
- func FlatMap(items DashSlice, iteratee Iteratee) DashSlice
- func FlatMapDeep(items DashSlice, iteratee Iteratee) DashSlice
- func FlatMapDepth(items DashSlice, iteratee Iteratee, depth int) DashSlice
- func Flatten(items DashSlice) DashSlice
- func FlattenDeep(items DashSlice) DashSlice
- func FlattenDepth(items DashSlice, depth int) DashSlice
- func ForEach(items DashSlice, action Action) DashSlice
- func ForEachRight(items DashSlice, action Action) DashSlice
- func Initial(items DashSlice) DashSlice
- func Intersection(items1 DashSlice, items2 DashSlice) DashSlice
- func IntersectionBy(items1 DashSlice, items2 DashSlice, iteratee Iteratee) DashSlice
- func IntersectionWith(items1 DashSlice, items2 DashSlice, comparison Comparison) DashSlice
- func Map(items DashSlice, iteratee Iteratee) DashSlice
- func NewDashSlice(items ...interface{}) DashSlice
- func NewDashSliceFromIntArray(items ...int) DashSlice
- func Pull(items *DashSlice, values ...interface{}) DashSlice
- func PullAll(items *DashSlice, values DashSlice) DashSlice
- func PullAllWith(items *DashSlice, values DashSlice, comparison Comparison) DashSlice
- func PullAt(items *DashSlice, indices ...int) DashSlice
- func Reject(items DashSlice, predicate Predicate) DashSlice
- func Remove(items *DashSlice, predicate Predicate) DashSlice
- func Reverse(items DashSlice) DashSlice
- func SampleSize(items DashSlice, n int) DashSlice
- func Shuffle(items DashSlice) DashSlice
- func Slice(items DashSlice, start int, end int) DashSlice
- func SortByFloat64(items DashSlice, iteratee IterateeToFloat) DashSlice
- func SortByInt(items DashSlice, iteratee IterateeToInt) DashSlice
- func SortByString(items DashSlice, iteratee IterateeToString) DashSlice
- func Tail(items DashSlice) DashSlice
- func Take(items DashSlice, n int) DashSlice
- func TakeRight(items DashSlice, n int) DashSlice
- func TakeRightWhile(items DashSlice, predicate Predicate) DashSlice
- func TakeWhile(items DashSlice, predicate Predicate) DashSlice
- func Union(slices ...DashSlice) DashSlice
- func UnionBy(iteratee Iteratee, slices ...DashSlice) DashSlice
- func UnionWith(comparison Comparison, slices ...DashSlice) DashSlice
- func Uniq(items DashSlice) DashSlice
- func UniqBy(items DashSlice, iteratee Iteratee) DashSlice
- func UniqWith(items DashSlice, comparison Comparison) DashSlice
- func Without(items DashSlice, values ...interface{}) DashSlice
- func Xor(items ...DashSlice) DashSlice
- func Zip(slices ...DashSlice) []DashSlice
- func ZipWith(iteratee func([]interface{}) interface{}, slices ...DashSlice) DashSlice
- type InitCamelCase
- type Iteratee
- type IterateeToFloat
- type IterateeToInt
- type IterateeToString
- type Predicate
- type Reducer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CamelCaseWithInit ¶ added in v1.1.0
func CamelCaseWithInit(str string, upperCase InitCamelCase) (string, error)
Converts string to camel case. First char is lower case by default.
func Capitalize ¶ added in v1.2.0
Converts the first character of string to upper case and the remaining to lower case.
func CountBy ¶
Creates an object composed of keys generated from the results of running each element of collection thru iteratee. The corresponding value of each key is the number of times the key was returned by iteratee. The iteratee is invoked with one argument: (value).
func EndsWithFrom ¶ added in v1.2.0
Checks if string ends with the given target string with the position to search up to.
func Escape ¶ added in v1.2.0
Converts the characters "&", "<", ">", '"', and "'" in string to their corresponding HTML entities.
func EscapeRegExp ¶ added in v1.2.0
Escapes the RegExp special characters "^", "$", "", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in string.
func Every ¶
Checks if predicate returns truthy for all elements of collection. Iteration is stopped once predicate returns falsy. The predicate is invoked with one argument: (value).
func FillInRange ¶
Fills elements of array with value from start up to, but not including end.
func Find ¶
Iterates over elements of collection, returning the first element predicate returns truthy for. The predicate is invoked with one argument: (value).
func FindFrom ¶
Iterates over elements of collection from start index, returning the first element predicate returns truthy for. The predicate is invoked with one argument: (value).
func FindIndex ¶
This method is like Find except that it returns the index of the first element predicate returns truthy for instead of the element itself.
func FindIndexWith ¶
func FindIndexWith(items DashSlice, element interface{}, comparison Comparison) (int, bool)
Same to IndexOf. The difference is that, this method provides a comparison function to compare programmatically.
func FindLast ¶
This method is like Find except that it iterates over elements of collection from right to left.
func FindLastFrom ¶
This method is like FindFrom except that it iterates over elements of collection from right to left.
func FindLastIndex ¶
This method is like Find except that it returns the index of the first element predicate returns truthy for instead of the element itself.
func FindLastIndexWith ¶
func FindLastIndexWith(items DashSlice, element interface{}, comparison Comparison) (int, bool)
This method is like FindIndex except that it iterates over elements of collection from right to left.
func FromPairs ¶
func FromPairs(pairs []DashSlice) map[interface{}]interface{}
This method returns an object composed from key-value pairs.
func GroupBy ¶
Creates an object composed of keys generated from the results of running each element of collection thru iteratee. The order of grouped values is determined by the order they occur in collection. The corresponding value of each key is an array of elements responsible for generating the key. The iteratee is invoked with one argument: (value).
func IdentityFloat64 ¶
func IdentityFloat64(i interface{}) float64
func IdentityInt ¶
func IdentityInt(i interface{}) int
func IdentityString ¶
func IdentityString(i interface{}) string
func Includes ¶
Checks if value is in collection. If collection is a string, it's checked for a substring of value, otherwise SameValueZero is used for equality comparisons. If fromIndex is negative, it's used as the offset from the end of collection.
func IndexOf ¶
This method is like _.find except that it returns the index of the first element predicate returns truthy for instead of the element itself.
func LastIndexOf ¶
This method is like IndexOf except that it iterates over elements of array from right to left.
func LowerFirst ¶ added in v1.2.0
func Nth ¶
Gets the element at index n of array. If n is negative, the nth element from the end is returned.
func Pad ¶ added in v1.2.0
Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
func PadLeftWith ¶ added in v1.2.0
Pads string on the left sides if it's shorter than length.
func PadRightWith ¶ added in v1.2.0
Pads string on the right sides if it's shorter than length.
func PadWith ¶ added in v1.2.0
Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
func Reduce ¶
Reduces collection to a value which is the accumulated result of running each element in collection thru iteratee, where each successive invocation is supplied the return value of the previous. If accumulator is not given, the first element of collection is used as the initial value. The reducer is invoked with two arguments: (accumulator, value).
func ReduceRight ¶
This method is like Reduce except that it iterates over elements of collection from right to left.
func ReduceRightWithInitial ¶
This method is like ReduceWithInitial except that it iterates over elements of collection from right to left.
func ReduceWithInitial ¶
Reduces collection to a value which is the accumulated result of running each element in collection thru iteratee, where each successive invocation is supplied the return value of the previous. If accumulator is not given, the first element of collection is used as the initial value. The reducer is invoked with two arguments: (accumulator, value).
func ReplaceRegx ¶ added in v1.2.0
Replaces matches for pattern in string with replacement.
func Some ¶
Checks if predicate returns truthy for any element of collection. Iteration is stopped once predicate returns truthy. The predicate is invoked with one argument: (value).
func SplitWithCountLimit ¶ added in v1.2.0
Splits string by separator and return limit count items.
func StartsWith ¶ added in v1.2.0
Checks if string starts with the given target string.
func StartsWithFrom ¶ added in v1.2.0
Checks if string starts with the given target string from a specific position.
func Ternary ¶ added in v1.1.0
func Ternary(satisfy bool, truthyValue interface{}, falsyValue interface{}) interface{}
func TrimEndWith ¶ added in v1.2.0
Removes tailing whitespace or specified characters from string.
func TrimStartWith ¶ added in v1.2.0
Removes leading whitespace or specified characters from string.
func TrimWith ¶ added in v1.2.0
Removes leading and trailing whitespace or specified characters from string.
func Unescape ¶ added in v1.2.0
The inverse of Escape func; this method converts the HTML entities &, <, >, ", and ' in string to their corresponding characters.
func UpperFirst ¶ added in v1.2.0
Converts the first character of string to upper case.
Types ¶
type Comparison ¶
type Comparison func(interface{}, interface{}) bool
type DashSlice ¶
type DashSlice []interface{}
func Chunk ¶
Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.
func Compact ¶
Creates an array with all falsy values removed. The values false, 0, "", nil are falsy.
func ConcatSlices ¶
Creates a new array concatenating array with any additional DashSlices.
func Difference ¶
Creates an array of array values not included in the other given arrays using SameValueZero for equality comparisons. The order and references of result values are determined by the first array.
func DifferenceBy ¶
This method is like _.difference except that it accepts iteratee which is invoked for each element of array and values to generate the criterion by which they're compared. The order and references of result values are determined by the first array. The iteratee is invoked with one argument: (value).
func DifferenceWith ¶
func DifferenceWith(items DashSlice, itemsToCompare DashSlice, comparison Comparison) DashSlice
This method is like _.difference except that it accepts comparator which is invoked to compare elements of array to values. The order and references of result values are determined by the first array. The comparator is invoked with two arguments: (arrVal, othVal).
func DropWhile ¶
Creates a slice of array excluding elements dropped from the beginning. Elements are dropped until predicate returns falsy. The predicate is invoked with two arguments: (value, index).
func Each ¶
Iterates over elements of collection and invokes iteratee for each element. The iteratee is invoked with three arguments: (value, index|key, collection). Iteratee functions may exit iteration early by explicitly returning false.
func EachRight ¶
This method is like ForEach except that it iterates over elements of collection from right to left.
func Filter ¶
Iterates over elements of collection, returning an array of all elements predicate returns truthy for. The predicate is invoked with one argument: (value).
func FlatMap ¶
Creates a flattened array of values by running each element in collection thru iteratee and flattening the mapped results. The iteratee is invoked with one argument: (value).
func FlatMapDeep ¶
This method is like FlatMap except that it recursively flattens the mapped results.
func FlatMapDepth ¶
This method is like FlatMap except that it recursively flattens the mapped results up to depth times.
func FlattenDepth ¶
Recursively flatten array up to depth times.
func ForEach ¶
Iterates over elements of collection and invokes iteratee for each element. The iteratee is invoked with three arguments: (value, index|key, collection). Iteratee functions may exit iteration early by explicitly returning false.
func ForEachRight ¶
This method is like ForEach except that it iterates over elements of collection from right to left.
func Intersection ¶
Creates an array of unique values that are included in all given arrays using SameValueZero for equality comparisons. The order and references of result values are determined by the first array.
func IntersectionBy ¶
This method is like Intersection except that it accepts iteratee which is invoked for each element of each arrays to generate the criterion by which they're compared. The order and references of result values are determined by the first array. The iteratee is invoked with one argument: (value).
func IntersectionWith ¶
func IntersectionWith(items1 DashSlice, items2 DashSlice, comparison Comparison) DashSlice
This method is like _.intersection except that it accepts comparator which is invoked to compare elements of arrays. The order and references of result values are determined by the first array. The comparator is invoked with two arguments: (arrVal, othVal).
func Map ¶
Creates an array of values by running each element in collection thru iteratee. The iteratee is invoked with one argument: (value).
func NewDashSlice ¶
func NewDashSlice(items ...interface{}) DashSlice
func PullAllWith ¶
func PullAllWith(items *DashSlice, values DashSlice, comparison Comparison) DashSlice
This method is like PullAll except that it accepts comparator which is invoked to compare elements of array to values. The comparator is invoked with two arguments: (arrVal, othVal).
func PullAt ¶
Removes elements from array corresponding to indexes and returns an array of removed elements.
func Reject ¶
The opposite of Filter; this method returns the elements of collection that predicate does not return truthy for.
func Remove ¶
Removes all elements from array that predicate returns truthy for and returns an array of the removed elements. The predicate is invoked with two arguments: (value, index).
func Reverse ¶
Reverses array so that the first element becomes the last, the second element becomes the second to last, and so on.
func SampleSize ¶
Gets n random elements at unique keys from collection up to the size of collection.
func SortByFloat64 ¶
func SortByFloat64(items DashSlice, iteratee IterateeToFloat) DashSlice
Creates an array of elements, sorted in ascending order by the results of running each element in a collection thru each iteratee. This method performs a stable sort, that is, it preserves the original sort order of equal elements. The iteratee is invoked with one argument: (value).
func SortByInt ¶
func SortByInt(items DashSlice, iteratee IterateeToInt) DashSlice
Creates an array of elements, sorted in ascending order by the results of running each element in a collection thru each iteratee. This method performs a stable sort, that is, it preserves the original sort order of equal elements. The iteratee is invoked with one argument: (value).
func SortByString ¶
func SortByString(items DashSlice, iteratee IterateeToString) DashSlice
Creates an array of elements, sorted in ascending order by the results of running each element in a collection thru each iteratee. This method performs a stable sort, that is, it preserves the original sort order of equal elements. The iteratee is invoked with one argument: (value).
func TakeRightWhile ¶
Creates a slice of array with elements taken from the end. Elements are taken until predicate returns falsy. The predicate is invoked with one argument: (value).
func TakeWhile ¶
Creates a slice of array with elements taken from the beginning. Elements are taken until predicate returns falsy. The predicate is invoked with one argument: (value).
func Union ¶
Creates an array of unique values, in order, from all given arrays using SameValueZero for equality comparisons.
func UnionBy ¶
This method is like Uniq except that it accepts iteratee which is invoked for each element in array to generate the criterion by which uniqueness is computed. The order of result values is determined by the order they occur in the array. The iteratee is invoked with one argument: (value).
func UnionWith ¶
func UnionWith(comparison Comparison, slices ...DashSlice) DashSlice
This method is like Uniq except that it accepts comparator which is invoked to compare elements of array. The order of result values is determined by the order they occur in the array. The comparator is invoked with two arguments: (arrVal, othVal).
func Uniq ¶
Creates a duplicate-free version of an array, using SameValueZero for equality comparisons, 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.
func UniqBy ¶
This method is like Union except that it accepts iteratee which is invoked for each element of each arrays to generate the criterion by which uniqueness is computed. Result values are chosen from the first array in which the value occurs. The iteratee is invoked with one argument: (value).
func UniqWith ¶
func UniqWith(items DashSlice, comparison Comparison) DashSlice
This method is like Uniq except that it accepts comparator which is invoked to compare elements of array. The order of result values is determined by the order they occur in the array. The comparator is invoked with two arguments: (arrVal, othVal).
func Without ¶
Creates an array excluding all given values using SameValueZero for equality comparisons.
func Xor ¶
Creates an array of unique values that is the symmetric difference of the given arrays. The order of result values is determined by the order they occur in the arrays.
func Zip ¶
Creates an array of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on.
type InitCamelCase ¶ added in v1.1.0
type InitCamelCase bool
type IterateeToFloat ¶
type IterateeToFloat func(interface{}) float64
type IterateeToInt ¶
type IterateeToInt func(interface{}) int
type IterateeToString ¶
type IterateeToString func(interface{}) string