_baseAt.js 591 B

1234567891011121314151617181920212223
  1. import get from './get';
  2. /**
  3. * The base implementation of `_.at` without support for individual paths.
  4. *
  5. * @private
  6. * @param {Object} object The object to iterate over.
  7. * @param {string[]} paths The property paths of elements to pick.
  8. * @returns {Array} Returns the new array of picked elements.
  9. */
  10. function baseAt(object, paths) {
  11. var index = -1,
  12. isNil = object == null,
  13. length = paths.length,
  14. result = Array(length);
  15. while (++index < length) {
  16. result[index] = isNil ? undefined : get(object, paths[index]);
  17. }
  18. return result;
  19. }
  20. export default baseAt;