_xfindLastIndex.js 770 B

123456789101112131415161718192021222324252627282930313233343536
  1. import _xfBase from "./_xfBase.js";
  2. var XFindLastIndex =
  3. /*#__PURE__*/
  4. function () {
  5. function XFindLastIndex(f, xf) {
  6. this.xf = xf;
  7. this.f = f;
  8. this.idx = -1;
  9. this.lastIdx = -1;
  10. }
  11. XFindLastIndex.prototype['@@transducer/init'] = _xfBase.init;
  12. XFindLastIndex.prototype['@@transducer/result'] = function (result) {
  13. return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.lastIdx));
  14. };
  15. XFindLastIndex.prototype['@@transducer/step'] = function (result, input) {
  16. this.idx += 1;
  17. if (this.f(input)) {
  18. this.lastIdx = this.idx;
  19. }
  20. return result;
  21. };
  22. return XFindLastIndex;
  23. }();
  24. export default function _xfindLastIndex(f) {
  25. return function (xf) {
  26. return new XFindLastIndex(f, xf);
  27. };
  28. }