main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
901 bytes
|
Line | |
---|
1 | import _xfBase from "./_xfBase.js";
|
---|
2 |
|
---|
3 | var XDropRepeatsWith =
|
---|
4 | /*#__PURE__*/
|
---|
5 | function () {
|
---|
6 | function XDropRepeatsWith(pred, xf) {
|
---|
7 | this.xf = xf;
|
---|
8 | this.pred = pred;
|
---|
9 | this.lastValue = undefined;
|
---|
10 | this.seenFirstValue = false;
|
---|
11 | }
|
---|
12 |
|
---|
13 | XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init;
|
---|
14 | XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result;
|
---|
15 |
|
---|
16 | XDropRepeatsWith.prototype['@@transducer/step'] = function (result, input) {
|
---|
17 | var sameAsLast = false;
|
---|
18 |
|
---|
19 | if (!this.seenFirstValue) {
|
---|
20 | this.seenFirstValue = true;
|
---|
21 | } else if (this.pred(this.lastValue, input)) {
|
---|
22 | sameAsLast = true;
|
---|
23 | }
|
---|
24 |
|
---|
25 | this.lastValue = input;
|
---|
26 | return sameAsLast ? result : this.xf['@@transducer/step'](result, input);
|
---|
27 | };
|
---|
28 |
|
---|
29 | return XDropRepeatsWith;
|
---|
30 | }();
|
---|
31 |
|
---|
32 | export default function _xdropRepeatsWith(pred) {
|
---|
33 | return function (xf) {
|
---|
34 | return new XDropRepeatsWith(pred, xf);
|
---|
35 | };
|
---|
36 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.