🍕chunki
chunki exposes two methods; one for splitting array into chunks based on size and another for combining them together.
chunki has two utility functions:
- One to split an array into smaller chunks.
- Another to combine chunks into a single array.
Chunk Method
const { chunk } = require("chunki");
const arr = [1, 2, 3, 4, 5, 6];
const chunks = chunk(arr, 2);
console.log(chunks);
const arr = [{ name: "john" }, { name: "Patlu" }];
const chunks = chunk(arr, 1);
console.log(chunks);
Flatten Method
const { flatten } = require("chunki");
const chunks = [
[1, 2],
[3, 4],
[5, 6],
];
const flattenArr = flatten(chunks);
console.log(flattenArr);