f4379897adf95d24bbdaec2ca4ba775ae7ebac76
[platform/framework/web/crosswalk-tizen.git] /
1 var isIndex = require('./isIndex'),
2     isLength = require('./isLength');
3
4 /**
5  * The base implementation of `_.at` without support for string collections
6  * and individual key arguments.
7  *
8  * @private
9  * @param {Array|Object} collection The collection to iterate over.
10  * @param {number[]|string[]} props The property names or indexes of elements to pick.
11  * @returns {Array} Returns the new array of picked elements.
12  */
13 function baseAt(collection, props) {
14   var index = -1,
15       length = collection.length,
16       isArr = isLength(length),
17       propsLength = props.length,
18       result = Array(propsLength);
19
20   while(++index < propsLength) {
21     var key = props[index];
22     if (isArr) {
23       result[index] = isIndex(key, length) ? collection[key] : undefined;
24     } else {
25       result[index] = collection[key];
26     }
27   }
28   return result;
29 }
30
31 module.exports = baseAt;