blob: c5b52190f4dcc5986850eaec5f36195cc8a2e42f [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001var LazyWrapper = require('./_LazyWrapper');
2
3/**
4 * Reverses the direction of lazy iteration.
5 *
6 * @private
7 * @name reverse
8 * @memberOf LazyWrapper
9 * @returns {Object} Returns the new reversed `LazyWrapper` object.
10 */
11function lazyReverse() {
12 if (this.__filtered__) {
13 var result = new LazyWrapper(this);
14 result.__dir__ = -1;
15 result.__filtered__ = true;
16 } else {
17 result = this.clone();
18 result.__dir__ *= -1;
19 }
20 return result;
21}
22
23module.exports = lazyReverse;