_xdropRepeatsWith.js 901 B

123456789101112131415161718192021222324252627282930313233343536
  1. import _xfBase from "./_xfBase.js";
  2. var XDropRepeatsWith =
  3. /*#__PURE__*/
  4. function () {
  5. function XDropRepeatsWith(pred, xf) {
  6. this.xf = xf;
  7. this.pred = pred;
  8. this.lastValue = undefined;
  9. this.seenFirstValue = false;
  10. }
  11. XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init;
  12. XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result;
  13. XDropRepeatsWith.prototype['@@transducer/step'] = function (result, input) {
  14. var sameAsLast = false;
  15. if (!this.seenFirstValue) {
  16. this.seenFirstValue = true;
  17. } else if (this.pred(this.lastValue, input)) {
  18. sameAsLast = true;
  19. }
  20. this.lastValue = input;
  21. return sameAsLast ? result : this.xf['@@transducer/step'](result, input);
  22. };
  23. return XDropRepeatsWith;
  24. }();
  25. export default function _xdropRepeatsWith(pred) {
  26. return function (xf) {
  27. return new XDropRepeatsWith(pred, xf);
  28. };
  29. }