Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Subscriber } from '../Subscriber';
  2. export function every(predicate, thisArg) {
  3. return (source) => source.lift(new EveryOperator(predicate, thisArg, source));
  4. }
  5. class EveryOperator {
  6. constructor(predicate, thisArg, source) {
  7. this.predicate = predicate;
  8. this.thisArg = thisArg;
  9. this.source = source;
  10. }
  11. call(observer, source) {
  12. return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
  13. }
  14. }
  15. class EverySubscriber extends Subscriber {
  16. constructor(destination, predicate, thisArg, source) {
  17. super(destination);
  18. this.predicate = predicate;
  19. this.thisArg = thisArg;
  20. this.source = source;
  21. this.index = 0;
  22. this.thisArg = thisArg || this;
  23. }
  24. notifyComplete(everyValueMatch) {
  25. this.destination.next(everyValueMatch);
  26. this.destination.complete();
  27. }
  28. _next(value) {
  29. let result = false;
  30. try {
  31. result = this.predicate.call(this.thisArg, value, this.index++, this.source);
  32. }
  33. catch (err) {
  34. this.destination.error(err);
  35. return;
  36. }
  37. if (!result) {
  38. this.notifyComplete(false);
  39. }
  40. }
  41. _complete() {
  42. this.notifyComplete(true);
  43. }
  44. }
  45. //# sourceMappingURL=every.js.map