_xuniqWith.js 748 B

1234567891011121314151617181920212223242526272829303132
  1. import _includesWith from "./_includesWith.js";
  2. import _xfBase from "./_xfBase.js";
  3. var XUniqWith =
  4. /*#__PURE__*/
  5. function () {
  6. function XUniqWith(pred, xf) {
  7. this.xf = xf;
  8. this.pred = pred;
  9. this.items = [];
  10. }
  11. XUniqWith.prototype['@@transducer/init'] = _xfBase.init;
  12. XUniqWith.prototype['@@transducer/result'] = _xfBase.result;
  13. XUniqWith.prototype['@@transducer/step'] = function (result, input) {
  14. if (_includesWith(this.pred, input, this.items)) {
  15. return result;
  16. } else {
  17. this.items.push(input);
  18. return this.xf['@@transducer/step'](result, input);
  19. }
  20. };
  21. return XUniqWith;
  22. }();
  23. export default function _xuniqWith(pred) {
  24. return function (xf) {
  25. return new XUniqWith(pred, xf);
  26. };
  27. }