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.

pairs.js 1.6KB

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