lang/array.js
/**
		 * Splits array into groups and returns an array of arrays where the items of each
		 * nested array share a common key.
		 *
		 * @static
		 * @param {Array} a
		 * @param {Function} keySelector - A function that returns a unique key for an item.
		 * @returns {Array}
		 */
Splits array into groups and returns an array of arrays where the items of each
nested array share a common key.

@static
@param {Array} a
@param {Function} keySelector - A function that returns a unique key for an item.
@returns {Array}
Splits array into groups and returns an array of arrays where the items of each nested array share a common key . @static @param { Array } a @param { Function } keySelector - A function that returns a unique key for an item . @returns { Array }
batchBy(a, keySelector) {
			assert.argumentIsArray(a, 'a');
			assert.argumentIsRequired(keySelector, 'keySelector', Function);
			let currentKey = null;
			let currentBatch = null;
			return a.reduce((batches, item) => {
				const key = keySelector(item);
				if (currentBatch === null || currentKey !== key) {
					currentKey = key;
					currentBatch = [];
					batches.push(currentBatch);
				}
				currentBatch.push(item);
				return batches;
			}, []);
		}
batchBy ( a , keySelector ) { assert . argumentIsArray ( a , 'a' ) ; assert . argumentIsRequired ( keySelector , 'keySelector' , Function ) ; let currentKey = null ; let currentBatch = null ; return a . reduce ( ( batches , item ) => { const key = keySelector ( item ) ; if ( currentBatch === null || currentKey !== key ) { currentKey = key ; currentBatch = [ ] ; batches . push ( currentBatch ) ; } currentBatch . push ( item ) ; return batches ; } , [ ] ) ; }
Splits array into groups and returns an array of arrays where the items of each
 nested array share a common key.
Splits array into groups and returns an array of arrays where the items of each nested array share a common key .