https://github.com/fergiemcdowall/distribute-array
Distributes one array evenly between a given number of smaller arrays
https://github.com/fergiemcdowall/distribute-array
Last synced: about 1 month ago
JSON representation
Distributes one array evenly between a given number of smaller arrays
- Host: GitHub
- URL: https://github.com/fergiemcdowall/distribute-array
- Owner: fergiemcdowall
- License: mit
- Created: 2015-09-05T14:45:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-04T08:36:42.000Z (over 9 years ago)
- Last Synced: 2025-03-01T21:36:08.979Z (2 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![NPM version][npm-version-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![MIT License][license-image]][license-url] [![Build Status][travis-image]][travis-url]
# distribute-array
Distributes one array evenly between a given number of smaller arrays```javascript
var da = require('distribute-array');
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];newArr = da(arr, 3); // newArr is now [ [ 1, 2, 3, 10 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]
newArr = da(arr, 5); // newArr is now [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ], [ 9, 10 ] ]
newArr = da(arr, 15); // newArr is now [ [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ],
// [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10 ],
// [], [], [], [], [] ]
```[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: LICENSE[npm-url]: https://npmjs.org/package/distribute-array
[npm-version-image]: http://img.shields.io/npm/v/distribute-array.svg?style=flat
[npm-downloads-image]: http://img.shields.io/npm/dm/distribute-array.svg?style=flat[travis-url]: http://travis-ci.org/fergiemcdowall/distribute-array
[travis-image]: http://img.shields.io/travis/fergiemcdowall/distribute-array.svg?style=flat