mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Bump to v4.8.0.
This commit is contained in:
13
chunk.js
13
chunk.js
@@ -1,4 +1,5 @@
|
||||
var baseSlice = require('./_baseSlice'),
|
||||
isIterateeCall = require('./_isIterateeCall'),
|
||||
toInteger = require('./toInteger');
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
@@ -15,7 +16,8 @@ var nativeCeil = Math.ceil,
|
||||
* @since 3.0.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to process.
|
||||
* @param {number} [size=0] The length of each chunk.
|
||||
* @param {number} [size=1] The length of each chunk
|
||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||
* @returns {Array} Returns the new array containing chunks.
|
||||
* @example
|
||||
*
|
||||
@@ -25,9 +27,12 @@ var nativeCeil = Math.ceil,
|
||||
* _.chunk(['a', 'b', 'c', 'd'], 3);
|
||||
* // => [['a', 'b', 'c'], ['d']]
|
||||
*/
|
||||
function chunk(array, size) {
|
||||
size = nativeMax(toInteger(size), 0);
|
||||
|
||||
function chunk(array, size, guard) {
|
||||
if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
|
||||
size = 1;
|
||||
} else {
|
||||
size = nativeMax(toInteger(size), 0);
|
||||
}
|
||||
var length = array ? array.length : 0;
|
||||
if (!length || size < 1) {
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user