There was an error while loading. Please reload this page.
Break map into chunks of given size.
function chunk(x, n, s) // x: a map // n: chunk size [1] // s: chunk step [n]
const map = require('extra-map'); var x = new Map([ ['a', 1], ['b', 2], ['c', 3], ['d', 4], ['e', 5], ['f', 6], ['g', 7], ['h', 8] ]); map.chunk(x, 3); // → [ // → Map(3) { 'a' => 1, 'b' => 2, 'c' => 3 }, // → Map(3) { 'd' => 4, 'e' => 5, 'f' => 6 }, // → Map(2) { 'g' => 7, 'h' => 8 } // → ] map.chunk(x, 2, 3); // → [ // → Map(2) { 'a' => 1, 'b' => 2 }, // → Map(2) { 'd' => 4, 'e' => 5 }, // → Map(2) { 'g' => 7, 'h' => 8 } // → ] map.chunk(x, 4, 3); // → [ // → Map(4) { 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4 }, // → Map(4) { 'd' => 4, 'e' => 5, 'f' => 6, 'g' => 7 }, // → Map(2) { 'g' => 7, 'h' => 8 } // → ]