source: node_modules/ramda/src/internal/_xdropRepeatsWith.js@ 65b6638

main
Last change on this file since 65b6638 was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 940 bytes
Line 
1var _xfBase =
2/*#__PURE__*/
3require("./_xfBase.js");
4
5var XDropRepeatsWith =
6/*#__PURE__*/
7function () {
8 function XDropRepeatsWith(pred, xf) {
9 this.xf = xf;
10 this.pred = pred;
11 this.lastValue = undefined;
12 this.seenFirstValue = false;
13 }
14
15 XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init;
16 XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result;
17
18 XDropRepeatsWith.prototype['@@transducer/step'] = function (result, input) {
19 var sameAsLast = false;
20
21 if (!this.seenFirstValue) {
22 this.seenFirstValue = true;
23 } else if (this.pred(this.lastValue, input)) {
24 sameAsLast = true;
25 }
26
27 this.lastValue = input;
28 return sameAsLast ? result : this.xf['@@transducer/step'](result, input);
29 };
30
31 return XDropRepeatsWith;
32}();
33
34function _xdropRepeatsWith(pred) {
35 return function (xf) {
36 return new XDropRepeatsWith(pred, xf);
37 };
38}
39
40module.exports = _xdropRepeatsWith;
Note: See TracBrowser for help on using the repository browser.