partition-all
v1.0.1
Published
Returns a sequence of lists like partition, but may include partitions with fewer than n items at the end.
Downloads
17
Readme
partition-all
Returns a sequence of arrays, but may include partitions with fewer than n items at the end.
Installation
npm install partition-all --save
Usage
var partitionAll = require('partition-all');
partitionAll(2, [1, 2, 3, 4, 5, 6]); // => [[1, 2], [3, 4], [5, 6]]
partitionAll(2, [1, 2, 3, 4, 5]); // => [[1, 2], [3, 4], [5]]
partitionAll(3, [1, 2, 3, 4, 5]); // => [[1, 2, 3], [4, 5]]
var partition2 = partitionAll(2);
partition2([1, 2, 3, 4, 5, 6]); // => [[1, 2], [3, 4], [5, 6]]