Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / internal / baseMap.js
1 var baseEach = require('./baseEach'),
2     isArrayLike = require('./isArrayLike');
3
4 /**
5  * The base implementation of `_.map` without support for callback shorthands
6  * and `this` binding.
7  *
8  * @private
9  * @param {Array|Object|string} collection The collection to iterate over.
10  * @param {Function} iteratee The function invoked per iteration.
11  * @returns {Array} Returns the new mapped array.
12  */
13 function baseMap(collection, iteratee) {
14   var index = -1,
15       result = isArrayLike(collection) ? Array(collection.length) : [];
16
17   baseEach(collection, function(value, key, collection) {
18     result[++index] = iteratee(value, key, collection);
19   });
20   return result;
21 }
22
23 module.exports = baseMap;