https://github.com/hamxabaig/cols-from-array
Create columns from an array with no bullshit! :sunglasses:
https://github.com/hamxabaig/cols-from-array
array-manipulations columns nested-arrays
Last synced: 9 months ago
JSON representation
Create columns from an array with no bullshit! :sunglasses:
- Host: GitHub
- URL: https://github.com/hamxabaig/cols-from-array
- Owner: hamxabaig
- License: mit
- Created: 2019-04-14T12:46:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-14T12:49:49.000Z (over 6 years ago)
- Last Synced: 2025-03-23T19:15:39.714Z (9 months ago)
- Topics: array-manipulations, columns, nested-arrays
- Language: JavaScript
- Size: 2.93 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# cols-from-array [](https://travis-ci.com/hamxabaig/cols-from-array)
> Create cols from an array with no bullshit! :sunglasses:
## Install
```
$ npm install cols-from-array
```
## Usage
```js
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
- [rows-from-array](https://github.com/hamxabaig/rows-from-array) - Create rows from array
## License
MIT © Made with ❤️ & ☕️ by [Hamza Baig](http://hamxabaig.github.io)