Skip to main content
Module

x/simplestatistics/index.js>chunk

simple statistics for node & browser javascript
Go to Latest
function chunk
import { chunk } from "https://deno.land/x/simplestatistics@v7.7.5/index.js";

Split an array into chunks of a specified size. This function has the same behavior as PHP's array_chunk function, and thus will insert smaller-sized chunks at the end if the input size is not divisible by the chunk size.

x is expected to be an array, and chunkSize a number. The x array can contain any kind of data.

Examples

chunk([1, 2, 3, 4, 5, 6], 2); // => [[1, 2], [3, 4], [5, 6]]

Parameters

x

a sample

chunkSize

size of each output array. must be a positive integer