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

range.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var Observable_1 = require("../Observable");
  4. function range(start, count, scheduler) {
  5. if (start === void 0) { start = 0; }
  6. return new Observable_1.Observable(function (subscriber) {
  7. if (count === undefined) {
  8. count = start;
  9. start = 0;
  10. }
  11. var index = 0;
  12. var current = start;
  13. if (scheduler) {
  14. return scheduler.schedule(dispatch, 0, {
  15. index: index, count: count, start: start, subscriber: subscriber
  16. });
  17. }
  18. else {
  19. do {
  20. if (index++ >= count) {
  21. subscriber.complete();
  22. break;
  23. }
  24. subscriber.next(current++);
  25. if (subscriber.closed) {
  26. break;
  27. }
  28. } while (true);
  29. }
  30. return undefined;
  31. });
  32. }
  33. exports.range = range;
  34. function dispatch(state) {
  35. var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber;
  36. if (index >= count) {
  37. subscriber.complete();
  38. return;
  39. }
  40. subscriber.next(start);
  41. if (subscriber.closed) {
  42. return;
  43. }
  44. state.index = index + 1;
  45. state.start = start + 1;
  46. this.schedule(state);
  47. }
  48. exports.dispatch = dispatch;
  49. //# sourceMappingURL=range.js.map