Skip to content
Node: lodash / Array.*13 APIs

slice

Package slice provides lodash/Array-style collection helpers for slices.

import "github.com/sahilkhaire/gox/slice"
## API reference

Select a symbol below — each page explains what it does, shows Node.js vs Go comparisons, and includes a runnable example.

Functions

SymbolNode.jsKindSummary
Chunk_.chunk(arr, n)funcChunk splits into sub-slices of size (lodash chunk).
Containsarr.includes(x)funcContains reports whether v is in the slice (Array.includes).
Everyarr.every(fn)funcEvery reports whether fn is true for all elements (Array.every).
Filterarr.filter(fn)funcFilter keeps elements where fn returns true (Array.filter).
Findarr.find(fn)funcFind returns the first element matching fn, or zero and false (Array.find).
FindIndexarr.findIndex(fn)funcFindIndex returns the index of the first match, or -1 (Array.findIndex).
Flatten_.flatten(arr)funcFlatten flattens one level of nested slices (lodash flatten).
GroupBy_.groupBy(arr, fn)funcGroupBy groups elements by key from fn (lodash groupBy).
Maparr.map(fn)funcMap applies fn to each element (Array.map).
Reducearr.reduce(fn, init)funcReduce folds the slice (Array.reduce).
Somearr.some(fn)funcSome reports whether fn is true for any element (Array.some).
SortBy_.sortBy(arr, fn)funcSortBy returns a sorted copy ordered by fn's key (lodash sortBy).
Uniq_.uniq(arr)funcUniq returns unique elements in first-seen order (lodash uniq).

MIT Licensed · Built for Node.js developers moving to Go