sx-array-chunk

1.0.0 • Public • Published

sx-array-chunk

介绍

将一个数组分割成多个

安装教程

  1. 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);
}

Readme

Keywords

Package Sidebar

Install

npm i sx-array-chunk

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

1.9 kB

Total Files

4

Last publish

Collaborators

  • shi-xi