_flatCat.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import _forceReduced from "./_forceReduced.js";
  2. import _isArrayLike from "./_isArrayLike.js";
  3. import _xArrayReduce from "./_xArrayReduce.js";
  4. import _xReduce from "./_xReduce.js";
  5. import _xfBase from "./_xfBase.js";
  6. var tInit = '@@transducer/init';
  7. var tStep = '@@transducer/step';
  8. var tResult = '@@transducer/result';
  9. var XPreservingReduced =
  10. /*#__PURE__*/
  11. function () {
  12. function XPreservingReduced(xf) {
  13. this.xf = xf;
  14. }
  15. XPreservingReduced.prototype[tInit] = _xfBase.init;
  16. XPreservingReduced.prototype[tResult] = _xfBase.result;
  17. XPreservingReduced.prototype[tStep] = function (result, input) {
  18. var ret = this.xf[tStep](result, input);
  19. return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret;
  20. };
  21. return XPreservingReduced;
  22. }();
  23. var XFlatCat =
  24. /*#__PURE__*/
  25. function () {
  26. function XFlatCat(xf) {
  27. this.xf = new XPreservingReduced(xf);
  28. }
  29. XFlatCat.prototype[tInit] = _xfBase.init;
  30. XFlatCat.prototype[tResult] = _xfBase.result;
  31. XFlatCat.prototype[tStep] = function (result, input) {
  32. return !_isArrayLike(input) ? _xArrayReduce(this.xf, result, [input]) : _xReduce(this.xf, result, input);
  33. };
  34. return XFlatCat;
  35. }();
  36. var _flatCat = function _xcat(xf) {
  37. return new XFlatCat(xf);
  38. };
  39. export default _flatCat;