_xdropLastWhile.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import _xfBase from "./_xfBase.js";
  2. import _xReduce from "./_xReduce.js";
  3. var XDropLastWhile =
  4. /*#__PURE__*/
  5. function () {
  6. function XDropLastWhile(fn, xf) {
  7. this.f = fn;
  8. this.retained = [];
  9. this.xf = xf;
  10. }
  11. XDropLastWhile.prototype['@@transducer/init'] = _xfBase.init;
  12. XDropLastWhile.prototype['@@transducer/result'] = function (result) {
  13. this.retained = null;
  14. return this.xf['@@transducer/result'](result);
  15. };
  16. XDropLastWhile.prototype['@@transducer/step'] = function (result, input) {
  17. return this.f(input) ? this.retain(result, input) : this.flush(result, input);
  18. };
  19. XDropLastWhile.prototype.flush = function (result, input) {
  20. result = _xReduce(this.xf, result, this.retained);
  21. this.retained = [];
  22. return this.xf['@@transducer/step'](result, input);
  23. };
  24. XDropLastWhile.prototype.retain = function (result, input) {
  25. this.retained.push(input);
  26. return result;
  27. };
  28. return XDropLastWhile;
  29. }();
  30. export default function _xdropLastWhile(fn) {
  31. return function (xf) {
  32. return new XDropLastWhile(fn, xf);
  33. };
  34. }