@extra-iterable/chunk

Breaks iterable into chunks of given size.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-iterable/chunk
512.5.222 years ago3 years agoMinified + gzip package size for @extra-iterable/chunk in KB

Readme

Breaks iterable into chunks of given size. :package: :smileycat: :running: :vhs: :moon: :scroll: :newspaper: :bluebook:
This is part of package extra-iterable.



iterable.chunk(x, [n], [s]);
// x: an iterable
// n: chunk size (1)
// s: chunk step (n)

const iterable = require("extra-iterable");

var x = [1, 2, 3, 4, 5, 6, 7, 8];
[...iterable.chunk(x, 3)];
// [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ]

[...iterable.chunk(x, 2, 3)];
// [ [ 1, 2 ], [ 4, 5 ], [ 7, 8 ] ]

[...iterable.chunk(x, 4, 3)];
// [ [ 1, 2, 3, 4 ], [ 4, 5, 6, 7 ], [ 7, 8 ] ]



References