dconvert-array
v1.0.3
Published
Convert 1d array to 2d array
Downloads
2
Readme
dconvert-array
Convert 1d array to 2d array
Installation
npm
$ npm i dconvert-array
Usage
import oneArray2twoArray from 'dconvert-array';
const data1 = [1, 2, 3, 4, 5, 6, 7];
const data2 = [1, 2, 3, 4, 5, 6, 7, 8];
const rdata1 = oneArray2twoArray(data1, 3);
const rdata2 = oneArray2twoArray(data2, 3, item => (item === 5 ? 2 : 1));
console.log(rdata1); // [[1,2,3],[4,5,6],[7]]
console.log(rdata2); // [[1,2,3],[4,5],[6,7,8]]