_xfind.js 809 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import _reduced from "./_reduced.js";
  2. import _xfBase from "./_xfBase.js";
  3. var XFind =
  4. /*#__PURE__*/
  5. function () {
  6. function XFind(f, xf) {
  7. this.xf = xf;
  8. this.f = f;
  9. this.found = false;
  10. }
  11. XFind.prototype['@@transducer/init'] = _xfBase.init;
  12. XFind.prototype['@@transducer/result'] = function (result) {
  13. if (!this.found) {
  14. result = this.xf['@@transducer/step'](result, void 0);
  15. }
  16. return this.xf['@@transducer/result'](result);
  17. };
  18. XFind.prototype['@@transducer/step'] = function (result, input) {
  19. if (this.f(input)) {
  20. this.found = true;
  21. result = _reduced(this.xf['@@transducer/step'](result, input));
  22. }
  23. return result;
  24. };
  25. return XFind;
  26. }();
  27. export default function _xfind(f) {
  28. return function (xf) {
  29. return new XFind(f, xf);
  30. };
  31. }