_xtake.js 669 B

1234567891011121314151617181920212223242526272829
  1. import _reduced from "./_reduced.js";
  2. import _xfBase from "./_xfBase.js";
  3. var XTake =
  4. /*#__PURE__*/
  5. function () {
  6. function XTake(n, xf) {
  7. this.xf = xf;
  8. this.n = n;
  9. this.i = 0;
  10. }
  11. XTake.prototype['@@transducer/init'] = _xfBase.init;
  12. XTake.prototype['@@transducer/result'] = _xfBase.result;
  13. XTake.prototype['@@transducer/step'] = function (result, input) {
  14. this.i += 1;
  15. var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input);
  16. return this.n >= 0 && this.i >= this.n ? _reduced(ret) : ret;
  17. };
  18. return XTake;
  19. }();
  20. export default function _xtake(n) {
  21. return function (xf) {
  22. return new XTake(n, xf);
  23. };
  24. }