Projekt

Obecné

Profil

Stáhnout (1019 Bajtů) Statistiky
| Větev: | Revize:
1
var LazyWrapper = require('./_LazyWrapper'),
2
    LodashWrapper = require('./_LodashWrapper'),
3
    reverse = require('./reverse'),
4
    thru = require('./thru');
5

    
6
/**
7
 * This method is the wrapper version of `_.reverse`.
8
 *
9
 * **Note:** This method mutates the wrapped array.
10
 *
11
 * @name reverse
12
 * @memberOf _
13
 * @since 0.1.0
14
 * @category Seq
15
 * @returns {Object} Returns the new `lodash` wrapper instance.
16
 * @example
17
 *
18
 * var array = [1, 2, 3];
19
 *
20
 * _(array).reverse().value()
21
 * // => [3, 2, 1]
22
 *
23
 * console.log(array);
24
 * // => [3, 2, 1]
25
 */
26
function wrapperReverse() {
27
  var value = this.__wrapped__;
28
  if (value instanceof LazyWrapper) {
29
    var wrapped = value;
30
    if (this.__actions__.length) {
31
      wrapped = new LazyWrapper(this);
32
    }
33
    wrapped = wrapped.reverse();
34
    wrapped.__actions__.push({
35
      'func': thru,
36
      'args': [reverse],
37
      'thisArg': undefined
38
    });
39
    return new LodashWrapper(wrapped, this.__chain__);
40
  }
41
  return this.thru(reverse);
42
}
43

    
44
module.exports = wrapperReverse;
(563-563/571)