mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
981 B
40 lines
981 B
9 years ago
|
var LazyWrapper = require('./_LazyWrapper'),
|
||
|
LodashWrapper = require('./_LodashWrapper'),
|
||
|
reverse = require('./reverse'),
|
||
10 years ago
|
thru = require('./thru');
|
||
|
|
||
|
/**
|
||
9 years ago
|
* This method is the wrapper version of `_.reverse`.
|
||
10 years ago
|
*
|
||
|
* **Note:** This method mutates the wrapped array.
|
||
|
*
|
||
|
* @name reverse
|
||
|
* @memberOf _
|
||
9 years ago
|
* @category Seq
|
||
|
* @returns {Object} Returns the new `lodash` wrapper instance.
|
||
10 years ago
|
* @example
|
||
|
*
|
||
|
* var array = [1, 2, 3];
|
||
|
*
|
||
|
* _(array).reverse().value()
|
||
|
* // => [3, 2, 1]
|
||
|
*
|
||
|
* console.log(array);
|
||
|
* // => [3, 2, 1]
|
||
|
*/
|
||
|
function wrapperReverse() {
|
||
|
var value = this.__wrapped__;
|
||
|
if (value instanceof LazyWrapper) {
|
||
9 years ago
|
var wrapped = value;
|
||
10 years ago
|
if (this.__actions__.length) {
|
||
9 years ago
|
wrapped = new LazyWrapper(this);
|
||
10 years ago
|
}
|
||
9 years ago
|
wrapped = wrapped.reverse();
|
||
9 years ago
|
wrapped.__actions__.push({ 'func': thru, 'args': [reverse], 'thisArg': undefined });
|
||
9 years ago
|
return new LodashWrapper(wrapped, this.__chain__);
|
||
10 years ago
|
}
|
||
9 years ago
|
return this.thru(reverse);
|
||
10 years ago
|
}
|
||
|
|
||
|
module.exports = wrapperReverse;
|