2d-array 中文文档教程

发布于 9年前 浏览 59 项目主页 更新于 3年前

2d-array

将一维数组转换为二维数组

build status

Installation

npm install 2d-array --save

Usage

var create2dArray = require('2d-array')

console.log(create2dArray([ 1, 2, 3, 4, 5, 6 ], 2))
// -> [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]

console.log(create2dArray([ 1, 2, 3, 4], 2, 2))
// -> [ [ 1 ], [ 2, 3 ] ]

var array = create2dArray(array, n[, ignore])

选项必须包括:

  • array - an array to transform into a 2d array.
  • n - the number of items to be inside each array. Non-numbers (undefined, null, ''), Non-floats or strings that represent anything other than one number will return an empty array.
  • 'ignore' - Optional - When set, deletes the value specified from any array containing that value.

Credits

2d-array

Transform a 1d array into a 2d array

build status

Installation

npm install 2d-array --save

Usage

var create2dArray = require('2d-array')

console.log(create2dArray([ 1, 2, 3, 4, 5, 6 ], 2))
// -> [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]

console.log(create2dArray([ 1, 2, 3, 4], 2, 2))
// -> [ [ 1 ], [ 2, 3 ] ]

var array = create2dArray(array, n[, ignore])

Options must include:

  • array - an array to transform into a 2d array.
  • n - the number of items to be inside each array. Non-numbers (undefined, null, ''), Non-floats or strings that represent anything other than one number will return an empty array.
  • 'ignore' - Optional - When set, deletes the value specified from any array containing that value.

Credits

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文