ramda
Version:
A practical functional library for JavaScript programmers.
28 lines • 930 B
JavaScript
var _xfBase = /*#__PURE__*/require("./_xfBase.js");
var XDropRepeatsWith = /*#__PURE__*/function () {
function XDropRepeatsWith(pred, xf) {
this.xf = xf;
this.pred = pred;
this.lastValue = undefined;
this.seenFirstValue = false;
}
XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init;
XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result;
XDropRepeatsWith.prototype['@@transducer/step'] = function (result, input) {
var sameAsLast = false;
if (!this.seenFirstValue) {
this.seenFirstValue = true;
} else if (this.pred(this.lastValue, input)) {
sameAsLast = true;
}
this.lastValue = input;
return sameAsLast ? result : this.xf['@@transducer/step'](result, input);
};
return XDropRepeatsWith;
}();
function _xdropRepeatsWith(pred) {
return function (xf) {
return new XDropRepeatsWith(pred, xf);
};
}
module.exports = _xdropRepeatsWith;