2d-array

1.0.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i 2d-array

Weekly Downloads

37

Version

1.0.0

License

ISC

Last publish

Collaborators

  • domharrington