partition-into
v1.0.0
Published
Partition an array into required sets of n numbers, and the remaining values
Downloads
6
Maintainers
Readme
partition-into
Partition an array into required sets of n numbers, and the remaining values
Install
$ npm install --save partition-into
Usage
var partitionInto = require('partition-into');
partitionInto([1, 2, 3, 4, 5], 3);
//=> [[1, 2, 3], [4, 5]]
partitionInto([1, 2, 3, 4, 5, 6, 7], 5);
//=> [[1, 2, 3, 4, 5], [6, 7]]
partitionInto([1, 2, 3, 4, 5]);
//=> [ [ ] ]
API
partitionInto(input_obj, num)
input_obj
Required
Type: Array
Input 1-dimensional array
num
Required
Type: integer
Default: undefined
Number of items per partition
License
MIT © Siddharth Kannan