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

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var Observable_1 = require("../Observable");
  4. var Subscription_1 = require("../Subscription");
  5. function pairs(obj, scheduler) {
  6. if (!scheduler) {
  7. return new Observable_1.Observable(function (subscriber) {
  8. var keys = Object.keys(obj);
  9. for (var i = 0; i < keys.length && !subscriber.closed; i++) {
  10. var key = keys[i];
  11. if (obj.hasOwnProperty(key)) {
  12. subscriber.next([key, obj[key]]);
  13. }
  14. }
  15. subscriber.complete();
  16. });
  17. }
  18. else {
  19. return new Observable_1.Observable(function (subscriber) {
  20. var keys = Object.keys(obj);
  21. var subscription = new Subscription_1.Subscription();
  22. subscription.add(scheduler.schedule(dispatch, 0, { keys: keys, index: 0, subscriber: subscriber, subscription: subscription, obj: obj }));
  23. return subscription;
  24. });
  25. }
  26. }
  27. exports.pairs = pairs;
  28. function dispatch(state) {
  29. var keys = state.keys, index = state.index, subscriber = state.subscriber, subscription = state.subscription, obj = state.obj;
  30. if (!subscriber.closed) {
  31. if (index < keys.length) {
  32. var key = keys[index];
  33. subscriber.next([key, obj[key]]);
  34. subscription.add(this.schedule({ keys: keys, index: index + 1, subscriber: subscriber, subscription: subscription, obj: obj }));
  35. }
  36. else {
  37. subscriber.complete();
  38. }
  39. }
  40. }
  41. exports.dispatch = dispatch;
  42. //# sourceMappingURL=pairs.js.map