1 var LazyWrapper = require('./_LazyWrapper'),
2 LodashWrapper = require('./_LodashWrapper'),
3 baseAt = require('./_baseAt'),
4 baseFlatten = require('./_baseFlatten'),
5 isIndex = require('./_isIndex'),
6 rest = require('./rest'),
7 thru = require('./thru');
10 * This method is the wrapper version of `_.at`.
15 * @param {...(string|string[])} [paths] The property paths of elements to pick,
16 * specified individually or in arrays.
17 * @returns {Object} Returns the new `lodash` wrapper instance.
20 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
22 * _(object).at(['a[0].b.c', 'a[1]']).value();
25 * _(['a', 'b', 'c']).at(0, 2).value();
28 var wrapperAt = rest(function(paths) {
29 paths = baseFlatten(paths);
30 var length = paths.length,
31 start = length ? paths[0] : 0,
32 value = this.__wrapped__,
33 interceptor = function(object) { return baseAt(object, paths); };
35 if (length > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex(start)) {
36 return this.thru(interceptor);
38 value = value.slice(start, +start + (length ? 1 : 0));
39 value.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
40 return new LodashWrapper(value, this.__chain__).thru(function(array) {
41 if (length && !array.length) {
42 array.push(undefined);
48 module.exports = wrapperAt;