1 var LazyWrapper = require('../internal/LazyWrapper'),
2 LodashWrapper = require('../internal/LodashWrapper'),
3 thru = require('./thru');
6 * Reverses the wrapped array so the first element becomes the last, the
7 * second element becomes the second to last, and so on.
9 * **Note:** This method mutates the wrapped array.
14 * @returns {Object} Returns the new reversed `lodash` wrapper instance.
17 * var array = [1, 2, 3];
19 * _(array).reverse().value()
25 function wrapperReverse() {
26 var value = this.__wrapped__;
28 var interceptor = function(value) {
29 return value.reverse();
31 if (value instanceof LazyWrapper) {
33 if (this.__actions__.length) {
34 wrapped = new LazyWrapper(this);
36 wrapped = wrapped.reverse();
37 wrapped.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
38 return new LodashWrapper(wrapped, this.__chain__);
40 return this.thru(interceptor);
43 module.exports = wrapperReverse;