mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Bump to v3.0.0.
This commit is contained in:
35
chain/wrapperReverse.js
Normal file
35
chain/wrapperReverse.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import LazyWrapper from '../internal/LazyWrapper';
|
||||
import LodashWrapper from '../internal/LodashWrapper';
|
||||
import thru from './thru';
|
||||
|
||||
/**
|
||||
* Reverses the wrapped array so the first element becomes the last, the
|
||||
* second element becomes the second to last, and so on.
|
||||
*
|
||||
* **Note:** This method mutates the wrapped array.
|
||||
*
|
||||
* @name reverse
|
||||
* @memberOf _
|
||||
* @category Chain
|
||||
* @returns {Object} Returns the new reversed `lodash` object.
|
||||
* @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) {
|
||||
return new LodashWrapper(value.reverse());
|
||||
}
|
||||
return this.thru(function(value) {
|
||||
return value.reverse();
|
||||
});
|
||||
}
|
||||
|
||||
export default wrapperReverse;
|
||||
Reference in New Issue
Block a user