Sha256: f72eef17c0da044c0fe44b017a344746ea8ba2d7023137e7d083929e38a8a2a7

Contents?: true

Size: 1.1 KB

Versions: 153

Compression:

Stored size: 1.1 KB

Contents

var LazyWrapper = require('../internal/LazyWrapper'),
    LodashWrapper = require('../internal/LodashWrapper'),
    thru = require('./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` wrapper instance.
 * @example
 *
 * var array = [1, 2, 3];
 *
 * _(array).reverse().value()
 * // => [3, 2, 1]
 *
 * console.log(array);
 * // => [3, 2, 1]
 */
function wrapperReverse() {
  var value = this.__wrapped__;

  var interceptor = function(value) {
    return value.reverse();
  };
  if (value instanceof LazyWrapper) {
    var wrapped = value;
    if (this.__actions__.length) {
      wrapped = new LazyWrapper(this);
    }
    wrapped = wrapped.reverse();
    wrapped.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
    return new LodashWrapper(wrapped, this.__chain__);
  }
  return this.thru(interceptor);
}

module.exports = wrapperReverse;

Version data entries

153 entries across 80 versions & 8 rubygems

Version Path
trusty-festivity-extension-2.5.2 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.5.1 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.5.1 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.5.0 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.5.0 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.6 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.6 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.5 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.5 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.4 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.4 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.3 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.3 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.2 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.2 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.1 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.1 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.0 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.4.0 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperReverse.js
trusty-festivity-extension-2.3.30 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperReverse.js