Nurturing Palpable Magnificence
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@extra-iterable/chunk

2.5.13 • Public • Published

Breaks iterable into chunks of given size. 🏃 📼 📦 🌔 📒

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

Install

npm i @extra-iterable/chunk

DownloadsWeekly Downloads

167

Version

2.5.13

License

MIT

Unpacked Size

5.17 kB

Total Files

9

Last publish

Collaborators

  • avatar