1.0.0 • Published 5 years ago

cols-from-array v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

cols-from-array Build Status

Create cols from an array with no bullshit! :sunglasses:

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