Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fathym_common/src/src.deps.ts>chunk

The Fathym Reference Architecture provides the common foundation for applications built in Typescript.
Go to Latest
function chunk
import { chunk } from "https://deno.land/x/fathym_common@v0.0.142/src/src.deps.ts";

Splits the given array into chunks of the given size and returns them.

Examples

Example 1

import { chunk } from "https://deno.land/std@0.224.0/collections/chunk.ts";
import { assertEquals } from "https://deno.land/std@0.224.0/assert/assert_equals.ts";

const words = [
  "lorem",
  "ipsum",
  "dolor",
  "sit",
  "amet",
  "consetetur",
  "sadipscing",
];
const chunks = chunk(words, 3);

assertEquals(
  chunks,
  [
    ["lorem", "ipsum", "dolor"],
    ["sit", "amet", "consetetur"],
    ["sadipscing"],
  ],
);

Parameters

array: readonly T[]
size: number