diff --git a/lodash.js b/lodash.js index a0d546b29..1fceb973b 100644 --- a/lodash.js +++ b/lodash.js @@ -473,26 +473,6 @@ return false; } - /** - * The base implementation of `_.at` without support for strings and individual - * key arguments. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {number[]|string[]} [props] The property names or indexes of elements to pick. - * @returns {Array} Returns the new array of picked elements. - */ - function baseAt(collection, props) { - var index = -1, - length = props.length, - result = Array(length); - - while(++index < length) { - result[index] = collection[props[index]]; - } - return result; - } - /** * The base implementation of `compareAscending` which compares values and * sorts them in ascending order without guaranteeing a stable sort. @@ -1423,6 +1403,34 @@ return object; } + /** + * The base implementation of `_.at` without support for strings and individual + * key arguments. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {number[]|string[]} [props] The property names or indexes of elements to pick. + * @returns {Array} Returns the new array of picked elements. + */ + function baseAt(collection, props) { + var index = -1, + length = collection ? collection.length : 0, + isArr = isLength(length), + propsLength = props.length, + result = Array(propsLength); + + while(++index < propsLength) { + var key = props[index]; + if (isArr) { + key = parseFloat(key); + result[index] = (key > -1 && key < length && key % 1 == 0) ? collection[key] : undefined; + } else { + result[index] = collection[key]; + } + } + return result; + } + /** * The base implementation of `_.bindAll` without support for individual * method name arguments.