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.

range.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Observable } from '../Observable';
  2. export function range(start = 0, count = 0, scheduler) {
  3. return new Observable(subscriber => {
  4. let index = 0;
  5. let current = start;
  6. if (scheduler) {
  7. return scheduler.schedule(dispatch, 0, {
  8. index, count, start, subscriber
  9. });
  10. }
  11. else {
  12. do {
  13. if (index++ >= count) {
  14. subscriber.complete();
  15. break;
  16. }
  17. subscriber.next(current++);
  18. if (subscriber.closed) {
  19. break;
  20. }
  21. } while (true);
  22. }
  23. return undefined;
  24. });
  25. }
  26. export function dispatch(state) {
  27. const { start, index, count, subscriber } = state;
  28. if (index >= count) {
  29. subscriber.complete();
  30. return;
  31. }
  32. subscriber.next(start);
  33. if (subscriber.closed) {
  34. return;
  35. }
  36. state.index = index + 1;
  37. state.start = start + 1;
  38. this.schedule(state);
  39. }
  40. //# sourceMappingURL=range.js.map