Skip to main content

Arrays

import { chunk, compact, first } from '@rtorcato/js-common/arrays'

Exports

NameSummary
chunkChunks an array into smaller arrays of a specified size.
compactRemoves all falsy values from an array.
firstReturns the first element of an array, or undefined if the array is empty.
flattenFlattens an array one level deep.
groupByGroups array elements by a key derived from each element.
lastReturns the last element of an array, or undefined if the array is empty.
shuffleShuffles an array using the Fisher-Yates algorithm.
uniqueRemoves duplicate values from an array while preserving order.