Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

skipWhile.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { Subscriber } from '../Subscriber';
  2. export function skipWhile(predicate) {
  3. return (source) => source.lift(new SkipWhileOperator(predicate));
  4. }
  5. class SkipWhileOperator {
  6. constructor(predicate) {
  7. this.predicate = predicate;
  8. }
  9. call(subscriber, source) {
  10. return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
  11. }
  12. }
  13. class SkipWhileSubscriber extends Subscriber {
  14. constructor(destination, predicate) {
  15. super(destination);
  16. this.predicate = predicate;
  17. this.skipping = true;
  18. this.index = 0;
  19. }
  20. _next(value) {
  21. const destination = this.destination;
  22. if (this.skipping) {
  23. this.tryCallPredicate(value);
  24. }
  25. if (!this.skipping) {
  26. destination.next(value);
  27. }
  28. }
  29. tryCallPredicate(value) {
  30. try {
  31. const result = this.predicate(value, this.index++);
  32. this.skipping = Boolean(result);
  33. }
  34. catch (err) {
  35. this.destination.error(err);
  36. }
  37. }
  38. }
  39. //# sourceMappingURL=skipWhile.js.map