sx-array-chunk
v1.0.0
Published
将一个数组分割成多个
Downloads
2
Readme
sx-array-chunk
介绍
将一个数组分割成多个
安装教程
- npm i sx-array-chunk
使用说明
import sxArrayChunk from "sx-array-chunk";
try {
const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
console.log(sxArrayChunk(array, 2));
// 返回 [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ], [ 9, 10 ] ]
console.log(sxArrayChunk(array, 3));
// 返回 [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ], [ 10 ] ]
} catch (error) {
console.log(error.message);
}