_xuniqBy.js 617 B

123456789101112131415161718192021222324252627
  1. import _Set from "./_Set.js";
  2. import _xfBase from "./_xfBase.js";
  3. var XUniqBy =
  4. /*#__PURE__*/
  5. function () {
  6. function XUniqBy(f, xf) {
  7. this.xf = xf;
  8. this.f = f;
  9. this.set = new _Set();
  10. }
  11. XUniqBy.prototype['@@transducer/init'] = _xfBase.init;
  12. XUniqBy.prototype['@@transducer/result'] = _xfBase.result;
  13. XUniqBy.prototype['@@transducer/step'] = function (result, input) {
  14. return this.set.add(this.f(input)) ? this.xf['@@transducer/step'](result, input) : result;
  15. };
  16. return XUniqBy;
  17. }();
  18. export default function _xuniqBy(f) {
  19. return function (xf) {
  20. return new XUniqBy(f, xf);
  21. };
  22. }