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