29b40c2e929c8952b5844aa4f8824fce072f6bdd
[platform/framework/web/crosswalk-tizen.git] /
1 var baseEach = require('./baseEach'),
2     getLength = require('./getLength'),
3     isLength = require('./isLength');
4
5 /**
6  * The base implementation of `_.map` without support for callback shorthands
7  * and `this` binding.
8  *
9  * @private
10  * @param {Array|Object|string} collection The collection to iterate over.
11  * @param {Function} iteratee The function invoked per iteration.
12  * @returns {Array} Returns the new mapped array.
13  */
14 function baseMap(collection, iteratee) {
15   var index = -1,
16       length = getLength(collection),
17       result = isLength(length) ? Array(length) : [];
18
19   baseEach(collection, function(value, key, collection) {
20     result[++index] = iteratee(value, key, collection);
21   });
22   return result;
23 }
24
25 module.exports = baseMap;