_lazyReverse.js 491 B

123456789101112131415161718192021222324
  1. var LazyWrapper = require('./_LazyWrapper');
  2. /**
  3. * Reverses the direction of lazy iteration.
  4. *
  5. * @private
  6. * @name reverse
  7. * @memberOf LazyWrapper
  8. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  9. */
  10. function lazyReverse() {
  11. if (this.__filtered__) {
  12. var result = new LazyWrapper(this);
  13. result.__dir__ = -1;
  14. result.__filtered__ = true;
  15. } else {
  16. result = this.clone();
  17. result.__dir__ *= -1;
  18. }
  19. return result;
  20. }
  21. module.exports = lazyReverse;