cols-from-array

1.0.0 • Public • Published

cols-from-array Build Status

Create cols from an array with no bullshit! 😎

Install

$ npm install cols-from-array

Usage

const createCols = require('cols-from-array');
 
createCols([1, 2, 3, 4, 5, 6], {colLength: 2});
//=> [[1, 3, 5], [2, 4, 6]]

API

createCols(arr, [options])

arr

Type: Array

The Array to convert into columns

options

Type: Object

colLength

Type: number
Default: 2

The number of columns to divide the array into.

fillCol

Type: any
Default: N/A

Used to fill the array cols if the length is uneven. For instance,

createCols([1, 2, 3, 4, 5, 6, 7], {colLength: 3, fillCol: 0});
//=> [[1, 4, 7], [2, 5, 0], [3, 6, 0]]

Related

License

MIT © Made with ❤️ & ☕️ by Hamza Baig

Package Sidebar

Install

npm i cols-from-array

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

3.72 kB

Total Files

4

Last publish

Collaborators

  • hamxabaig