import { chunkify } from "https://deno.land/x/iter@v3.2.3/lib/transformers.ts";
Splits an iterable into evenly sized chunks. See @sindresorhus/chunkify
Examples
Example 1
Example 1
import * as iter from "https://deno.land/x/iter/mod.ts";
const naturals = iter.create.increments(-1, -1);
const chunks = iter.chunkify(naturals, 3);
const iterator = chunks[Symbol.iterator]();
console.log(iterator.next().value); // -> [ -1, -2, -3 ]
console.log(iterator.next().value); // -> [ -4, -5, -6 ]
console.log(iterator.next().value); // -> [ -7, -8, -9 ]
console.log(iterator.next().value); // -> [ -10, -11, -12 ]
console.log(iterator.next().value); // -> [ -13, -14, -15 ]
console.log(iterator.next().value); // -> [ -16, -17, -18 ]
Parameters
it: Iterable<T>
- The iterable being chunkified.
Returns
A new iterable over chunk arrays.