123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- var LazyWrapper = require('./_LazyWrapper'),
- LodashWrapper = require('./_LodashWrapper'),
- baseAt = require('./_baseAt'),
- flatRest = require('./_flatRest'),
- isIndex = require('./_isIndex'),
- thru = require('./thru');
- var wrapperAt = flatRest(function(paths) {
- var length = paths.length,
- start = length ? paths[0] : 0,
- value = this.__wrapped__,
- interceptor = function(object) { return baseAt(object, paths); };
- if (length > 1 || this.__actions__.length ||
- !(value instanceof LazyWrapper) || !isIndex(start)) {
- return this.thru(interceptor);
- }
- value = value.slice(start, +start + (length ? 1 : 0));
- value.__actions__.push({
- 'func': thru,
- 'args': [interceptor],
- 'thisArg': undefined
- });
- return new LodashWrapper(value, this.__chain__).thru(function(array) {
- if (length && !array.length) {
- array.push(undefined);
- }
- return array;
- });
- });
- module.exports = wrapperAt;
|