Skip to main content
Module

x/arrays/mod.ts>Arrays.chunk

Provides utility methods for common Array operations
Latest
function Arrays.chunk
import { Arrays } from "https://deno.land/x/arrays@v1.0.21/mod.ts";
const { chunk } = Arrays;

Returns an array split into chunks. If the array can't be split equally based on the given size, the last chunk will be the remaining elements.

import 'https://deno.land/x/arrays/mod.ts'

const arr = [1, 2, 3, 4, 5]
const chunkedArr = arr.chunk(2)
// => [[1, 2], [3, 4], 5]

Parameters

array: Array<any>
  • Size of each chunk
size: number

Returns

Array<any>