mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 19:37:49 +00:00
Have baseMap use getLength and isLength.
This commit is contained in:
@@ -2475,9 +2475,12 @@
|
|||||||
* @returns {Array} Returns the new mapped array.
|
* @returns {Array} Returns the new mapped array.
|
||||||
*/
|
*/
|
||||||
function baseMap(collection, iteratee) {
|
function baseMap(collection, iteratee) {
|
||||||
var result = [];
|
var index = -1,
|
||||||
|
length = getLength(collection),
|
||||||
|
result = isLength(length) ? Array(length) : [];
|
||||||
|
|
||||||
baseEach(collection, function(value, key, collection) {
|
baseEach(collection, function(value, key, collection) {
|
||||||
result.push(iteratee(value, key, collection));
|
result[++index] = iteratee(value, key, collection);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user