Skip to content

Instantly share code, notes, and snippets.

'use strict'
/**
* Partition the given list into separate groups which may be, at most, the size given.
* @param {Array<T>} list This may be any array-like object that supports indexing and has a length property
* @param {Number} size Any positive integer that is not NaN
* @return {Array<Array<T>>} A set of arrays that are sized based upon the given size. The nested arrays may be
* no larger than the given size, but **may** be smaller; there will be no empty arrays
* @throws {TypeError} If list is falsey (i.e, undefined/null)
* @throws {TypeError} If list does not have a length property