rxjs-rails 2.3.9 → 2.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rxjs/rails/version.rb +1 -1
- data/vendor/assets/javascripts/rx.aggregates.js +174 -204
- data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
- data/vendor/assets/javascripts/rx.all.compat.js +1626 -1528
- data/vendor/assets/javascripts/rx.all.compat.min.js +3 -3
- data/vendor/assets/javascripts/rx.all.js +1624 -1526
- data/vendor/assets/javascripts/rx.all.min.js +3 -3
- data/vendor/assets/javascripts/rx.async.compat.js +241 -0
- data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
- data/vendor/assets/javascripts/rx.async.js +241 -0
- data/vendor/assets/javascripts/rx.async.min.js +1 -1
- data/vendor/assets/javascripts/rx.backpressure.js +3 -3
- data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
- data/vendor/assets/javascripts/rx.binding.js +350 -378
- data/vendor/assets/javascripts/rx.binding.min.js +1 -1
- data/vendor/assets/javascripts/rx.coincidence.js +16 -21
- data/vendor/assets/javascripts/rx.compat.js +633 -683
- data/vendor/assets/javascripts/rx.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.js +633 -683
- data/vendor/assets/javascripts/rx.lite.compat.js +941 -1137
- data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.lite.extras.js +58 -74
- data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -1
- data/vendor/assets/javascripts/rx.lite.js +941 -1137
- data/vendor/assets/javascripts/rx.lite.min.js +2 -2
- data/vendor/assets/javascripts/rx.min.js +2 -2
- data/vendor/assets/javascripts/rx.time.js +182 -212
- data/vendor/assets/javascripts/rx.time.min.js +1 -1
- metadata +10 -10
@@ -119,18 +119,6 @@
|
|
119
119
|
|
120
120
|
/**
|
121
121
|
* Returns an observable sequence that produces a value after dueTime has elapsed and then after each period.
|
122
|
-
*
|
123
|
-
* @example
|
124
|
-
* 1 - res = Rx.Observable.timer(new Date());
|
125
|
-
* 2 - res = Rx.Observable.timer(new Date(), 1000);
|
126
|
-
* 3 - res = Rx.Observable.timer(new Date(), Rx.Scheduler.timeout);
|
127
|
-
* 4 - res = Rx.Observable.timer(new Date(), 1000, Rx.Scheduler.timeout);
|
128
|
-
*
|
129
|
-
* 5 - res = Rx.Observable.timer(5000);
|
130
|
-
* 6 - res = Rx.Observable.timer(5000, 1000);
|
131
|
-
* 7 - res = Rx.Observable.timer(5000, Rx.Scheduler.timeout);
|
132
|
-
* 8 - res = Rx.Observable.timer(5000, 1000, Rx.Scheduler.timeout);
|
133
|
-
*
|
134
122
|
* @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value.
|
135
123
|
* @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring.
|
136
124
|
* @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used.
|
@@ -141,7 +129,7 @@
|
|
141
129
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
142
130
|
if (periodOrScheduler !== undefined && typeof periodOrScheduler === 'number') {
|
143
131
|
period = periodOrScheduler;
|
144
|
-
} else if (periodOrScheduler
|
132
|
+
} else if (isScheduler(periodOrScheduler)) {
|
145
133
|
scheduler = periodOrScheduler;
|
146
134
|
}
|
147
135
|
if (dueTime instanceof Date && period === undefined) {
|
@@ -260,7 +248,37 @@
|
|
260
248
|
*/
|
261
249
|
observableProto.throttle = function (dueTime, scheduler) {
|
262
250
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
263
|
-
|
251
|
+
var source = this;
|
252
|
+
return new AnonymousObservable(function (observer) {
|
253
|
+
var cancelable = new SerialDisposable(), hasvalue = false, value, id = 0;
|
254
|
+
var subscription = source.subscribe(
|
255
|
+
function (x) {
|
256
|
+
hasvalue = true;
|
257
|
+
value = x;
|
258
|
+
id++;
|
259
|
+
var currentId = id,
|
260
|
+
d = new SingleAssignmentDisposable();
|
261
|
+
cancelable.setDisposable(d);
|
262
|
+
d.setDisposable(scheduler.scheduleWithRelative(dueTime, function () {
|
263
|
+
hasValue && id === currentId && observer.onNext(value);
|
264
|
+
hasvalue = false;
|
265
|
+
}));
|
266
|
+
},
|
267
|
+
function (e) {
|
268
|
+
cancelable.dispose();
|
269
|
+
observer.onError(e);
|
270
|
+
hasvalue = false;
|
271
|
+
id++;
|
272
|
+
},
|
273
|
+
function () {
|
274
|
+
cancelable.dispose();
|
275
|
+
hasvalue && observer.onNext(value);
|
276
|
+
observer.onCompleted();
|
277
|
+
hasvalue = false;
|
278
|
+
id++;
|
279
|
+
});
|
280
|
+
return new CompositeDisposable(subscription, cancelable);
|
281
|
+
});
|
264
282
|
};
|
265
283
|
|
266
284
|
/**
|
@@ -277,70 +295,49 @@
|
|
277
295
|
*/
|
278
296
|
observableProto.windowWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) {
|
279
297
|
var source = this, timeShift;
|
280
|
-
|
281
|
-
|
298
|
+
if (timeShiftOrScheduler === undefined) {
|
299
|
+
timeShift = timeSpan;
|
300
|
+
}
|
282
301
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
283
302
|
if (typeof timeShiftOrScheduler === 'number') {
|
284
303
|
timeShift = timeShiftOrScheduler;
|
285
|
-
} else if (
|
304
|
+
} else if (isScheduler(timeShiftOrScheduler)) {
|
286
305
|
timeShift = timeSpan;
|
287
306
|
scheduler = timeShiftOrScheduler;
|
288
307
|
}
|
289
308
|
return new AnonymousObservable(function (observer) {
|
290
309
|
var groupDisposable,
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
groupDisposable.add(source.subscribe(function (x) {
|
305
|
-
var i, len;
|
306
|
-
for (i = 0, len = q.length; i < len; i++) {
|
307
|
-
q[i].onNext(x);
|
308
|
-
}
|
309
|
-
}, function (e) {
|
310
|
-
var i, len;
|
311
|
-
for (i = 0, len = q.length; i < len; i++) {
|
312
|
-
q[i].onError(e);
|
313
|
-
}
|
314
|
-
observer.onError(e);
|
315
|
-
}, function () {
|
316
|
-
var i, len;
|
317
|
-
for (i = 0, len = q.length; i < len; i++) {
|
318
|
-
q[i].onCompleted();
|
319
|
-
}
|
320
|
-
observer.onCompleted();
|
321
|
-
}));
|
322
|
-
|
323
|
-
return refCountDisposable;
|
324
|
-
|
325
|
-
function createTimer () {
|
326
|
-
var m = new SingleAssignmentDisposable(), isSpan = false, isShift = false;
|
310
|
+
nextShift = timeShift,
|
311
|
+
nextSpan = timeSpan,
|
312
|
+
q = [],
|
313
|
+
refCountDisposable,
|
314
|
+
timerD = new SerialDisposable(),
|
315
|
+
totalTime = 0;
|
316
|
+
groupDisposable = new CompositeDisposable(timerD),
|
317
|
+
refCountDisposable = new RefCountDisposable(groupDisposable);
|
318
|
+
|
319
|
+
function createTimer () {
|
320
|
+
var m = new SingleAssignmentDisposable(),
|
321
|
+
isSpan = false,
|
322
|
+
isShift = false;
|
327
323
|
timerD.setDisposable(m);
|
328
|
-
|
329
324
|
if (nextSpan === nextShift) {
|
330
325
|
isSpan = true;
|
331
326
|
isShift = true;
|
332
327
|
} else if (nextSpan < nextShift) {
|
333
|
-
|
328
|
+
isSpan = true;
|
334
329
|
} else {
|
335
330
|
isShift = true;
|
336
331
|
}
|
337
|
-
|
338
332
|
var newTotalTime = isSpan ? nextSpan : nextShift,
|
339
|
-
|
333
|
+
ts = newTotalTime - totalTime;
|
340
334
|
totalTime = newTotalTime;
|
341
|
-
|
342
|
-
|
343
|
-
|
335
|
+
if (isSpan) {
|
336
|
+
nextSpan += timeShift;
|
337
|
+
}
|
338
|
+
if (isShift) {
|
339
|
+
nextShift += timeShift;
|
340
|
+
}
|
344
341
|
m.setDisposable(scheduler.scheduleWithRelative(ts, function () {
|
345
342
|
var s;
|
346
343
|
if (isShift) {
|
@@ -354,17 +351,30 @@
|
|
354
351
|
}
|
355
352
|
createTimer();
|
356
353
|
}));
|
357
|
-
}
|
354
|
+
};
|
355
|
+
q.push(new Subject());
|
356
|
+
observer.onNext(addRef(q[0], refCountDisposable));
|
357
|
+
createTimer();
|
358
|
+
groupDisposable.add(source.subscribe(function (x) {
|
359
|
+
for (var i = 0, len = q.length; i < len; i++) {
|
360
|
+
q[i].onNext(x);
|
361
|
+
}
|
362
|
+
}, function (e) {
|
363
|
+
for (var i = 0, len = q.length; i < len; i++) {
|
364
|
+
q[i].onError(e);
|
365
|
+
}
|
366
|
+
observer.onError(e);
|
367
|
+
}, function () {
|
368
|
+
for (var i = 0, len = q.length; i < len; i++) {
|
369
|
+
q[i].onCompleted();
|
370
|
+
}
|
371
|
+
observer.onCompleted();
|
372
|
+
}));
|
373
|
+
return refCountDisposable;
|
358
374
|
});
|
359
375
|
};
|
360
|
-
|
361
376
|
/**
|
362
377
|
* Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed.
|
363
|
-
* @example
|
364
|
-
* 1 - res = source.windowWithTimeOrCount(5000, 50); // 5s or 50 items
|
365
|
-
* 2 - res = source.windowWithTimeOrCount(5000, 50, scheduler); //5s or 50 items
|
366
|
-
*
|
367
|
-
* @memberOf Observable#
|
368
378
|
* @param {Number} timeSpan Maximum time length of a window.
|
369
379
|
* @param {Number} count Maximum element count of a window.
|
370
380
|
* @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.
|
@@ -375,15 +385,31 @@
|
|
375
385
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
376
386
|
return new AnonymousObservable(function (observer) {
|
377
387
|
var createTimer,
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
388
|
+
groupDisposable,
|
389
|
+
n = 0,
|
390
|
+
refCountDisposable,
|
391
|
+
s,
|
392
|
+
timerD = new SerialDisposable(),
|
393
|
+
windowId = 0;
|
384
394
|
groupDisposable = new CompositeDisposable(timerD);
|
385
395
|
refCountDisposable = new RefCountDisposable(groupDisposable);
|
386
|
-
|
396
|
+
createTimer = function (id) {
|
397
|
+
var m = new SingleAssignmentDisposable();
|
398
|
+
timerD.setDisposable(m);
|
399
|
+
m.setDisposable(scheduler.scheduleWithRelative(timeSpan, function () {
|
400
|
+
var newId;
|
401
|
+
if (id !== windowId) {
|
402
|
+
return;
|
403
|
+
}
|
404
|
+
n = 0;
|
405
|
+
newId = ++windowId;
|
406
|
+
s.onCompleted();
|
407
|
+
s = new Subject();
|
408
|
+
observer.onNext(addRef(s, refCountDisposable));
|
409
|
+
createTimer(newId);
|
410
|
+
}));
|
411
|
+
};
|
412
|
+
s = new Subject();
|
387
413
|
observer.onNext(addRef(s, refCountDisposable));
|
388
414
|
createTimer(0);
|
389
415
|
groupDisposable.add(source.subscribe(function (x) {
|
@@ -398,34 +424,19 @@
|
|
398
424
|
s = new Subject();
|
399
425
|
observer.onNext(addRef(s, refCountDisposable));
|
400
426
|
}
|
401
|
-
|
427
|
+
if (newWindow) {
|
428
|
+
createTimer(newId);
|
429
|
+
}
|
402
430
|
}, function (e) {
|
403
431
|
s.onError(e);
|
404
432
|
observer.onError(e);
|
405
433
|
}, function () {
|
406
434
|
s.onCompleted();
|
407
435
|
observer.onCompleted();
|
408
|
-
}));
|
409
|
-
|
410
|
-
return refCountDisposable;
|
411
|
-
|
412
|
-
function createTimer(id) {
|
413
|
-
var m = new SingleAssignmentDisposable();
|
414
|
-
timerD.setDisposable(m);
|
415
|
-
m.setDisposable(scheduler.scheduleWithRelative(timeSpan, function () {
|
416
|
-
var newId;
|
417
|
-
if (id !== windowId) { return; }
|
418
|
-
n = 0;
|
419
|
-
newId = ++windowId;
|
420
|
-
s.onCompleted();
|
421
|
-
s = new Subject();
|
422
|
-
observer.onNext(addRef(s, refCountDisposable));
|
423
|
-
createTimer(newId);
|
424
|
-
}));
|
425
|
-
}
|
436
|
+
}));
|
437
|
+
return refCountDisposable;
|
426
438
|
});
|
427
439
|
};
|
428
|
-
|
429
440
|
/**
|
430
441
|
* Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.
|
431
442
|
*
|
@@ -545,16 +556,7 @@
|
|
545
556
|
};
|
546
557
|
|
547
558
|
/**
|
548
|
-
* Returns the source observable sequence or the other observable sequence if dueTime elapses.
|
549
|
-
*
|
550
|
-
* @example
|
551
|
-
* 1 - res = source.timeout(new Date()); // As a date
|
552
|
-
* 2 - res = source.timeout(5000); // 5 seconds
|
553
|
-
* 3 - res = source.timeout(new Date(), Rx.Observable.returnValue(42)); // As a date and timeout observable
|
554
|
-
* 4 - res = source.timeout(5000, Rx.Observable.returnValue(42)); // 5 seconds and timeout observable
|
555
|
-
* 5 - res = source.timeout(new Date(), Rx.Observable.returnValue(42), Rx.Scheduler.timeout); // As a date and timeout observable
|
556
|
-
* 6 - res = source.timeout(5000, Rx.Observable.returnValue(42), Rx.Scheduler.timeout); // 5 seconds and timeout observable
|
557
|
-
*
|
559
|
+
* Returns the source observable sequence or the other observable sequence if dueTime elapses.
|
558
560
|
* @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.
|
559
561
|
* @param {Observable} [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used.
|
560
562
|
* @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.
|
@@ -577,7 +579,7 @@
|
|
577
579
|
|
578
580
|
subscription.setDisposable(original);
|
579
581
|
|
580
|
-
|
582
|
+
function createTimer() {
|
581
583
|
var myId = id;
|
582
584
|
timer.setDisposable(scheduler[schedulerMethod](dueTime, function () {
|
583
585
|
if (id === myId) {
|
@@ -585,7 +587,7 @@
|
|
585
587
|
subscription.setDisposable(other.subscribe(observer));
|
586
588
|
}
|
587
589
|
}));
|
588
|
-
}
|
590
|
+
}
|
589
591
|
|
590
592
|
createTimer();
|
591
593
|
|
@@ -798,83 +800,71 @@
|
|
798
800
|
|
799
801
|
/**
|
800
802
|
* Returns the source observable sequence, switching to the other observable sequence if a timeout is signaled.
|
801
|
-
*
|
802
|
-
* @example
|
803
|
-
* 1 - res = source.timeoutWithSelector(Rx.Observable.timer(500));
|
804
|
-
* 2 - res = source.timeoutWithSelector(Rx.Observable.timer(500), function (x) { return Rx.Observable.timer(200); });
|
805
|
-
* 3 - res = source.timeoutWithSelector(Rx.Observable.timer(500), function (x) { return Rx.Observable.timer(200); }, Rx.Observable.returnValue(42));
|
806
|
-
*
|
807
803
|
* @param {Observable} [firstTimeout] Observable sequence that represents the timeout for the first element. If not provided, this defaults to Observable.never().
|
808
804
|
* @param {Function} [timeoutDurationSelector] Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.
|
809
805
|
* @param {Observable} [other] Sequence to return in case of a timeout. If not provided, this is set to Observable.throwException().
|
810
806
|
* @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
|
811
807
|
*/
|
812
808
|
observableProto.timeoutWithSelector = function (firstTimeout, timeoutdurationSelector, other) {
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
809
|
+
if (arguments.length === 1) {
|
810
|
+
timeoutdurationSelector = firstTimeout;
|
811
|
+
firstTimeout = observableNever();
|
812
|
+
}
|
813
|
+
other || (other = observableThrow(new Error('Timeout')));
|
814
|
+
var source = this;
|
815
|
+
return new AnonymousObservable(function (observer) {
|
816
|
+
var subscription = new SerialDisposable(), timer = new SerialDisposable(), original = new SingleAssignmentDisposable();
|
821
817
|
|
822
|
-
|
818
|
+
subscription.setDisposable(original);
|
823
819
|
|
824
|
-
|
825
|
-
var myId = id, timerWins = function () {
|
826
|
-
return id === myId;
|
827
|
-
};
|
828
|
-
var d = new SingleAssignmentDisposable();
|
829
|
-
timer.setDisposable(d);
|
830
|
-
d.setDisposable(timeout.subscribe(function () {
|
831
|
-
if (timerWins()) {
|
832
|
-
subscription.setDisposable(other.subscribe(observer));
|
833
|
-
}
|
834
|
-
d.dispose();
|
835
|
-
}, function (e) {
|
836
|
-
if (timerWins()) {
|
837
|
-
observer.onError(e);
|
838
|
-
}
|
839
|
-
}, function () {
|
840
|
-
if (timerWins()) {
|
841
|
-
subscription.setDisposable(other.subscribe(observer));
|
842
|
-
}
|
843
|
-
}));
|
844
|
-
};
|
820
|
+
var id = 0, switched = false;
|
845
821
|
|
846
|
-
|
847
|
-
|
848
|
-
var res = !switched;
|
849
|
-
if (res) {
|
850
|
-
id++;
|
851
|
-
}
|
852
|
-
return res;
|
853
|
-
};
|
822
|
+
function setTimer(timeout) {
|
823
|
+
var myId = id;
|
854
824
|
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
}
|
825
|
+
function timerWins () {
|
826
|
+
return id === myId;
|
827
|
+
}
|
828
|
+
|
829
|
+
var d = new SingleAssignmentDisposable();
|
830
|
+
timer.setDisposable(d);
|
831
|
+
d.setDisposable(timeout.subscribe(function () {
|
832
|
+
timerWins() && subscription.setDisposable(other.subscribe(observer));
|
833
|
+
d.dispose();
|
834
|
+
}, function (e) {
|
835
|
+
timerWins() && observer.onError(e);
|
836
|
+
}, function () {
|
837
|
+
timerWins() && subscription.setDisposable(other.subscribe(observer));
|
838
|
+
}));
|
839
|
+
};
|
840
|
+
|
841
|
+
setTimer(firstTimeout);
|
842
|
+
|
843
|
+
function observerWins() {
|
844
|
+
var res = !switched;
|
845
|
+
if (res) { id++; }
|
846
|
+
return res;
|
847
|
+
}
|
848
|
+
|
849
|
+
original.setDisposable(source.subscribe(function (x) {
|
850
|
+
if (observerWins()) {
|
851
|
+
observer.onNext(x);
|
852
|
+
var timeout;
|
853
|
+
try {
|
854
|
+
timeout = timeoutdurationSelector(x);
|
855
|
+
} catch (e) {
|
856
|
+
observer.onError(e);
|
857
|
+
return;
|
858
|
+
}
|
859
|
+
setTimer(isPromise(timeout) ? observableFromPromise(timeout) : timeout);
|
860
|
+
}
|
861
|
+
}, function (e) {
|
862
|
+
observerWins() && observer.onError(e);
|
863
|
+
}, function () {
|
864
|
+
observerWins() && observer.onCompleted();
|
865
|
+
}));
|
866
|
+
return new CompositeDisposable(subscription, timer);
|
867
|
+
});
|
878
868
|
};
|
879
869
|
|
880
870
|
/**
|
@@ -889,7 +879,8 @@
|
|
889
879
|
observableProto.throttleWithSelector = function (throttleDurationSelector) {
|
890
880
|
var source = this;
|
891
881
|
return new AnonymousObservable(function (observer) {
|
892
|
-
var value, hasValue = false, cancelable = new SerialDisposable(), id = 0
|
882
|
+
var value, hasValue = false, cancelable = new SerialDisposable(), id = 0;
|
883
|
+
var subscription = source.subscribe(function (x) {
|
893
884
|
var throttle;
|
894
885
|
try {
|
895
886
|
throttle = throttleDurationSelector(x);
|
@@ -897,21 +888,20 @@
|
|
897
888
|
observer.onError(e);
|
898
889
|
return;
|
899
890
|
}
|
891
|
+
|
892
|
+
isPromise(throttle) && (throttle = observableFromPromise(throttle));
|
893
|
+
|
900
894
|
hasValue = true;
|
901
895
|
value = x;
|
902
896
|
id++;
|
903
897
|
var currentid = id, d = new SingleAssignmentDisposable();
|
904
898
|
cancelable.setDisposable(d);
|
905
899
|
d.setDisposable(throttle.subscribe(function () {
|
906
|
-
|
907
|
-
observer.onNext(value);
|
908
|
-
}
|
900
|
+
hasValue && id === currentid && observer.onNext(value);
|
909
901
|
hasValue = false;
|
910
902
|
d.dispose();
|
911
903
|
}, observer.onError.bind(observer), function () {
|
912
|
-
|
913
|
-
observer.onNext(value);
|
914
|
-
}
|
904
|
+
hasValue && id === currentid && observer.onNext(value);
|
915
905
|
hasValue = false;
|
916
906
|
d.dispose();
|
917
907
|
}));
|
@@ -922,9 +912,7 @@
|
|
922
912
|
id++;
|
923
913
|
}, function () {
|
924
914
|
cancelable.dispose();
|
925
|
-
|
926
|
-
observer.onNext(value);
|
927
|
-
}
|
915
|
+
hasValue && observer.onNext(value);
|
928
916
|
observer.onCompleted();
|
929
917
|
hasValue = false;
|
930
918
|
id++;
|
@@ -970,9 +958,6 @@
|
|
970
958
|
|
971
959
|
/**
|
972
960
|
* Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements.
|
973
|
-
*
|
974
|
-
* @example
|
975
|
-
* 1 - res = source.takeLastWithTime(5000, [optional timer scheduler], [optional loop scheduler]);
|
976
961
|
* @description
|
977
962
|
* This operator accumulates a queue with a length enough to store elements received during the initial duration window.
|
978
963
|
* As more elements are received, elements older than the specified duration are taken from the queue and produced on the
|
@@ -986,7 +971,6 @@
|
|
986
971
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
987
972
|
return new AnonymousObservable(function (observer) {
|
988
973
|
var q = [];
|
989
|
-
|
990
974
|
return source.subscribe(function (x) {
|
991
975
|
var now = scheduler.now();
|
992
976
|
q.push({ interval: now, value: x });
|
@@ -997,11 +981,8 @@
|
|
997
981
|
var now = scheduler.now();
|
998
982
|
while (q.length > 0) {
|
999
983
|
var next = q.shift();
|
1000
|
-
if (now - next.interval <= duration) {
|
1001
|
-
observer.onNext(next.value);
|
1002
|
-
}
|
984
|
+
if (now - next.interval <= duration) { observer.onNext(next.value); }
|
1003
985
|
}
|
1004
|
-
|
1005
986
|
observer.onCompleted();
|
1006
987
|
});
|
1007
988
|
});
|
@@ -1009,9 +990,6 @@
|
|
1009
990
|
|
1010
991
|
/**
|
1011
992
|
* Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
|
1012
|
-
*
|
1013
|
-
* @example
|
1014
|
-
* 1 - res = source.takeLastBufferWithTime(5000, [optional scheduler]);
|
1015
993
|
* @description
|
1016
994
|
* This operator accumulates a queue with a length enough to store elements received during the initial duration window.
|
1017
995
|
* As more elements are received, elements older than the specified duration are taken from the queue and produced on the
|
@@ -1025,7 +1003,6 @@
|
|
1025
1003
|
isScheduler(scheduler) || (scheduler = timeoutScheduler);
|
1026
1004
|
return new AnonymousObservable(function (observer) {
|
1027
1005
|
var q = [];
|
1028
|
-
|
1029
1006
|
return source.subscribe(function (x) {
|
1030
1007
|
var now = scheduler.now();
|
1031
1008
|
q.push({ interval: now, value: x });
|
@@ -1036,11 +1013,8 @@
|
|
1036
1013
|
var now = scheduler.now(), res = [];
|
1037
1014
|
while (q.length > 0) {
|
1038
1015
|
var next = q.shift();
|
1039
|
-
if (now - next.interval <= duration) {
|
1040
|
-
res.push(next.value);
|
1041
|
-
}
|
1016
|
+
if (now - next.interval <= duration) { res.push(next.value); }
|
1042
1017
|
}
|
1043
|
-
|
1044
1018
|
observer.onNext(res);
|
1045
1019
|
observer.onCompleted();
|
1046
1020
|
});
|
@@ -1100,10 +1074,10 @@
|
|
1100
1074
|
* Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.
|
1101
1075
|
*
|
1102
1076
|
* @examples
|
1103
|
-
* 1 - res = source.skipUntilWithTime(new Date(), [
|
1104
|
-
* 2 - res = source.skipUntilWithTime(5000, [
|
1105
|
-
* @param startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.
|
1106
|
-
* @param scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
|
1077
|
+
* 1 - res = source.skipUntilWithTime(new Date(), [scheduler]);
|
1078
|
+
* 2 - res = source.skipUntilWithTime(5000, [scheduler]);
|
1079
|
+
* @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.
|
1080
|
+
* @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
|
1107
1081
|
* @returns {Observable} An observable sequence with the elements skipped until the specified start time.
|
1108
1082
|
*/
|
1109
1083
|
observableProto.skipUntilWithTime = function (startTime, scheduler) {
|
@@ -1124,13 +1098,9 @@
|
|
1124
1098
|
};
|
1125
1099
|
|
1126
1100
|
/**
|
1127
|
-
* Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
|
1128
|
-
*
|
1129
|
-
* @example
|
1130
|
-
* 1 - res = source.takeUntilWithTime(new Date(), [optional scheduler]);
|
1131
|
-
* 2 - res = source.takeUntilWithTime(5000, [optional scheduler]);
|
1101
|
+
* Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
|
1132
1102
|
* @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately.
|
1133
|
-
* @param {Scheduler} scheduler Scheduler to run the timer on.
|
1103
|
+
* @param {Scheduler} [scheduler] Scheduler to run the timer on.
|
1134
1104
|
* @returns {Observable} An observable sequence with the elements taken until the specified end time.
|
1135
1105
|
*/
|
1136
1106
|
observableProto.takeUntilWithTime = function (endTime, scheduler) {
|
@@ -1139,9 +1109,9 @@
|
|
1139
1109
|
'scheduleWithAbsolute' :
|
1140
1110
|
'scheduleWithRelative';
|
1141
1111
|
return new AnonymousObservable(function (observer) {
|
1142
|
-
return new CompositeDisposable(
|
1143
|
-
observer.onCompleted()
|
1144
|
-
|
1112
|
+
return new CompositeDisposable(
|
1113
|
+
scheduler[schedulerMethod](endTime, observer.onCompleted.bind(observer)),
|
1114
|
+
source.subscribe(observer));
|
1145
1115
|
});
|
1146
1116
|
};
|
1147
1117
|
|
@@ -1 +1 @@
|
|
1
|
-
(function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b){return new n(function(c){return b.scheduleWithAbsolute(a,function(){c.onNext(0),c.onCompleted()})})}function f(a,b,c){return new n(function(d){var e=0,f=a,g=z(b);return c.scheduleRecursiveWithAbsolute(f,function(a){if(g>0){var b=c.now();f+=g,b>=f&&(f=b+g)}d.onNext(e++),a(f)})})}function g(a,b){return new n(function(c){return b.scheduleWithRelative(z(a),function(){c.onNext(0),c.onCompleted()})})}function h(a,b,c){return a===b?new n(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):o(function(){return f(c.now()+a,b,c)})}function i(a,b,c){return new n(function(d){var e,f=!1,g=new u,h=null,i=[],j=!1;return e=a.materialize().timestamp(c).subscribe(function(a){var e,k;"E"===a.value.kind?(i=[],i.push(a),h=a.value.exception,k=!j):(i.push({value:a.value,timestamp:a.timestamp+b}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new t,g.setDisposable(e),e.setDisposable(c.scheduleRecursiveWithRelative(b,function(a){var b,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-c.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-c.now())):f=!1,b=h,j=!1,null!==b?d.onError(b):k&&a(e)}}))))}),new v(e,g)})}function j(a,b,c){return o(function(){return i(a,b-c.now(),c)})}function k(a,b){return new n(function(c){function d(){g&&(g=!1,c.onNext(f)),e&&c.onCompleted()}var e,f,g;return new v(a.subscribe(function(a){g=!0,f=a},c.onError.bind(c),function(){e=!0}),b.subscribe(d,c.onError.bind(c),d))})}var l=c.Observable,m=l.prototype,n=c.AnonymousObservable,o=l.defer,p=l.empty,q=l.never,r=l.throwException,s=(l.fromArray,c.Scheduler.timeout),t=c.SingleAssignmentDisposable,u=c.SerialDisposable,v=c.CompositeDisposable,w=c.RefCountDisposable,x=c.Subject,y=c.internals.addRef,z=c.Scheduler.normalize,A=c.helpers,B=A.isPromise,C=A.isScheduler,D=l.fromPromise,E=(A.notDefined,l.interval=function(a,b){return h(a,a,C(b)?b:s)}),F=l.timer=function(a,b,c){var i;return C(c)||(c=s),b!==d&&"number"==typeof b?i=b:b!==d&&"object"==typeof b&&(c=b),a instanceof Date&&i===d?e(a.getTime(),c):a instanceof Date&&i!==d?(i=b,f(a.getTime(),i,c)):i===d?g(a,c):h(a,i,c)};return m.delay=function(a,b){return C(b)||(b=s),a instanceof Date?j(this,a.getTime(),b):i(this,a,b)},m.throttle=function(a,b){return C(b)||(b=s),this.throttleWithSelector(function(){return F(a,b)})},m.windowWithTime=function(a,b,c){var d,e=this;return null==b&&(d=a),C(c)||(c=s),"number"==typeof b?d=b:"object"==typeof b&&(d=a,c=b),new n(function(b){function f(){var a=new t,e=!1,g=!1;l.setDisposable(a),j===i?(e=!0,g=!0):i>j?e=!0:g=!0;var n=e?j:i,o=n-m;m=n,e&&(j+=d),g&&(i+=d),a.setDisposable(c.scheduleWithRelative(o,function(){var a;g&&(a=new x,k.push(a),b.onNext(y(a,h))),e&&(a=k.shift(),a.onCompleted()),f()}))}var g,h,i=d,j=a,k=[],l=new u,m=0;return g=new v(l),h=new w(g),k.push(new x),b.onNext(y(k[0],h)),f(),g.add(e.subscribe(function(a){var b,c;for(b=0,c=k.length;c>b;b++)k[b].onNext(a)},function(a){var c,d;for(c=0,d=k.length;d>c;c++)k[c].onError(a);b.onError(a)},function(){var a,c;for(a=0,c=k.length;c>a;a++)k[a].onCompleted();b.onCompleted()})),h})},m.windowWithTimeOrCount=function(a,b,c){var d=this;return C(c)||(c=s),new n(function(e){function f(b){var d=new t;timerD.setDisposable(d),d.setDisposable(c.scheduleWithRelative(a,function(){var a;b===windowId&&(i=0,a=++windowId,j.onCompleted(),j=new x,e.onNext(y(j,h)),f(a))}))}var f,g,h,i=0,j=new x;return timerD=new u,windowId=0,g=new v(timerD),h=new w(g),e.onNext(y(j,h)),f(0),g.add(d.subscribe(function(a){var c=0,d=!1;j.onNext(a),i++,i===b&&(d=!0,i=0,c=++windowId,j.onCompleted(),j=new x,e.onNext(y(j,h))),d&&f(c)},function(a){j.onError(a),e.onError(a)},function(){j.onCompleted(),e.onCompleted()})),h})},m.bufferWithTime=function(){return this.windowWithTime.apply(this,arguments).selectMany(function(a){return a.toArray()})},m.bufferWithTimeOrCount=function(a,b,c){return this.windowWithTimeOrCount(a,b,c).selectMany(function(a){return a.toArray()})},m.timeInterval=function(a){var b=this;return C(a)||(a=s),o(function(){var c=a.now();return b.map(function(b){var d=a.now(),e=d-c;return c=d,{value:b,interval:e}})})},m.timestamp=function(a){return C(a)||(a=s),this.map(function(b){return{value:b,timestamp:a.now()}})},m.sample=function(a,b){return C(b)||(b=s),"number"==typeof a?k(this,E(a,b)):k(this,a)},m.timeout=function(a,b,c){b||(b=r(new Error("Timeout"))),C(c)||(c=s);var d=this,e=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new n(function(f){var g=0,h=new t,i=new u,j=!1,k=new u;i.setDisposable(h);var l=function(){var d=g;k.setDisposable(c[e](a,function(){g===d&&(B(b)&&(b=D(b)),i.setDisposable(b.subscribe(f)))}))};return l(),h.setDisposable(d.subscribe(function(a){j||(g++,f.onNext(a),l())},function(a){j||(g++,f.onError(a))},function(){j||(g++,f.onCompleted())})),new v(i,k)})},l.generateWithAbsoluteTime=function(a,b,c,d,e,f){return C(f)||(f=s),new n(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithAbsolute(f.now(),function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return void g.onError(f)}k?a(i):g.onCompleted()})})},l.generateWithRelativeTime=function(a,b,c,d,e,f){return C(f)||(f=s),new n(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithRelative(0,function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return void g.onError(f)}k?a(i):g.onCompleted()})})},m.delaySubscription=function(a,b){return this.delayWithSelector(F(a,C(b)?b:s),p)},m.delayWithSelector=function(a,b){var c,d,e=this;return"function"==typeof a?d=a:(c=a,d=b),new n(function(a){var b=new v,f=!1,g=function(){f&&0===b.length&&a.onCompleted()},h=new u,i=function(){h.setDisposable(e.subscribe(function(c){var e;try{e=d(c)}catch(f){return void a.onError(f)}var h=new t;b.add(h),h.setDisposable(e.subscribe(function(){a.onNext(c),b.remove(h),g()},a.onError.bind(a),function(){a.onNext(c),b.remove(h),g()}))},a.onError.bind(a),function(){f=!0,h.dispose(),g()}))};return c?h.setDisposable(c.subscribe(function(){i()},a.onError.bind(a),function(){i()})):i(),new v(h,b)})},m.timeoutWithSelector=function(a,b,c){if(1===arguments.length){b=a;var a=q()}c||(c=r(new Error("Timeout")));var d=this;return new n(function(e){var f=new u,g=new u,h=new t;f.setDisposable(h);var i=0,j=!1,k=function(a){var b=i,d=function(){return i===b},h=new t;g.setDisposable(h),h.setDisposable(a.subscribe(function(){d()&&f.setDisposable(c.subscribe(e)),h.dispose()},function(a){d()&&e.onError(a)},function(){d()&&f.setDisposable(c.subscribe(e))}))};k(a);var l=function(){var a=!j;return a&&i++,a};return h.setDisposable(d.subscribe(function(a){if(l()){e.onNext(a);var c;try{c=b(a)}catch(d){return void e.onError(d)}k(c)}},function(a){l()&&e.onError(a)},function(){l()&&e.onCompleted()})),new v(f,g)})},m.throttleWithSelector=function(a){var b=this;return new n(function(c){var d,e=!1,f=new u,g=0,h=b.subscribe(function(b){var h;try{h=a(b)}catch(i){return void c.onError(i)}e=!0,d=b,g++;var j=g,k=new t;f.setDisposable(k),k.setDisposable(h.subscribe(function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()},c.onError.bind(c),function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()}))},function(a){f.dispose(),c.onError(a),e=!1,g++},function(){f.dispose(),e&&c.onNext(d),c.onCompleted(),e=!1,g++});return new v(h,f)})},m.skipLastWithTime=function(a,b){C(b)||(b=s);var c=this;return new n(function(d){var e=[];return c.subscribe(function(c){var f=b.now();for(e.push({interval:f,value:c});e.length>0&&f-e[0].interval>=a;)d.onNext(e.shift().value)},d.onError.bind(d),function(){for(var c=b.now();e.length>0&&c-e[0].interval>=a;)d.onNext(e.shift().value);d.onCompleted()})})},m.takeLastWithTime=function(a,b){var c=this;return C(b)||(b=s),new n(function(d){var e=[];return c.subscribe(function(c){var d=b.now();for(e.push({interval:d,value:c});e.length>0&&d-e[0].interval>=a;)e.shift()},d.onError.bind(d),function(){for(var c=b.now();e.length>0;){var f=e.shift();c-f.interval<=a&&d.onNext(f.value)}d.onCompleted()})})},m.takeLastBufferWithTime=function(a,b){var c=this;return C(b)||(b=s),new n(function(d){var e=[];return c.subscribe(function(c){var d=b.now();for(e.push({interval:d,value:c});e.length>0&&d-e[0].interval>=a;)e.shift()},d.onError.bind(d),function(){for(var c=b.now(),f=[];e.length>0;){var g=e.shift();c-g.interval<=a&&f.push(g.value)}d.onNext(f),d.onCompleted()})})},m.takeWithTime=function(a,b){var c=this;return C(b)||(b=s),new n(function(d){return new v(b.scheduleWithRelative(a,d.onCompleted.bind(d)),c.subscribe(d))})},m.skipWithTime=function(a,b){var c=this;return C(b)||(b=s),new n(function(d){var e=!1;return new v(b.scheduleWithRelative(a,function(){e=!0}),c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d)))})},m.skipUntilWithTime=function(a,b){C(b)||(b=s);var c=this,d=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new n(function(e){var f=!1;return new v(b[d](a,function(){f=!0}),c.subscribe(function(a){f&&e.onNext(a)},e.onError.bind(e),e.onCompleted.bind(e)))})},m.takeUntilWithTime=function(a,b){C(b)||(b=s);var c=this,d=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new n(function(e){return new v(b[d](a,function(){e.onCompleted()}),c.subscribe(e))})},c});
|
1
|
+
(function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b){return new n(function(c){return b.scheduleWithAbsolute(a,function(){c.onNext(0),c.onCompleted()})})}function f(a,b,c){return new n(function(d){var e=0,f=a,g=z(b);return c.scheduleRecursiveWithAbsolute(f,function(a){if(g>0){var b=c.now();f+=g,b>=f&&(f=b+g)}d.onNext(e++),a(f)})})}function g(a,b){return new n(function(c){return b.scheduleWithRelative(z(a),function(){c.onNext(0),c.onCompleted()})})}function h(a,b,c){return a===b?new n(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):o(function(){return f(c.now()+a,b,c)})}function i(a,b,c){return new n(function(d){var e,f=!1,g=new u,h=null,i=[],j=!1;return e=a.materialize().timestamp(c).subscribe(function(a){var e,k;"E"===a.value.kind?(i=[],i.push(a),h=a.value.exception,k=!j):(i.push({value:a.value,timestamp:a.timestamp+b}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new t,g.setDisposable(e),e.setDisposable(c.scheduleRecursiveWithRelative(b,function(a){var b,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-c.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-c.now())):f=!1,b=h,j=!1,null!==b?d.onError(b):k&&a(e)}}))))}),new v(e,g)})}function j(a,b,c){return o(function(){return i(a,b-c.now(),c)})}function k(a,b){return new n(function(c){function d(){g&&(g=!1,c.onNext(f)),e&&c.onCompleted()}var e,f,g;return new v(a.subscribe(function(a){g=!0,f=a},c.onError.bind(c),function(){e=!0}),b.subscribe(d,c.onError.bind(c),d))})}var l=c.Observable,m=l.prototype,n=c.AnonymousObservable,o=l.defer,p=l.empty,q=l.never,r=l.throwException,s=(l.fromArray,c.Scheduler.timeout),t=c.SingleAssignmentDisposable,u=c.SerialDisposable,v=c.CompositeDisposable,w=c.RefCountDisposable,x=c.Subject,y=c.internals.addRef,z=c.Scheduler.normalize,A=c.helpers,B=A.isPromise,C=A.isScheduler,D=l.fromPromise,E=(A.notDefined,l.interval=function(a,b){return h(a,a,C(b)?b:s)}),F=l.timer=function(a,b,c){var i;return C(c)||(c=s),b!==d&&"number"==typeof b?i=b:C(b)&&(c=b),a instanceof Date&&i===d?e(a.getTime(),c):a instanceof Date&&i!==d?(i=b,f(a.getTime(),i,c)):i===d?g(a,c):h(a,i,c)};return m.delay=function(a,b){return C(b)||(b=s),a instanceof Date?j(this,a.getTime(),b):i(this,a,b)},m.throttle=function(a,b){C(b)||(b=s);var c=this;return new n(function(d){var e,f=new u,g=!1,h=0,i=c.subscribe(function(c){g=!0,e=c,h++;var i=h,j=new t;f.setDisposable(j),j.setDisposable(b.scheduleWithRelative(a,function(){hasValue&&h===i&&d.onNext(e),g=!1}))},function(a){f.dispose(),d.onError(a),g=!1,h++},function(){f.dispose(),g&&d.onNext(e),d.onCompleted(),g=!1,h++});return new v(i,f)})},m.windowWithTime=function(a,b,c){var e,f=this;return b===d&&(e=a),C(c)||(c=s),"number"==typeof b?e=b:C(b)&&(e=a,c=b),new n(function(b){function d(){var a=new t,f=!1,g=!1;l.setDisposable(a),j===i?(f=!0,g=!0):i>j?f=!0:g=!0;var n=f?j:i,o=n-m;m=n,f&&(j+=e),g&&(i+=e),a.setDisposable(c.scheduleWithRelative(o,function(){var a;g&&(a=new x,k.push(a),b.onNext(y(a,h))),f&&(a=k.shift(),a.onCompleted()),d()}))}var g,h,i=e,j=a,k=[],l=new u,m=0;return g=new v(l),h=new w(g),k.push(new x),b.onNext(y(k[0],h)),d(),g.add(f.subscribe(function(a){for(var b=0,c=k.length;c>b;b++)k[b].onNext(a)},function(a){for(var c=0,d=k.length;d>c;c++)k[c].onError(a);b.onError(a)},function(){for(var a=0,c=k.length;c>a;a++)k[a].onCompleted();b.onCompleted()})),h})},m.windowWithTimeOrCount=function(a,b,c){var d=this;return C(c)||(c=s),new n(function(e){var f,g,h,i,j=0,k=new u,l=0;return g=new v(k),h=new w(g),f=function(b){var d=new t;k.setDisposable(d),d.setDisposable(c.scheduleWithRelative(a,function(){var a;b===l&&(j=0,a=++l,i.onCompleted(),i=new x,e.onNext(y(i,h)),f(a))}))},i=new x,e.onNext(y(i,h)),f(0),g.add(d.subscribe(function(a){var c=0,d=!1;i.onNext(a),j++,j===b&&(d=!0,j=0,c=++l,i.onCompleted(),i=new x,e.onNext(y(i,h))),d&&f(c)},function(a){i.onError(a),e.onError(a)},function(){i.onCompleted(),e.onCompleted()})),h})},m.bufferWithTime=function(){return this.windowWithTime.apply(this,arguments).selectMany(function(a){return a.toArray()})},m.bufferWithTimeOrCount=function(a,b,c){return this.windowWithTimeOrCount(a,b,c).selectMany(function(a){return a.toArray()})},m.timeInterval=function(a){var b=this;return C(a)||(a=s),o(function(){var c=a.now();return b.map(function(b){var d=a.now(),e=d-c;return c=d,{value:b,interval:e}})})},m.timestamp=function(a){return C(a)||(a=s),this.map(function(b){return{value:b,timestamp:a.now()}})},m.sample=function(a,b){return C(b)||(b=s),"number"==typeof a?k(this,E(a,b)):k(this,a)},m.timeout=function(a,b,c){b||(b=r(new Error("Timeout"))),C(c)||(c=s);var d=this,e=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new n(function(f){function g(){var d=h;l.setDisposable(c[e](a,function(){h===d&&(B(b)&&(b=D(b)),j.setDisposable(b.subscribe(f)))}))}var h=0,i=new t,j=new u,k=!1,l=new u;return j.setDisposable(i),g(),i.setDisposable(d.subscribe(function(a){k||(h++,f.onNext(a),g())},function(a){k||(h++,f.onError(a))},function(){k||(h++,f.onCompleted())})),new v(j,l)})},l.generateWithAbsoluteTime=function(a,b,c,d,e,f){return C(f)||(f=s),new n(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithAbsolute(f.now(),function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return void g.onError(f)}k?a(i):g.onCompleted()})})},l.generateWithRelativeTime=function(a,b,c,d,e,f){return C(f)||(f=s),new n(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithRelative(0,function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return void g.onError(f)}k?a(i):g.onCompleted()})})},m.delaySubscription=function(a,b){return this.delayWithSelector(F(a,C(b)?b:s),p)},m.delayWithSelector=function(a,b){var c,d,e=this;return"function"==typeof a?d=a:(c=a,d=b),new n(function(a){var b=new v,f=!1,g=function(){f&&0===b.length&&a.onCompleted()},h=new u,i=function(){h.setDisposable(e.subscribe(function(c){var e;try{e=d(c)}catch(f){return void a.onError(f)}var h=new t;b.add(h),h.setDisposable(e.subscribe(function(){a.onNext(c),b.remove(h),g()},a.onError.bind(a),function(){a.onNext(c),b.remove(h),g()}))},a.onError.bind(a),function(){f=!0,h.dispose(),g()}))};return c?h.setDisposable(c.subscribe(function(){i()},a.onError.bind(a),function(){i()})):i(),new v(h,b)})},m.timeoutWithSelector=function(a,b,c){1===arguments.length&&(b=a,a=q()),c||(c=r(new Error("Timeout")));var d=this;return new n(function(e){function f(a){function b(){return k===d}var d=k,f=new t;i.setDisposable(f),f.setDisposable(a.subscribe(function(){b()&&h.setDisposable(c.subscribe(e)),f.dispose()},function(a){b()&&e.onError(a)},function(){b()&&h.setDisposable(c.subscribe(e))}))}function g(){var a=!l;return a&&k++,a}var h=new u,i=new u,j=new t;h.setDisposable(j);var k=0,l=!1;return f(a),j.setDisposable(d.subscribe(function(a){if(g()){e.onNext(a);var c;try{c=b(a)}catch(d){return void e.onError(d)}f(B(c)?D(c):c)}},function(a){g()&&e.onError(a)},function(){g()&&e.onCompleted()})),new v(h,i)})},m.throttleWithSelector=function(a){var b=this;return new n(function(c){var d,e=!1,f=new u,g=0,h=b.subscribe(function(b){var h;try{h=a(b)}catch(i){return void c.onError(i)}B(h)&&(h=D(h)),e=!0,d=b,g++;var j=g,k=new t;f.setDisposable(k),k.setDisposable(h.subscribe(function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()},c.onError.bind(c),function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()}))},function(a){f.dispose(),c.onError(a),e=!1,g++},function(){f.dispose(),e&&c.onNext(d),c.onCompleted(),e=!1,g++});return new v(h,f)})},m.skipLastWithTime=function(a,b){C(b)||(b=s);var c=this;return new n(function(d){var e=[];return c.subscribe(function(c){var f=b.now();for(e.push({interval:f,value:c});e.length>0&&f-e[0].interval>=a;)d.onNext(e.shift().value)},d.onError.bind(d),function(){for(var c=b.now();e.length>0&&c-e[0].interval>=a;)d.onNext(e.shift().value);d.onCompleted()})})},m.takeLastWithTime=function(a,b){var c=this;return C(b)||(b=s),new n(function(d){var e=[];return c.subscribe(function(c){var d=b.now();for(e.push({interval:d,value:c});e.length>0&&d-e[0].interval>=a;)e.shift()},d.onError.bind(d),function(){for(var c=b.now();e.length>0;){var f=e.shift();c-f.interval<=a&&d.onNext(f.value)}d.onCompleted()})})},m.takeLastBufferWithTime=function(a,b){var c=this;return C(b)||(b=s),new n(function(d){var e=[];return c.subscribe(function(c){var d=b.now();for(e.push({interval:d,value:c});e.length>0&&d-e[0].interval>=a;)e.shift()},d.onError.bind(d),function(){for(var c=b.now(),f=[];e.length>0;){var g=e.shift();c-g.interval<=a&&f.push(g.value)}d.onNext(f),d.onCompleted()})})},m.takeWithTime=function(a,b){var c=this;return C(b)||(b=s),new n(function(d){return new v(b.scheduleWithRelative(a,d.onCompleted.bind(d)),c.subscribe(d))})},m.skipWithTime=function(a,b){var c=this;return C(b)||(b=s),new n(function(d){var e=!1;return new v(b.scheduleWithRelative(a,function(){e=!0}),c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d)))})},m.skipUntilWithTime=function(a,b){C(b)||(b=s);var c=this,d=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new n(function(e){var f=!1;return new v(b[d](a,function(){f=!0}),c.subscribe(function(a){f&&e.onNext(a)},e.onError.bind(e),e.onCompleted.bind(e)))})},m.takeUntilWithTime=function(a,b){C(b)||(b=s);var c=this,d=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new n(function(e){return new v(b[d](a,e.onCompleted.bind(e)),c.subscribe(e))})},c});
|