rxjs-rails 2.3.10 → 2.3.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rxjs/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/rx.aggregates.js +120 -70
  4. data/vendor/assets/javascripts/rx.aggregates.min.js +3 -1
  5. data/vendor/assets/javascripts/rx.all.compat.js +1810 -1849
  6. data/vendor/assets/javascripts/rx.all.compat.min.js +5 -3
  7. data/vendor/assets/javascripts/rx.all.js +1776 -1815
  8. data/vendor/assets/javascripts/rx.all.min.js +5 -3
  9. data/vendor/assets/javascripts/rx.async.compat.js +45 -45
  10. data/vendor/assets/javascripts/rx.async.compat.min.js +3 -1
  11. data/vendor/assets/javascripts/rx.async.js +39 -39
  12. data/vendor/assets/javascripts/rx.async.min.js +3 -1
  13. data/vendor/assets/javascripts/rx.backpressure.js +21 -19
  14. data/vendor/assets/javascripts/rx.backpressure.min.js +3 -1
  15. data/vendor/assets/javascripts/rx.binding.js +90 -90
  16. data/vendor/assets/javascripts/rx.binding.min.js +3 -1
  17. data/vendor/assets/javascripts/rx.coincidence.js +184 -179
  18. data/vendor/assets/javascripts/rx.coincidence.min.js +3 -1
  19. data/vendor/assets/javascripts/rx.compat.js +1019 -1001
  20. data/vendor/assets/javascripts/rx.compat.min.js +4 -2
  21. data/vendor/assets/javascripts/rx.experimental.js +65 -64
  22. data/vendor/assets/javascripts/rx.experimental.min.js +3 -1
  23. data/vendor/assets/javascripts/rx.joinpatterns.js +265 -363
  24. data/vendor/assets/javascripts/rx.joinpatterns.min.js +3 -1
  25. data/vendor/assets/javascripts/rx.js +969 -951
  26. data/vendor/assets/javascripts/rx.lite.compat.js +1014 -1182
  27. data/vendor/assets/javascripts/rx.lite.compat.min.js +4 -2
  28. data/vendor/assets/javascripts/rx.lite.extras.js +101 -109
  29. data/vendor/assets/javascripts/rx.lite.extras.min.js +3 -1
  30. data/vendor/assets/javascripts/rx.lite.js +1008 -1176
  31. data/vendor/assets/javascripts/rx.lite.min.js +4 -2
  32. data/vendor/assets/javascripts/rx.min.js +4 -2
  33. data/vendor/assets/javascripts/rx.testing.js +196 -196
  34. data/vendor/assets/javascripts/rx.testing.min.js +3 -1
  35. data/vendor/assets/javascripts/rx.time.js +162 -178
  36. data/vendor/assets/javascripts/rx.time.min.js +3 -1
  37. data/vendor/assets/javascripts/rx.virtualtime.js +30 -30
  38. data/vendor/assets/javascripts/rx.virtualtime.min.js +3 -1
  39. metadata +2 -6
  40. data/vendor/assets/javascripts/rx.core.compat.js +0 -2548
  41. data/vendor/assets/javascripts/rx.core.compat.min.js +0 -1
  42. data/vendor/assets/javascripts/rx.core.js +0 -2430
  43. data/vendor/assets/javascripts/rx.core.min.js +0 -1
@@ -1,4 +1,4 @@
1
- // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
1
+ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
2
 
3
3
  ;(function (undefined) {
4
4
 
@@ -16,55 +16,55 @@
16
16
  freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
17
17
  moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
18
18
  freeGlobal = objectTypes[typeof global] && global;
19
-
19
+
20
20
  if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
21
21
  root = freeGlobal;
22
22
  }
23
23
 
24
- var Rx = {
25
- internals: {},
24
+ var Rx = {
25
+ internals: {},
26
26
  config: {
27
27
  Promise: root.Promise // Detect if promise exists
28
28
  },
29
29
  helpers: { }
30
30
  };
31
-
32
- // Defaults
33
- var noop = Rx.helpers.noop = function () { },
34
- notDefined = Rx.helpers.notDefined = function (x) { return typeof x === 'undefined'; },
35
- isScheduler = Rx.helpers.isScheduler = function (x) { return x instanceof Rx.Scheduler; },
36
- identity = Rx.helpers.identity = function (x) { return x; },
37
- pluck = Rx.helpers.pluck = function (property) { return function (x) { return x[property]; }; },
38
- just = Rx.helpers.just = function (value) { return function () { return value; }; },
39
- defaultNow = Rx.helpers.defaultNow = (function () { return !!Date.now ? Date.now : function () { return +new Date; }; }()),
40
- defaultComparer = Rx.helpers.defaultComparer = function (x, y) { return isEqual(x, y); },
41
- defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); },
42
- defaultKeySerializer = Rx.helpers.defaultKeySerializer = function (x) { return x.toString(); },
43
- defaultError = Rx.helpers.defaultError = function (err) { throw err; },
44
- isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.then === 'function'; },
45
- asArray = Rx.helpers.asArray = function () { return Array.prototype.slice.call(arguments); },
46
- not = Rx.helpers.not = function (a) { return !a; },
47
- isFunction = Rx.helpers.isFunction = (function () {
48
-
49
- var isFn = function (value) {
50
- return typeof value == 'function' || false;
51
- }
52
-
53
- // fallback for older versions of Chrome and Safari
54
- if (isFn(/x/)) {
55
- isFn = function(value) {
56
- return typeof value == 'function' && toString.call(value) == '[object Function]';
57
- };
58
- }
59
-
60
- return isFn;
61
- }());
62
-
63
- // Errors
64
- var sequenceContainsNoElements = 'Sequence contains no elements.';
65
- var argumentOutOfRange = 'Argument out of range';
66
- var objectDisposed = 'Object has been disposed';
67
- function checkDisposed() { if (this.isDisposed) { throw new Error(objectDisposed); } }
31
+
32
+ // Defaults
33
+ var noop = Rx.helpers.noop = function () { },
34
+ notDefined = Rx.helpers.notDefined = function (x) { return typeof x === 'undefined'; },
35
+ isScheduler = Rx.helpers.isScheduler = function (x) { return x instanceof Rx.Scheduler; },
36
+ identity = Rx.helpers.identity = function (x) { return x; },
37
+ pluck = Rx.helpers.pluck = function (property) { return function (x) { return x[property]; }; },
38
+ just = Rx.helpers.just = function (value) { return function () { return value; }; },
39
+ defaultNow = Rx.helpers.defaultNow = (function () { return !!Date.now ? Date.now : function () { return +new Date; }; }()),
40
+ defaultComparer = Rx.helpers.defaultComparer = function (x, y) { return isEqual(x, y); },
41
+ defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); },
42
+ defaultKeySerializer = Rx.helpers.defaultKeySerializer = function (x) { return x.toString(); },
43
+ defaultError = Rx.helpers.defaultError = function (err) { throw err; },
44
+ isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.then === 'function'; },
45
+ asArray = Rx.helpers.asArray = function () { return Array.prototype.slice.call(arguments); },
46
+ not = Rx.helpers.not = function (a) { return !a; },
47
+ isFunction = Rx.helpers.isFunction = (function () {
48
+
49
+ var isFn = function (value) {
50
+ return typeof value == 'function' || false;
51
+ }
52
+
53
+ // fallback for older versions of Chrome and Safari
54
+ if (isFn(/x/)) {
55
+ isFn = function(value) {
56
+ return typeof value == 'function' && toString.call(value) == '[object Function]';
57
+ };
58
+ }
59
+
60
+ return isFn;
61
+ }());
62
+
63
+ // Errors
64
+ var sequenceContainsNoElements = 'Sequence contains no elements.';
65
+ var argumentOutOfRange = 'Argument out of range';
66
+ var objectDisposed = 'Object has been disposed';
67
+ function checkDisposed() { if (this.isDisposed) { throw new Error(objectDisposed); } }
68
68
 
69
69
  // Shim in iterator support
70
70
  var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||
@@ -73,8 +73,10 @@
73
73
  if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {
74
74
  $iterator$ = '@@iterator';
75
75
  }
76
-
77
- var doneEnumerator = { done: true, value: undefined };
76
+
77
+ var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined };
78
+
79
+ Rx.iterator = $iterator$;
78
80
 
79
81
  /** `Object#toString` result shortcuts */
80
82
  var argsClass = '[object Arguments]',
@@ -89,7 +91,7 @@
89
91
  stringClass = '[object String]';
90
92
 
91
93
  var toString = Object.prototype.toString,
92
- hasOwnProperty = Object.prototype.hasOwnProperty,
94
+ hasOwnProperty = Object.prototype.hasOwnProperty,
93
95
  supportsArgsClass = toString.call(arguments) == argsClass, // For less <IE9 && FF<4
94
96
  suportNodeClass,
95
97
  errorProto = Error.prototype,
@@ -118,7 +120,7 @@
118
120
  props = [];
119
121
 
120
122
  ctor.prototype = { 'valueOf': 1, 'y': 1 };
121
- for (var key in new ctor) { props.push(key); }
123
+ for (var key in new ctor) { props.push(key); }
122
124
  for (key in arguments) { }
123
125
 
124
126
  // Detect if `name` or `message` properties of `Error.prototype` are enumerable by default.
@@ -192,7 +194,7 @@
192
194
  }
193
195
  }
194
196
  return object;
195
- }
197
+ }
196
198
 
197
199
  function internalForIn(object, callback) {
198
200
  return internalFor(object, callback, keysIn);
@@ -213,10 +215,10 @@
213
215
  isArguments = function(value) {
214
216
  return (value && typeof value == 'object') ? hasOwnProperty.call(value, 'callee') : false;
215
217
  };
216
- }
218
+ }
217
219
 
218
220
  var isEqual = Rx.internals.isEqual = function (x, y) {
219
- return deepEquals(x, y, [], []);
221
+ return deepEquals(x, y, [], []);
220
222
  };
221
223
 
222
224
  /** @private
@@ -357,47 +359,45 @@
357
359
 
358
360
  return result;
359
361
  }
360
- var slice = Array.prototype.slice;
361
- function argsOrArray(args, idx) {
362
- return args.length === 1 && Array.isArray(args[idx]) ?
363
- args[idx] :
364
- slice.call(args);
365
- }
366
- var hasProp = {}.hasOwnProperty;
367
362
 
368
- /** @private */
369
- var inherits = this.inherits = Rx.internals.inherits = function (child, parent) {
370
- function __() { this.constructor = child; }
371
- __.prototype = parent.prototype;
372
- child.prototype = new __();
373
- };
363
+ var slice = Array.prototype.slice;
364
+ function argsOrArray(args, idx) {
365
+ return args.length === 1 && Array.isArray(args[idx]) ?
366
+ args[idx] :
367
+ slice.call(args);
368
+ }
369
+ var hasProp = {}.hasOwnProperty;
374
370
 
375
- /** @private */
376
- var addProperties = Rx.internals.addProperties = function (obj) {
377
- var sources = slice.call(arguments, 1);
378
- for (var i = 0, len = sources.length; i < len; i++) {
379
- var source = sources[i];
380
- for (var prop in source) {
381
- obj[prop] = source[prop];
382
- }
383
- }
384
- };
371
+ var inherits = this.inherits = Rx.internals.inherits = function (child, parent) {
372
+ function __() { this.constructor = child; }
373
+ __.prototype = parent.prototype;
374
+ child.prototype = new __();
375
+ };
385
376
 
386
- // Rx Utils
387
- var addRef = Rx.internals.addRef = function (xs, r) {
388
- return new AnonymousObservable(function (observer) {
389
- return new CompositeDisposable(r.getDisposable(), xs.subscribe(observer));
390
- });
391
- };
377
+ var addProperties = Rx.internals.addProperties = function (obj) {
378
+ var sources = slice.call(arguments, 1);
379
+ for (var i = 0, len = sources.length; i < len; i++) {
380
+ var source = sources[i];
381
+ for (var prop in source) {
382
+ obj[prop] = source[prop];
383
+ }
384
+ }
385
+ };
392
386
 
393
- // Collection polyfills
394
- function arrayInitialize(count, factory) {
395
- var a = new Array(count);
396
- for (var i = 0; i < count; i++) {
397
- a[i] = factory();
398
- }
399
- return a;
387
+ // Rx Utils
388
+ var addRef = Rx.internals.addRef = function (xs, r) {
389
+ return new AnonymousObservable(function (observer) {
390
+ return new CompositeDisposable(r.getDisposable(), xs.subscribe(observer));
391
+ });
392
+ };
393
+
394
+ function arrayInitialize(count, factory) {
395
+ var a = new Array(count);
396
+ for (var i = 0; i < count; i++) {
397
+ a[i] = factory();
400
398
  }
399
+ return a;
400
+ }
401
401
 
402
402
  // Utilities
403
403
  if (!Function.prototype.bind) {
@@ -550,91 +550,92 @@ if (!Array.prototype.forEach) {
550
550
  };
551
551
  }
552
552
 
553
- // Collections
554
- function IndexedItem(id, value) {
555
- this.id = id;
556
- this.value = value;
557
- }
558
-
559
- IndexedItem.prototype.compareTo = function (other) {
560
- var c = this.value.compareTo(other.value);
561
- c === 0 && (c = this.id - other.id);
562
- return c;
563
- };
564
-
565
- // Priority Queue for Scheduling
566
- var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {
567
- this.items = new Array(capacity);
568
- this.length = 0;
569
- };
570
-
571
- var priorityProto = PriorityQueue.prototype;
572
- priorityProto.isHigherPriority = function (left, right) {
573
- return this.items[left].compareTo(this.items[right]) < 0;
574
- };
575
-
576
- priorityProto.percolate = function (index) {
577
- if (index >= this.length || index < 0) { return; }
578
- var parent = index - 1 >> 1;
579
- if (parent < 0 || parent === index) { return; }
580
- if (this.isHigherPriority(index, parent)) {
581
- var temp = this.items[index];
582
- this.items[index] = this.items[parent];
583
- this.items[parent] = temp;
584
- this.percolate(parent);
585
- }
586
- };
587
-
588
- priorityProto.heapify = function (index) {
589
- +index || (index = 0);
590
- if (index >= this.length || index < 0) { return; }
591
- var left = 2 * index + 1,
592
- right = 2 * index + 2,
593
- first = index;
594
- if (left < this.length && this.isHigherPriority(left, first)) {
595
- first = left;
596
- }
597
- if (right < this.length && this.isHigherPriority(right, first)) {
598
- first = right;
599
- }
600
- if (first !== index) {
601
- var temp = this.items[index];
602
- this.items[index] = this.items[first];
603
- this.items[first] = temp;
604
- this.heapify(first);
605
- }
606
- };
607
-
608
- priorityProto.peek = function () { return this.items[0].value; };
609
-
610
- priorityProto.removeAt = function (index) {
611
- this.items[index] = this.items[--this.length];
612
- delete this.items[this.length];
613
- this.heapify();
614
- };
615
-
616
- priorityProto.dequeue = function () {
617
- var result = this.peek();
618
- this.removeAt(0);
619
- return result;
620
- };
621
-
622
- priorityProto.enqueue = function (item) {
623
- var index = this.length++;
624
- this.items[index] = new IndexedItem(PriorityQueue.count++, item);
625
- this.percolate(index);
626
- };
627
-
628
- priorityProto.remove = function (item) {
629
- for (var i = 0; i < this.length; i++) {
630
- if (this.items[i].value === item) {
631
- this.removeAt(i);
632
- return true;
633
- }
634
- }
635
- return false;
636
- };
553
+ // Collections
554
+ function IndexedItem(id, value) {
555
+ this.id = id;
556
+ this.value = value;
557
+ }
558
+
559
+ IndexedItem.prototype.compareTo = function (other) {
560
+ var c = this.value.compareTo(other.value);
561
+ c === 0 && (c = this.id - other.id);
562
+ return c;
563
+ };
564
+
565
+ // Priority Queue for Scheduling
566
+ var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {
567
+ this.items = new Array(capacity);
568
+ this.length = 0;
569
+ };
570
+
571
+ var priorityProto = PriorityQueue.prototype;
572
+ priorityProto.isHigherPriority = function (left, right) {
573
+ return this.items[left].compareTo(this.items[right]) < 0;
574
+ };
575
+
576
+ priorityProto.percolate = function (index) {
577
+ if (index >= this.length || index < 0) { return; }
578
+ var parent = index - 1 >> 1;
579
+ if (parent < 0 || parent === index) { return; }
580
+ if (this.isHigherPriority(index, parent)) {
581
+ var temp = this.items[index];
582
+ this.items[index] = this.items[parent];
583
+ this.items[parent] = temp;
584
+ this.percolate(parent);
585
+ }
586
+ };
587
+
588
+ priorityProto.heapify = function (index) {
589
+ +index || (index = 0);
590
+ if (index >= this.length || index < 0) { return; }
591
+ var left = 2 * index + 1,
592
+ right = 2 * index + 2,
593
+ first = index;
594
+ if (left < this.length && this.isHigherPriority(left, first)) {
595
+ first = left;
596
+ }
597
+ if (right < this.length && this.isHigherPriority(right, first)) {
598
+ first = right;
599
+ }
600
+ if (first !== index) {
601
+ var temp = this.items[index];
602
+ this.items[index] = this.items[first];
603
+ this.items[first] = temp;
604
+ this.heapify(first);
605
+ }
606
+ };
607
+
608
+ priorityProto.peek = function () { return this.items[0].value; };
609
+
610
+ priorityProto.removeAt = function (index) {
611
+ this.items[index] = this.items[--this.length];
612
+ delete this.items[this.length];
613
+ this.heapify();
614
+ };
615
+
616
+ priorityProto.dequeue = function () {
617
+ var result = this.peek();
618
+ this.removeAt(0);
619
+ return result;
620
+ };
621
+
622
+ priorityProto.enqueue = function (item) {
623
+ var index = this.length++;
624
+ this.items[index] = new IndexedItem(PriorityQueue.count++, item);
625
+ this.percolate(index);
626
+ };
627
+
628
+ priorityProto.remove = function (item) {
629
+ for (var i = 0; i < this.length; i++) {
630
+ if (this.items[i].value === item) {
631
+ this.removeAt(i);
632
+ return true;
633
+ }
634
+ }
635
+ return false;
636
+ };
637
637
  PriorityQueue.count = 0;
638
+
638
639
  /**
639
640
  * Represents a group of disposable resources that are disposed together.
640
641
  * @constructor
@@ -650,7 +651,7 @@ if (!Array.prototype.forEach) {
650
651
  /**
651
652
  * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.
652
653
  * @param {Mixed} item Disposable to add.
653
- */
654
+ */
654
655
  CompositeDisposablePrototype.add = function (item) {
655
656
  if (this.isDisposed) {
656
657
  item.dispose();
@@ -680,7 +681,7 @@ if (!Array.prototype.forEach) {
680
681
  };
681
682
 
682
683
  /**
683
- * Disposes all disposables in the group and removes them from the group.
684
+ * Disposes all disposables in the group and removes them from the group.
684
685
  */
685
686
  CompositeDisposablePrototype.dispose = function () {
686
687
  if (!this.isDisposed) {
@@ -698,15 +699,15 @@ if (!Array.prototype.forEach) {
698
699
  /**
699
700
  * Converts the existing CompositeDisposable to an array of disposables
700
701
  * @returns {Array} An array of disposable objects.
701
- */
702
+ */
702
703
  CompositeDisposablePrototype.toArray = function () {
703
704
  return this.disposables.slice(0);
704
705
  };
705
-
706
+
706
707
  /**
707
708
  * Provides a set of static methods for creating Disposables.
708
709
  *
709
- * @constructor
710
+ * @constructor
710
711
  * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
711
712
  */
712
713
  var Disposable = Rx.Disposable = function (action) {
@@ -714,7 +715,7 @@ if (!Array.prototype.forEach) {
714
715
  this.action = action || noop;
715
716
  };
716
717
 
717
- /** Performs the task of cleaning up resources. */
718
+ /** Performs the task of cleaning up resources. */
718
719
  Disposable.prototype.dispose = function () {
719
720
  if (!this.isDisposed) {
720
721
  this.action();
@@ -729,8 +730,8 @@ if (!Array.prototype.forEach) {
729
730
  */
730
731
  var disposableCreate = Disposable.create = function (action) { return new Disposable(action); };
731
732
 
732
- /**
733
- * Gets the disposable that does nothing when disposed.
733
+ /**
734
+ * Gets the disposable that does nothing when disposed.
734
735
  */
735
736
  var disposableEmpty = Disposable.empty = { dispose: noop };
736
737
 
@@ -753,7 +754,7 @@ if (!Array.prototype.forEach) {
753
754
  /**
754
755
  * Sets the underlying disposable.
755
756
  * @param {Disposable} value The new underlying disposable.
756
- */
757
+ */
757
758
  booleanDisposablePrototype.setDisposable = function (value) {
758
759
  var shouldDispose = this.isDisposed, old;
759
760
  if (!shouldDispose) {
@@ -764,7 +765,7 @@ if (!Array.prototype.forEach) {
764
765
  shouldDispose && value && value.dispose();
765
766
  };
766
767
 
767
- /**
768
+ /**
768
769
  * Disposes the underlying disposable as well as all future replacements.
769
770
  */
770
771
  booleanDisposablePrototype.dispose = function () {
@@ -780,9 +781,10 @@ if (!Array.prototype.forEach) {
780
781
  return BooleanDisposable;
781
782
  }());
782
783
  var SerialDisposable = Rx.SerialDisposable = SingleAssignmentDisposable;
784
+
783
785
  /**
784
786
  * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.
785
- */
787
+ */
786
788
  var RefCountDisposable = Rx.RefCountDisposable = (function () {
787
789
 
788
790
  function InnerDisposable(disposable) {
@@ -816,8 +818,8 @@ if (!Array.prototype.forEach) {
816
818
  this.count = 0;
817
819
  }
818
820
 
819
- /**
820
- * Disposes the underlying disposable only when all dependent disposables have been disposed
821
+ /**
822
+ * Disposes the underlying disposable only when all dependent disposables have been disposed
821
823
  */
822
824
  RefCountDisposable.prototype.dispose = function () {
823
825
  if (!this.isDisposed) {
@@ -832,9 +834,9 @@ if (!Array.prototype.forEach) {
832
834
  };
833
835
 
834
836
  /**
835
- * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.
837
+ * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.
836
838
  * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime.
837
- */
839
+ */
838
840
  RefCountDisposable.prototype.getDisposable = function () {
839
841
  return this.isDisposed ? disposableEmpty : new InnerDisposable(this);
840
842
  };
@@ -842,46 +844,46 @@ if (!Array.prototype.forEach) {
842
844
  return RefCountDisposable;
843
845
  })();
844
846
 
845
- function ScheduledDisposable(scheduler, disposable) {
846
- this.scheduler = scheduler;
847
- this.disposable = disposable;
848
- this.isDisposed = false;
849
- }
850
-
851
- ScheduledDisposable.prototype.dispose = function () {
852
- var parent = this;
853
- this.scheduler.schedule(function () {
854
- if (!parent.isDisposed) {
855
- parent.isDisposed = true;
856
- parent.disposable.dispose();
857
- }
858
- });
859
- };
860
-
861
- var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
862
- this.scheduler = scheduler;
863
- this.state = state;
864
- this.action = action;
865
- this.dueTime = dueTime;
866
- this.comparer = comparer || defaultSubComparer;
867
- this.disposable = new SingleAssignmentDisposable();
868
- }
869
-
870
- ScheduledItem.prototype.invoke = function () {
871
- this.disposable.setDisposable(this.invokeCore());
872
- };
873
-
874
- ScheduledItem.prototype.compareTo = function (other) {
875
- return this.comparer(this.dueTime, other.dueTime);
876
- };
877
-
878
- ScheduledItem.prototype.isCancelled = function () {
879
- return this.disposable.isDisposed;
880
- };
881
-
882
- ScheduledItem.prototype.invokeCore = function () {
883
- return this.action(this.scheduler, this.state);
884
- };
847
+ function ScheduledDisposable(scheduler, disposable) {
848
+ this.scheduler = scheduler;
849
+ this.disposable = disposable;
850
+ this.isDisposed = false;
851
+ }
852
+
853
+ ScheduledDisposable.prototype.dispose = function () {
854
+ var parent = this;
855
+ this.scheduler.schedule(function () {
856
+ if (!parent.isDisposed) {
857
+ parent.isDisposed = true;
858
+ parent.disposable.dispose();
859
+ }
860
+ });
861
+ };
862
+
863
+ var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
864
+ this.scheduler = scheduler;
865
+ this.state = state;
866
+ this.action = action;
867
+ this.dueTime = dueTime;
868
+ this.comparer = comparer || defaultSubComparer;
869
+ this.disposable = new SingleAssignmentDisposable();
870
+ }
871
+
872
+ ScheduledItem.prototype.invoke = function () {
873
+ this.disposable.setDisposable(this.invokeCore());
874
+ };
875
+
876
+ ScheduledItem.prototype.compareTo = function (other) {
877
+ return this.comparer(this.dueTime, other.dueTime);
878
+ };
879
+
880
+ ScheduledItem.prototype.isCancelled = function () {
881
+ return this.disposable.isDisposed;
882
+ };
883
+
884
+ ScheduledItem.prototype.invokeCore = function () {
885
+ return this.action(this.scheduler, this.state);
886
+ };
885
887
 
886
888
  /** Provides a set of static properties to access commonly used schedulers. */
887
889
  var Scheduler = Rx.Scheduler = (function () {
@@ -949,7 +951,7 @@ if (!Array.prototype.forEach) {
949
951
  var schedulerProto = Scheduler.prototype;
950
952
 
951
953
  /**
952
- * Schedules an action to be executed.
954
+ * Schedules an action to be executed.
953
955
  * @param {Function} action Action to execute.
954
956
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
955
957
  */
@@ -958,7 +960,7 @@ if (!Array.prototype.forEach) {
958
960
  };
959
961
 
960
962
  /**
961
- * Schedules an action to be executed.
963
+ * Schedules an action to be executed.
962
964
  * @param state State passed to the action to be executed.
963
965
  * @param {Function} action Action to be executed.
964
966
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
@@ -968,7 +970,7 @@ if (!Array.prototype.forEach) {
968
970
  };
969
971
 
970
972
  /**
971
- * Schedules an action to be executed after the specified relative due time.
973
+ * Schedules an action to be executed after the specified relative due time.
972
974
  * @param {Function} action Action to execute.
973
975
  * @param {Number} dueTime Relative time after which to execute the action.
974
976
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
@@ -978,7 +980,7 @@ if (!Array.prototype.forEach) {
978
980
  };
979
981
 
980
982
  /**
981
- * Schedules an action to be executed after dueTime.
983
+ * Schedules an action to be executed after dueTime.
982
984
  * @param state State passed to the action to be executed.
983
985
  * @param {Function} action Action to be executed.
984
986
  * @param {Number} dueTime Relative time after which to execute the action.
@@ -989,7 +991,7 @@ if (!Array.prototype.forEach) {
989
991
  };
990
992
 
991
993
  /**
992
- * Schedules an action to be executed at the specified absolute due time.
994
+ * Schedules an action to be executed at the specified absolute due time.
993
995
  * @param {Function} action Action to execute.
994
996
  * @param {Number} dueTime Absolute time at which to execute the action.
995
997
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
@@ -999,7 +1001,7 @@ if (!Array.prototype.forEach) {
999
1001
  };
1000
1002
 
1001
1003
  /**
1002
- * Schedules an action to be executed at dueTime.
1004
+ * Schedules an action to be executed at dueTime.
1003
1005
  * @param {Mixed} state State passed to the action to be executed.
1004
1006
  * @param {Function} action Action to be executed.
1005
1007
  * @param {Number}dueTime Absolute time at which to execute the action.
@@ -1016,7 +1018,7 @@ if (!Array.prototype.forEach) {
1016
1018
  * Normalizes the specified TimeSpan value to a positive value.
1017
1019
  * @param {Number} timeSpan The time span value to normalize.
1018
1020
  * @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0
1019
- */
1021
+ */
1020
1022
  Scheduler.normalize = function (timeSpan) {
1021
1023
  timeSpan < 0 && (timeSpan = 0);
1022
1024
  return timeSpan;
@@ -1026,7 +1028,7 @@ if (!Array.prototype.forEach) {
1026
1028
  }());
1027
1029
 
1028
1030
  var normalizeTime = Scheduler.normalize;
1029
-
1031
+
1030
1032
  (function (schedulerProto) {
1031
1033
  function invokeRecImmediate(scheduler, pair) {
1032
1034
  var state = pair.first, action = pair.second, group = new CompositeDisposable(),
@@ -1091,7 +1093,7 @@ if (!Array.prototype.forEach) {
1091
1093
  };
1092
1094
 
1093
1095
  /**
1094
- * Schedules an action to be executed recursively.
1096
+ * Schedules an action to be executed recursively.
1095
1097
  * @param {Mixed} state State passed to the action to be executed.
1096
1098
  * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state.
1097
1099
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
@@ -1101,7 +1103,7 @@ if (!Array.prototype.forEach) {
1101
1103
  };
1102
1104
 
1103
1105
  /**
1104
- * Schedules an action to be executed recursively after a specified relative due time.
1106
+ * Schedules an action to be executed recursively after a specified relative due time.
1105
1107
  * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified relative time.
1106
1108
  * @param {Number}dueTime Relative time after which to execute the action for the first time.
1107
1109
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
@@ -1111,7 +1113,7 @@ if (!Array.prototype.forEach) {
1111
1113
  };
1112
1114
 
1113
1115
  /**
1114
- * Schedules an action to be executed recursively after a specified relative due time.
1116
+ * Schedules an action to be executed recursively after a specified relative due time.
1115
1117
  * @param {Mixed} state State passed to the action to be executed.
1116
1118
  * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.
1117
1119
  * @param {Number}dueTime Relative time after which to execute the action for the first time.
@@ -1124,7 +1126,7 @@ if (!Array.prototype.forEach) {
1124
1126
  };
1125
1127
 
1126
1128
  /**
1127
- * Schedules an action to be executed recursively at a specified absolute due time.
1129
+ * Schedules an action to be executed recursively at a specified absolute due time.
1128
1130
  * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified absolute time.
1129
1131
  * @param {Number}dueTime Absolute time at which to execute the action for the first time.
1130
1132
  * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
@@ -1134,7 +1136,7 @@ if (!Array.prototype.forEach) {
1134
1136
  };
1135
1137
 
1136
1138
  /**
1137
- * Schedules an action to be executed recursively at a specified absolute due time.
1139
+ * Schedules an action to be executed recursively at a specified absolute due time.
1138
1140
  * @param {Mixed} state State passed to the action to be executed.
1139
1141
  * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.
1140
1142
  * @param {Number}dueTime Absolute time at which to execute the action for the first time.
@@ -1144,23 +1146,23 @@ if (!Array.prototype.forEach) {
1144
1146
  return this._scheduleAbsolute({ first: state, second: action }, dueTime, function (s, p) {
1145
1147
  return invokeRecDate(s, p, 'scheduleWithAbsoluteAndState');
1146
1148
  });
1147
- };
1149
+ };
1148
1150
  }(Scheduler.prototype));
1149
1151
 
1150
1152
  (function (schedulerProto) {
1151
1153
 
1152
1154
  /**
1153
- * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.
1155
+ * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.
1154
1156
  * @param {Number} period Period for running the work periodically.
1155
1157
  * @param {Function} action Action to be executed.
1156
1158
  * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).
1157
- */
1159
+ */
1158
1160
  Scheduler.prototype.schedulePeriodic = function (period, action) {
1159
1161
  return this.schedulePeriodicWithState(null, period, action);
1160
1162
  };
1161
1163
 
1162
1164
  /**
1163
- * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.
1165
+ * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.
1164
1166
  * @param {Mixed} state Initial state passed to the action upon the first iteration.
1165
1167
  * @param {Number} period Period for running the work periodically.
1166
1168
  * @param {Function} action Action to be executed, potentially updating the state.
@@ -1169,7 +1171,7 @@ if (!Array.prototype.forEach) {
1169
1171
  Scheduler.prototype.schedulePeriodicWithState = function(state, period, action) {
1170
1172
  if (typeof root.setInterval === 'undefined') { throw new Error('Periodic scheduling not supported.'); }
1171
1173
  var s = state;
1172
-
1174
+
1173
1175
  var id = root.setInterval(function () {
1174
1176
  s = action(s);
1175
1177
  }, period);
@@ -1180,68 +1182,68 @@ if (!Array.prototype.forEach) {
1180
1182
  };
1181
1183
 
1182
1184
  }(Scheduler.prototype));
1183
-
1185
+
1184
1186
  (function (schedulerProto) {
1185
1187
  /**
1186
- * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions.
1188
+ * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions.
1187
1189
  * @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false.
1188
1190
  * @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling.
1189
- */
1191
+ */
1190
1192
  schedulerProto.catchError = schedulerProto['catch'] = function (handler) {
1191
1193
  return new CatchScheduler(this, handler);
1192
1194
  };
1193
- }(Scheduler.prototype));
1194
-
1195
- var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
1196
- function tick(command, recurse) {
1197
- recurse(0, this._period);
1198
- try {
1199
- this._state = this._action(this._state);
1200
- } catch (e) {
1201
- this._cancel.dispose();
1202
- throw e;
1203
- }
1204
- }
1205
-
1206
- function SchedulePeriodicRecursive(scheduler, state, period, action) {
1207
- this._scheduler = scheduler;
1208
- this._state = state;
1209
- this._period = period;
1210
- this._action = action;
1211
- }
1212
-
1213
- SchedulePeriodicRecursive.prototype.start = function () {
1214
- var d = new SingleAssignmentDisposable();
1215
- this._cancel = d;
1216
- d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
1217
-
1218
- return d;
1219
- };
1220
-
1221
- return SchedulePeriodicRecursive;
1222
- }());
1223
-
1224
- /**
1225
- * Gets a scheduler that schedules work immediately on the current thread.
1226
- */
1227
- var immediateScheduler = Scheduler.immediate = (function () {
1228
-
1229
- function scheduleNow(state, action) { return action(this, state); }
1230
-
1231
- function scheduleRelative(state, dueTime, action) {
1232
- var dt = normalizeTime(dt);
1233
- while (dt - this.now() > 0) { }
1234
- return action(this, state);
1235
- }
1236
-
1237
- function scheduleAbsolute(state, dueTime, action) {
1238
- return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
1239
- }
1240
-
1241
- return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
1242
- }());
1243
-
1244
- /**
1195
+ }(Scheduler.prototype));
1196
+
1197
+ var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {
1198
+ function tick(command, recurse) {
1199
+ recurse(0, this._period);
1200
+ try {
1201
+ this._state = this._action(this._state);
1202
+ } catch (e) {
1203
+ this._cancel.dispose();
1204
+ throw e;
1205
+ }
1206
+ }
1207
+
1208
+ function SchedulePeriodicRecursive(scheduler, state, period, action) {
1209
+ this._scheduler = scheduler;
1210
+ this._state = state;
1211
+ this._period = period;
1212
+ this._action = action;
1213
+ }
1214
+
1215
+ SchedulePeriodicRecursive.prototype.start = function () {
1216
+ var d = new SingleAssignmentDisposable();
1217
+ this._cancel = d;
1218
+ d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));
1219
+
1220
+ return d;
1221
+ };
1222
+
1223
+ return SchedulePeriodicRecursive;
1224
+ }());
1225
+
1226
+ /**
1227
+ * Gets a scheduler that schedules work immediately on the current thread.
1228
+ */
1229
+ var immediateScheduler = Scheduler.immediate = (function () {
1230
+
1231
+ function scheduleNow(state, action) { return action(this, state); }
1232
+
1233
+ function scheduleRelative(state, dueTime, action) {
1234
+ var dt = normalizeTime(dt);
1235
+ while (dt - this.now() > 0) { }
1236
+ return action(this, state);
1237
+ }
1238
+
1239
+ function scheduleAbsolute(state, dueTime, action) {
1240
+ return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
1241
+ }
1242
+
1243
+ return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
1244
+ }());
1245
+
1246
+ /**
1245
1247
  * Gets a scheduler that schedules work as soon as possible on the current thread.
1246
1248
  */
1247
1249
  var currentThreadScheduler = Scheduler.currentThread = (function () {
@@ -1275,7 +1277,7 @@ if (!Array.prototype.forEach) {
1275
1277
  queue.enqueue(si);
1276
1278
  try {
1277
1279
  runTrampoline(queue);
1278
- } catch (e) {
1280
+ } catch (e) {
1279
1281
  throw e;
1280
1282
  } finally {
1281
1283
  queue = null;
@@ -1291,7 +1293,7 @@ if (!Array.prototype.forEach) {
1291
1293
  }
1292
1294
 
1293
1295
  var currentScheduler = new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
1294
-
1296
+
1295
1297
  currentScheduler.scheduleRequired = function () { return !queue; };
1296
1298
  currentScheduler.ensureTrampoline = function (action) {
1297
1299
  if (!queue) { this.schedule(action); } else { action(); }
@@ -1319,11 +1321,11 @@ if (!Array.prototype.forEach) {
1319
1321
  setTimeout: localSetTimeout,
1320
1322
  clearTimeout: localClearTimeout
1321
1323
  };
1322
- }());
1324
+ }());
1323
1325
  var localSetTimeout = localTimer.setTimeout,
1324
1326
  localClearTimeout = localTimer.clearTimeout;
1325
1327
 
1326
- (function () {
1328
+ (function () {
1327
1329
 
1328
1330
  var reNative = RegExp('^' +
1329
1331
  String(toString)
@@ -1339,7 +1341,7 @@ if (!Array.prototype.forEach) {
1339
1341
  function postMessageSupported () {
1340
1342
  // Ensure not in a worker
1341
1343
  if (!root.postMessage || root.importScripts) { return false; }
1342
- var isAsync = false,
1344
+ var isAsync = false,
1343
1345
  oldHandler = root.onmessage;
1344
1346
  // Test for async
1345
1347
  root.onmessage = function () { isAsync = true; };
@@ -1396,19 +1398,19 @@ if (!Array.prototype.forEach) {
1396
1398
  scheduleMethod = function (action) {
1397
1399
  var id = channelTaskId++;
1398
1400
  channelTasks[id] = action;
1399
- channel.port2.postMessage(id);
1401
+ channel.port2.postMessage(id);
1400
1402
  };
1401
1403
  } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {
1402
-
1404
+
1403
1405
  scheduleMethod = function (action) {
1404
1406
  var scriptElement = root.document.createElement('script');
1405
- scriptElement.onreadystatechange = function () {
1407
+ scriptElement.onreadystatechange = function () {
1406
1408
  action();
1407
1409
  scriptElement.onreadystatechange = null;
1408
1410
  scriptElement.parentNode.removeChild(scriptElement);
1409
- scriptElement = null;
1411
+ scriptElement = null;
1410
1412
  };
1411
- root.document.documentElement.appendChild(scriptElement);
1413
+ root.document.documentElement.appendChild(scriptElement);
1412
1414
  };
1413
1415
 
1414
1416
  } else {
@@ -1417,7 +1419,7 @@ if (!Array.prototype.forEach) {
1417
1419
  }
1418
1420
  }());
1419
1421
 
1420
- /**
1422
+ /**
1421
1423
  * Gets a scheduler that schedules work via a timed callback based upon platform.
1422
1424
  */
1423
1425
  var timeoutScheduler = Scheduler.timeout = (function () {
@@ -1545,14 +1547,14 @@ if (!Array.prototype.forEach) {
1545
1547
  * Represents a notification to an observer.
1546
1548
  */
1547
1549
  var Notification = Rx.Notification = (function () {
1548
- function Notification(kind, hasValue) {
1550
+ function Notification(kind, hasValue) {
1549
1551
  this.hasValue = hasValue == null ? false : hasValue;
1550
1552
  this.kind = kind;
1551
1553
  }
1552
1554
 
1553
1555
  /**
1554
1556
  * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.
1555
- *
1557
+ *
1556
1558
  * @memberOf Notification
1557
1559
  * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on..
1558
1560
  * @param {Function} onError Delegate to invoke for an OnError notification.
@@ -1567,7 +1569,7 @@ if (!Array.prototype.forEach) {
1567
1569
 
1568
1570
  /**
1569
1571
  * Returns an observable sequence with a single notification.
1570
- *
1572
+ *
1571
1573
  * @memberOf Notifications
1572
1574
  * @param {Scheduler} [scheduler] Scheduler to send out the notification calls on.
1573
1575
  * @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription.
@@ -1647,150 +1649,150 @@ if (!Array.prototype.forEach) {
1647
1649
  };
1648
1650
  }());
1649
1651
 
1650
- var Enumerator = Rx.internals.Enumerator = function (next) {
1651
- this._next = next;
1652
- };
1653
-
1654
- Enumerator.prototype.next = function () {
1655
- return this._next();
1656
- };
1657
-
1658
- Enumerator.prototype[$iterator$] = function () { return this; }
1659
-
1660
- var Enumerable = Rx.internals.Enumerable = function (iterator) {
1661
- this._iterator = iterator;
1662
- };
1663
-
1664
- Enumerable.prototype[$iterator$] = function () {
1665
- return this._iterator();
1666
- };
1667
-
1668
- Enumerable.prototype.concat = function () {
1669
- var sources = this;
1670
- return new AnonymousObservable(function (observer) {
1671
- var e;
1672
- try {
1673
- e = sources[$iterator$]();
1674
- } catch(err) {
1675
- observer.onError();
1676
- return;
1677
- }
1678
-
1679
- var isDisposed,
1680
- subscription = new SerialDisposable();
1681
- var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1682
- var currentItem;
1683
- if (isDisposed) { return; }
1684
-
1685
- try {
1686
- currentItem = e.next();
1687
- } catch (ex) {
1688
- observer.onError(ex);
1689
- return;
1690
- }
1691
-
1692
- if (currentItem.done) {
1693
- observer.onCompleted();
1694
- return;
1695
- }
1696
-
1697
- // Check if promise
1698
- var currentValue = currentItem.value;
1699
- isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1700
-
1701
- var d = new SingleAssignmentDisposable();
1702
- subscription.setDisposable(d);
1703
- d.setDisposable(currentValue.subscribe(
1704
- observer.onNext.bind(observer),
1705
- observer.onError.bind(observer),
1706
- function () { self(); })
1707
- );
1708
- });
1709
-
1710
- return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1711
- isDisposed = true;
1712
- }));
1713
- });
1714
- };
1715
-
1716
- Enumerable.prototype.catchException = function () {
1717
- var sources = this;
1718
- return new AnonymousObservable(function (observer) {
1719
- var e;
1720
- try {
1721
- e = sources[$iterator$]();
1722
- } catch(err) {
1723
- observer.onError();
1724
- return;
1725
- }
1726
-
1727
- var isDisposed,
1728
- lastException,
1729
- subscription = new SerialDisposable();
1730
- var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1731
- if (isDisposed) { return; }
1732
-
1733
- var currentItem;
1734
- try {
1735
- currentItem = e.next();
1736
- } catch (ex) {
1737
- observer.onError(ex);
1738
- return;
1739
- }
1740
-
1741
- if (currentItem.done) {
1742
- if (lastException) {
1743
- observer.onError(lastException);
1744
- } else {
1745
- observer.onCompleted();
1746
- }
1747
- return;
1748
- }
1749
-
1750
- // Check if promise
1751
- var currentValue = currentItem.value;
1752
- isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1753
-
1754
- var d = new SingleAssignmentDisposable();
1755
- subscription.setDisposable(d);
1756
- d.setDisposable(currentValue.subscribe(
1757
- observer.onNext.bind(observer),
1758
- function (exn) {
1759
- lastException = exn;
1760
- self();
1761
- },
1762
- observer.onCompleted.bind(observer)));
1763
- });
1764
- return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1765
- isDisposed = true;
1766
- }));
1767
- });
1768
- };
1769
-
1770
- var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {
1771
- if (repeatCount == null) { repeatCount = -1; }
1772
- return new Enumerable(function () {
1773
- var left = repeatCount;
1774
- return new Enumerator(function () {
1775
- if (left === 0) { return doneEnumerator; }
1776
- if (left > 0) { left--; }
1777
- return { done: false, value: value };
1778
- });
1779
- });
1780
- };
1781
-
1782
- var enumerableFor = Enumerable.forEach = function (source, selector, thisArg) {
1783
- selector || (selector = identity);
1784
- return new Enumerable(function () {
1785
- var index = -1;
1786
- return new Enumerator(
1787
- function () {
1788
- return ++index < source.length ?
1789
- { done: false, value: selector.call(thisArg, source[index], index, source) } :
1790
- doneEnumerator;
1791
- });
1792
- });
1793
- };
1652
+ var Enumerator = Rx.internals.Enumerator = function (next) {
1653
+ this._next = next;
1654
+ };
1655
+
1656
+ Enumerator.prototype.next = function () {
1657
+ return this._next();
1658
+ };
1659
+
1660
+ Enumerator.prototype[$iterator$] = function () { return this; }
1661
+
1662
+ var Enumerable = Rx.internals.Enumerable = function (iterator) {
1663
+ this._iterator = iterator;
1664
+ };
1665
+
1666
+ Enumerable.prototype[$iterator$] = function () {
1667
+ return this._iterator();
1668
+ };
1669
+
1670
+ Enumerable.prototype.concat = function () {
1671
+ var sources = this;
1672
+ return new AnonymousObservable(function (observer) {
1673
+ var e;
1674
+ try {
1675
+ e = sources[$iterator$]();
1676
+ } catch(err) {
1677
+ observer.onError();
1678
+ return;
1679
+ }
1680
+
1681
+ var isDisposed,
1682
+ subscription = new SerialDisposable();
1683
+ var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1684
+ var currentItem;
1685
+ if (isDisposed) { return; }
1686
+
1687
+ try {
1688
+ currentItem = e.next();
1689
+ } catch (ex) {
1690
+ observer.onError(ex);
1691
+ return;
1692
+ }
1693
+
1694
+ if (currentItem.done) {
1695
+ observer.onCompleted();
1696
+ return;
1697
+ }
1698
+
1699
+ // Check if promise
1700
+ var currentValue = currentItem.value;
1701
+ isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1702
+
1703
+ var d = new SingleAssignmentDisposable();
1704
+ subscription.setDisposable(d);
1705
+ d.setDisposable(currentValue.subscribe(
1706
+ observer.onNext.bind(observer),
1707
+ observer.onError.bind(observer),
1708
+ function () { self(); })
1709
+ );
1710
+ });
1711
+
1712
+ return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1713
+ isDisposed = true;
1714
+ }));
1715
+ });
1716
+ };
1717
+
1718
+ Enumerable.prototype.catchException = function () {
1719
+ var sources = this;
1720
+ return new AnonymousObservable(function (observer) {
1721
+ var e;
1722
+ try {
1723
+ e = sources[$iterator$]();
1724
+ } catch(err) {
1725
+ observer.onError();
1726
+ return;
1727
+ }
1728
+
1729
+ var isDisposed,
1730
+ lastException,
1731
+ subscription = new SerialDisposable();
1732
+ var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1733
+ if (isDisposed) { return; }
1734
+
1735
+ var currentItem;
1736
+ try {
1737
+ currentItem = e.next();
1738
+ } catch (ex) {
1739
+ observer.onError(ex);
1740
+ return;
1741
+ }
1742
+
1743
+ if (currentItem.done) {
1744
+ if (lastException) {
1745
+ observer.onError(lastException);
1746
+ } else {
1747
+ observer.onCompleted();
1748
+ }
1749
+ return;
1750
+ }
1751
+
1752
+ // Check if promise
1753
+ var currentValue = currentItem.value;
1754
+ isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1755
+
1756
+ var d = new SingleAssignmentDisposable();
1757
+ subscription.setDisposable(d);
1758
+ d.setDisposable(currentValue.subscribe(
1759
+ observer.onNext.bind(observer),
1760
+ function (exn) {
1761
+ lastException = exn;
1762
+ self();
1763
+ },
1764
+ observer.onCompleted.bind(observer)));
1765
+ });
1766
+ return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1767
+ isDisposed = true;
1768
+ }));
1769
+ });
1770
+ };
1771
+
1772
+ var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {
1773
+ if (repeatCount == null) { repeatCount = -1; }
1774
+ return new Enumerable(function () {
1775
+ var left = repeatCount;
1776
+ return new Enumerator(function () {
1777
+ if (left === 0) { return doneEnumerator; }
1778
+ if (left > 0) { left--; }
1779
+ return { done: false, value: value };
1780
+ });
1781
+ });
1782
+ };
1783
+
1784
+ var enumerableOf = Enumerable.of = function (source, selector, thisArg) {
1785
+ selector || (selector = identity);
1786
+ return new Enumerable(function () {
1787
+ var index = -1;
1788
+ return new Enumerator(
1789
+ function () {
1790
+ return ++index < source.length ?
1791
+ { done: false, value: selector.call(thisArg, source[index], index, source) } :
1792
+ doneEnumerator;
1793
+ });
1794
+ });
1795
+ };
1794
1796
 
1795
1797
  /**
1796
1798
  * Supports push-style iteration over an observable sequence.
@@ -1799,22 +1801,17 @@ if (!Array.prototype.forEach) {
1799
1801
 
1800
1802
  /**
1801
1803
  * Creates a notification callback from an observer.
1802
- *
1803
- * @param observer Observer object.
1804
1804
  * @returns The action that forwards its input notification to the underlying observer.
1805
1805
  */
1806
1806
  Observer.prototype.toNotifier = function () {
1807
1807
  var observer = this;
1808
- return function (n) {
1809
- return n.accept(observer);
1810
- };
1808
+ return function (n) { return n.accept(observer); };
1811
1809
  };
1812
1810
 
1813
1811
  /**
1814
1812
  * Hides the identity of an observer.
1815
-
1816
- * @returns An observer that hides the identity of the specified observer.
1817
- */
1813
+ * @returns An observer that hides the identity of the specified observer.
1814
+ */
1818
1815
  Observer.prototype.asObserver = function () {
1819
1816
  return new AnonymousObserver(this.onNext.bind(this), this.onError.bind(this), this.onCompleted.bind(this));
1820
1817
  };
@@ -1822,16 +1819,12 @@ if (!Array.prototype.forEach) {
1822
1819
  /**
1823
1820
  * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods.
1824
1821
  * If a violation is detected, an Error is thrown from the offending observer method call.
1825
- *
1826
1822
  * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer.
1827
- */
1823
+ */
1828
1824
  Observer.prototype.checked = function () { return new CheckedObserver(this); };
1829
1825
 
1830
1826
  /**
1831
1827
  * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions.
1832
- *
1833
- * @static
1834
- * @memberOf Observer
1835
1828
  * @param {Function} [onNext] Observer's OnNext action implementation.
1836
1829
  * @param {Function} [onError] Observer's OnError action implementation.
1837
1830
  * @param {Function} [onCompleted] Observer's OnCompleted action implementation.
@@ -1846,19 +1839,19 @@ if (!Array.prototype.forEach) {
1846
1839
 
1847
1840
  /**
1848
1841
  * Creates an observer from a notification callback.
1849
- *
1842
+ *
1850
1843
  * @static
1851
1844
  * @memberOf Observer
1852
1845
  * @param {Function} handler Action that handles a notification.
1853
1846
  * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.
1854
1847
  */
1855
- Observer.fromNotifier = function (handler) {
1848
+ Observer.fromNotifier = function (handler, thisArg) {
1856
1849
  return new AnonymousObserver(function (x) {
1857
- return handler(notificationCreateOnNext(x));
1858
- }, function (exception) {
1859
- return handler(notificationCreateOnError(exception));
1850
+ return handler.call(thisArg, notificationCreateOnNext(x));
1851
+ }, function (e) {
1852
+ return handler.call(thisArg, notificationCreateOnError(e));
1860
1853
  }, function () {
1861
- return handler(notificationCreateOnCompleted());
1854
+ return handler.call(thisArg, notificationCreateOnCompleted());
1862
1855
  });
1863
1856
  };
1864
1857
 
@@ -1870,117 +1863,109 @@ if (!Array.prototype.forEach) {
1870
1863
  Observer.notifyOn = function (scheduler) {
1871
1864
  return new ObserveOnObserver(scheduler, this);
1872
1865
  };
1873
-
1874
- /**
1875
- * Abstract base class for implementations of the Observer class.
1876
- * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.
1877
- */
1878
- var AbstractObserver = Rx.internals.AbstractObserver = (function (_super) {
1879
- inherits(AbstractObserver, _super);
1880
-
1881
- /**
1882
- * Creates a new observer in a non-stopped state.
1883
- *
1884
- * @constructor
1885
- */
1886
- function AbstractObserver() {
1887
- this.isStopped = false;
1888
- _super.call(this);
1889
- }
1890
-
1891
- /**
1892
- * Notifies the observer of a new element in the sequence.
1893
- *
1894
- * @memberOf AbstractObserver
1895
- * @param {Any} value Next element in the sequence.
1896
- */
1897
- AbstractObserver.prototype.onNext = function (value) {
1898
- if (!this.isStopped) {
1899
- this.next(value);
1900
- }
1901
- };
1902
-
1903
- /**
1904
- * Notifies the observer that an exception has occurred.
1905
- *
1906
- * @memberOf AbstractObserver
1907
- * @param {Any} error The error that has occurred.
1908
- */
1909
- AbstractObserver.prototype.onError = function (error) {
1910
- if (!this.isStopped) {
1911
- this.isStopped = true;
1912
- this.error(error);
1913
- }
1914
- };
1915
-
1916
- /**
1917
- * Notifies the observer of the end of the sequence.
1918
- */
1919
- AbstractObserver.prototype.onCompleted = function () {
1920
- if (!this.isStopped) {
1921
- this.isStopped = true;
1922
- this.completed();
1923
- }
1924
- };
1925
-
1926
- /**
1927
- * Disposes the observer, causing it to transition to the stopped state.
1928
- */
1929
- AbstractObserver.prototype.dispose = function () {
1930
- this.isStopped = true;
1931
- };
1932
-
1933
- AbstractObserver.prototype.fail = function (e) {
1934
- if (!this.isStopped) {
1935
- this.isStopped = true;
1936
- this.error(e);
1937
- return true;
1938
- }
1939
-
1940
- return false;
1941
- };
1942
-
1943
- return AbstractObserver;
1944
- }(Observer));
1945
1866
 
1946
1867
  /**
1947
- * Class to create an Observer instance from delegate-based implementations of the on* methods.
1868
+ * Abstract base class for implementations of the Observer class.
1869
+ * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.
1948
1870
  */
1949
- var AnonymousObserver = Rx.AnonymousObserver = (function (_super) {
1950
- inherits(AnonymousObserver, _super);
1871
+ var AbstractObserver = Rx.internals.AbstractObserver = (function (__super__) {
1872
+ inherits(AbstractObserver, __super__);
1951
1873
 
1952
1874
  /**
1953
- * Creates an observer from the specified OnNext, OnError, and OnCompleted actions.
1954
- * @param {Any} onNext Observer's OnNext action implementation.
1955
- * @param {Any} onError Observer's OnError action implementation.
1956
- * @param {Any} onCompleted Observer's OnCompleted action implementation.
1957
- */
1958
- function AnonymousObserver(onNext, onError, onCompleted) {
1959
- _super.call(this);
1960
- this._onNext = onNext;
1961
- this._onError = onError;
1962
- this._onCompleted = onCompleted;
1875
+ * Creates a new observer in a non-stopped state.
1876
+ */
1877
+ function AbstractObserver() {
1878
+ this.isStopped = false;
1879
+ __super__.call(this);
1963
1880
  }
1964
1881
 
1965
1882
  /**
1966
- * Calls the onNext action.
1967
- * @param {Any} value Next element in the sequence.
1968
- */
1969
- AnonymousObserver.prototype.next = function (value) {
1970
- this._onNext(value);
1883
+ * Notifies the observer of a new element in the sequence.
1884
+ * @param {Any} value Next element in the sequence.
1885
+ */
1886
+ AbstractObserver.prototype.onNext = function (value) {
1887
+ if (!this.isStopped) { this.next(value); }
1888
+ };
1889
+
1890
+ /**
1891
+ * Notifies the observer that an exception has occurred.
1892
+ * @param {Any} error The error that has occurred.
1893
+ */
1894
+ AbstractObserver.prototype.onError = function (error) {
1895
+ if (!this.isStopped) {
1896
+ this.isStopped = true;
1897
+ this.error(error);
1898
+ }
1899
+ };
1900
+
1901
+ /**
1902
+ * Notifies the observer of the end of the sequence.
1903
+ */
1904
+ AbstractObserver.prototype.onCompleted = function () {
1905
+ if (!this.isStopped) {
1906
+ this.isStopped = true;
1907
+ this.completed();
1908
+ }
1909
+ };
1910
+
1911
+ /**
1912
+ * Disposes the observer, causing it to transition to the stopped state.
1913
+ */
1914
+ AbstractObserver.prototype.dispose = function () {
1915
+ this.isStopped = true;
1916
+ };
1917
+
1918
+ AbstractObserver.prototype.fail = function (e) {
1919
+ if (!this.isStopped) {
1920
+ this.isStopped = true;
1921
+ this.error(e);
1922
+ return true;
1923
+ }
1924
+
1925
+ return false;
1926
+ };
1927
+
1928
+ return AbstractObserver;
1929
+ }(Observer));
1930
+
1931
+ /**
1932
+ * Class to create an Observer instance from delegate-based implementations of the on* methods.
1933
+ */
1934
+ var AnonymousObserver = Rx.AnonymousObserver = (function (__super__) {
1935
+ inherits(AnonymousObserver, __super__);
1936
+
1937
+ /**
1938
+ * Creates an observer from the specified OnNext, OnError, and OnCompleted actions.
1939
+ * @param {Any} onNext Observer's OnNext action implementation.
1940
+ * @param {Any} onError Observer's OnError action implementation.
1941
+ * @param {Any} onCompleted Observer's OnCompleted action implementation.
1942
+ */
1943
+ function AnonymousObserver(onNext, onError, onCompleted) {
1944
+ __super__.call(this);
1945
+ this._onNext = onNext;
1946
+ this._onError = onError;
1947
+ this._onCompleted = onCompleted;
1948
+ }
1949
+
1950
+ /**
1951
+ * Calls the onNext action.
1952
+ * @param {Any} value Next element in the sequence.
1953
+ */
1954
+ AnonymousObserver.prototype.next = function (value) {
1955
+ this._onNext(value);
1971
1956
  };
1972
1957
 
1973
1958
  /**
1974
1959
  * Calls the onError action.
1975
- * @param {Any} error The error that has occurred.
1976
- */
1977
- AnonymousObserver.prototype.error = function (exception) {
1978
- this._onError(exception);
1960
+ * @param {Any} error The error that has occurred.
1961
+ */
1962
+ AnonymousObserver.prototype.error = function (error) {
1963
+ this._onError(error);
1979
1964
  };
1980
1965
 
1981
1966
  /**
1982
1967
  * Calls the onCompleted action.
1983
- */
1968
+ */
1984
1969
  AnonymousObserver.prototype.completed = function () {
1985
1970
  this._onCompleted();
1986
1971
  };
@@ -2003,8 +1988,8 @@ if (!Array.prototype.forEach) {
2003
1988
  this.checkAccess();
2004
1989
  try {
2005
1990
  this._observer.onNext(value);
2006
- } catch (e) {
2007
- throw e;
1991
+ } catch (e) {
1992
+ throw e;
2008
1993
  } finally {
2009
1994
  this._state = 0;
2010
1995
  }
@@ -2014,8 +1999,8 @@ if (!Array.prototype.forEach) {
2014
1999
  this.checkAccess();
2015
2000
  try {
2016
2001
  this._observer.onError(err);
2017
- } catch (e) {
2018
- throw e;
2002
+ } catch (e) {
2003
+ throw e;
2019
2004
  } finally {
2020
2005
  this._state = 2;
2021
2006
  }
@@ -2025,8 +2010,8 @@ if (!Array.prototype.forEach) {
2025
2010
  this.checkAccess();
2026
2011
  try {
2027
2012
  this._observer.onCompleted();
2028
- } catch (e) {
2029
- throw e;
2013
+ } catch (e) {
2014
+ throw e;
2030
2015
  } finally {
2031
2016
  this._state = 2;
2032
2017
  }
@@ -2150,24 +2135,45 @@ if (!Array.prototype.forEach) {
2150
2135
 
2151
2136
  /**
2152
2137
  * Subscribes an observer to the observable sequence.
2153
- *
2154
- * @example
2155
- * 1 - source.subscribe();
2156
- * 2 - source.subscribe(observer);
2157
- * 3 - source.subscribe(function (x) { console.log(x); });
2158
- * 4 - source.subscribe(function (x) { console.log(x); }, function (err) { console.log(err); });
2159
- * 5 - source.subscribe(function (x) { console.log(x); }, function (err) { console.log(err); }, function () { console.log('done'); });
2160
2138
  * @param {Mixed} [observerOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.
2161
2139
  * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.
2162
2140
  * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.
2163
- * @returns {Diposable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.
2141
+ * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.
2164
2142
  */
2165
2143
  observableProto.subscribe = observableProto.forEach = function (observerOrOnNext, onError, onCompleted) {
2166
- var subscriber = typeof observerOrOnNext === 'object' ?
2144
+ return this._subscribe(typeof observerOrOnNext === 'object' ?
2167
2145
  observerOrOnNext :
2168
- observerCreate(observerOrOnNext, onError, onCompleted);
2146
+ observerCreate(observerOrOnNext, onError, onCompleted));
2147
+ };
2148
+
2149
+ /**
2150
+ * Subscribes to the next value in the sequence with an optional "this" argument.
2151
+ * @param {Function} onNext The function to invoke on each element in the observable sequence.
2152
+ * @param {Any} [thisArg] Object to use as this when executing callback.
2153
+ * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
2154
+ */
2155
+ observableProto.subscribeOnNext = function (onNext, thisArg) {
2156
+ return this._subscribe(observerCreate(arguments.length === 2 ? function(x) { onNext.call(thisArg, x); } : onNext));
2157
+ };
2158
+
2159
+ /**
2160
+ * Subscribes to an exceptional condition in the sequence with an optional "this" argument.
2161
+ * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence.
2162
+ * @param {Any} [thisArg] Object to use as this when executing callback.
2163
+ * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
2164
+ */
2165
+ observableProto.subscribeOnError = function (onError, thisArg) {
2166
+ return this._subscribe(observerCreate(null, arguments.length === 2 ? function(e) { onError.call(thisArg, e); } : onError));
2167
+ };
2169
2168
 
2170
- return this._subscribe(subscriber);
2169
+ /**
2170
+ * Subscribes to the next value in the sequence with an optional "this" argument.
2171
+ * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence.
2172
+ * @param {Any} [thisArg] Object to use as this when executing callback.
2173
+ * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
2174
+ */
2175
+ observableProto.subscribeOnCompleted = function (onCompleted, thisArg) {
2176
+ return this._subscribe(observerCreate(null, null, arguments.length === 2 ? function() { onCompleted.call(thisArg); } : onCompleted));
2171
2177
  };
2172
2178
 
2173
2179
  return Observable;
@@ -2175,12 +2181,12 @@ if (!Array.prototype.forEach) {
2175
2181
 
2176
2182
  /**
2177
2183
  * Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
2178
- *
2184
+ *
2179
2185
  * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
2180
2186
  * that require to be run on a scheduler, use subscribeOn.
2181
- *
2187
+ *
2182
2188
  * @param {Scheduler} scheduler Scheduler to notify observers on.
2183
- * @returns {Observable} The source sequence whose observations happen on the specified scheduler.
2189
+ * @returns {Observable} The source sequence whose observations happen on the specified scheduler.
2184
2190
  */
2185
2191
  observableProto.observeOn = function (scheduler) {
2186
2192
  var source = this;
@@ -2232,11 +2238,12 @@ if (!Array.prototype.forEach) {
2232
2238
  return subject;
2233
2239
  });
2234
2240
  };
2241
+
2235
2242
  /*
2236
2243
  * Converts an existing observable sequence to an ES6 Compatible Promise
2237
2244
  * @example
2238
2245
  * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);
2239
- *
2246
+ *
2240
2247
  * // With config
2241
2248
  * Rx.config.Promise = RSVP.Promise;
2242
2249
  * var promise = Rx.Observable.return(42).toPromise();
@@ -2258,9 +2265,10 @@ if (!Array.prototype.forEach) {
2258
2265
  });
2259
2266
  });
2260
2267
  };
2268
+
2261
2269
  /**
2262
2270
  * Creates a list from an observable sequence.
2263
- * @returns An observable sequence containing a single element with a list containing all the elements of the source sequence.
2271
+ * @returns An observable sequence containing a single element with a list containing all the elements of the source sequence.
2264
2272
  */
2265
2273
  observableProto.toArray = function () {
2266
2274
  var self = this;
@@ -2278,12 +2286,12 @@ if (!Array.prototype.forEach) {
2278
2286
 
2279
2287
  /**
2280
2288
  * Creates an observable sequence from a specified subscribe method implementation.
2281
- *
2289
+ *
2282
2290
  * @example
2283
2291
  * var res = Rx.Observable.create(function (observer) { return function () { } );
2284
- * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );
2285
- * var res = Rx.Observable.create(function (observer) { } );
2286
- *
2292
+ * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );
2293
+ * var res = Rx.Observable.create(function (observer) { } );
2294
+ *
2287
2295
  * @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable.
2288
2296
  * @returns {Observable} The observable sequence with the specified implementation for the Subscribe method.
2289
2297
  */
@@ -2293,9 +2301,9 @@ if (!Array.prototype.forEach) {
2293
2301
 
2294
2302
  /**
2295
2303
  * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
2296
- *
2304
+ *
2297
2305
  * @example
2298
- * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });
2306
+ * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });
2299
2307
  * @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise.
2300
2308
  * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function.
2301
2309
  */
@@ -2314,10 +2322,10 @@ if (!Array.prototype.forEach) {
2314
2322
 
2315
2323
  /**
2316
2324
  * Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
2317
- *
2325
+ *
2318
2326
  * @example
2319
- * var res = Rx.Observable.empty();
2320
- * var res = Rx.Observable.empty(Rx.Scheduler.timeout);
2327
+ * var res = Rx.Observable.empty();
2328
+ * var res = Rx.Observable.empty(Rx.Scheduler.timeout);
2321
2329
  * @param {Scheduler} [scheduler] Scheduler to send the termination call on.
2322
2330
  * @returns {Observable} An observable sequence with no elements.
2323
2331
  */
@@ -2355,7 +2363,7 @@ if (!Array.prototype.forEach) {
2355
2363
  var len = +o.length;
2356
2364
  if (isNaN(len)) { return 0; }
2357
2365
  if (len === 0 || !numberIsFinite(len)) { return len; }
2358
- len = sign(len) * Math.floor(Math.abs(len));
2366
+ len = sign(len) * Math.floor(Math.abs(len));
2359
2367
  if (len <= 0) { return 0; }
2360
2368
  if (len > maxSafeInteger) { return maxSafeInteger; }
2361
2369
  return len;
@@ -2407,7 +2415,7 @@ if (!Array.prototype.forEach) {
2407
2415
  } catch (e) {
2408
2416
  observer.onError(e);
2409
2417
  return;
2410
- }
2418
+ }
2411
2419
  }
2412
2420
 
2413
2421
  observer.onNext(result);
@@ -2419,9 +2427,10 @@ if (!Array.prototype.forEach) {
2419
2427
  });
2420
2428
  });
2421
2429
  };
2430
+
2422
2431
  /**
2423
2432
  * Converts an array to an observable sequence, using an optional scheduler to enumerate the array.
2424
- *
2433
+ *
2425
2434
  * @example
2426
2435
  * var res = Rx.Observable.fromArray([1,2,3]);
2427
2436
  * var res = Rx.Observable.fromArray([1,2,3], Rx.Scheduler.timeout);
@@ -2445,7 +2454,7 @@ if (!Array.prototype.forEach) {
2445
2454
 
2446
2455
  /**
2447
2456
  * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
2448
- *
2457
+ *
2449
2458
  * @example
2450
2459
  * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; });
2451
2460
  * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout);
@@ -2509,7 +2518,7 @@ if (!Array.prototype.forEach) {
2509
2518
  };
2510
2519
 
2511
2520
  /**
2512
- * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
2521
+ * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
2513
2522
  * @example
2514
2523
  * var res = Rx.Observable.of(1,2,3);
2515
2524
  * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.
@@ -2523,7 +2532,7 @@ if (!Array.prototype.forEach) {
2523
2532
 
2524
2533
  /**
2525
2534
  * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
2526
- *
2535
+ *
2527
2536
  * @example
2528
2537
  * var res = Rx.Observable.range(0, 10);
2529
2538
  * var res = Rx.Observable.range(0, 10, Rx.Scheduler.timeout);
@@ -2548,7 +2557,7 @@ if (!Array.prototype.forEach) {
2548
2557
 
2549
2558
  /**
2550
2559
  * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
2551
- *
2560
+ *
2552
2561
  * @example
2553
2562
  * var res = Rx.Observable.repeat(42);
2554
2563
  * var res = Rx.Observable.repeat(42, 4);
@@ -2567,7 +2576,7 @@ if (!Array.prototype.forEach) {
2567
2576
  /**
2568
2577
  * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
2569
2578
  * There is an alias called 'just', and 'returnValue' for browsers <IE9.
2570
- *
2579
+ *
2571
2580
  * @example
2572
2581
  * var res = Rx.Observable.return(42);
2573
2582
  * var res = Rx.Observable.return(42, Rx.Scheduler.timeout);
@@ -2625,7 +2634,7 @@ if (!Array.prototype.forEach) {
2625
2634
  * Propagates the observable sequence or Promise that reacts first.
2626
2635
  * @param {Observable} rightSource Second observable sequence or Promise.
2627
2636
  * @returns {Observable} {Observable} An observable sequence that surfaces either of the given sequences, whichever reacted first.
2628
- */
2637
+ */
2629
2638
  observableProto.amb = function (rightSource) {
2630
2639
  var leftSource = this;
2631
2640
  return new AnonymousObservable(function (observer) {
@@ -2694,7 +2703,7 @@ if (!Array.prototype.forEach) {
2694
2703
  * @example
2695
2704
  * var = Rx.Observable.amb(xs, ys, zs);
2696
2705
  * @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first.
2697
- */
2706
+ */
2698
2707
  Observable.amb = function () {
2699
2708
  var acc = observableNever(),
2700
2709
  items = argsOrArray(arguments, 0);
@@ -2725,7 +2734,7 @@ if (!Array.prototype.forEach) {
2725
2734
  subscription.setDisposable(d);
2726
2735
  d.setDisposable(result.subscribe(observer));
2727
2736
  }, observer.onCompleted.bind(observer)));
2728
-
2737
+
2729
2738
  return subscription;
2730
2739
  });
2731
2740
  }
@@ -2737,25 +2746,21 @@ if (!Array.prototype.forEach) {
2737
2746
  * 2 - xs.catchException(function (ex) { return ys(ex); })
2738
2747
  * @param {Mixed} handlerOrSecond Exception handler function that returns an observable sequence given the error that occurred in the first sequence, or a second observable sequence used to produce results when an error occurred in the first sequence.
2739
2748
  * @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.
2740
- */
2741
- observableProto['catch'] = observableProto.catchException = function (handlerOrSecond) {
2749
+ */
2750
+ observableProto['catch'] = observableProto.catchError = observableProto.catchException = function (handlerOrSecond) {
2742
2751
  return typeof handlerOrSecond === 'function' ?
2743
2752
  observableCatchHandler(this, handlerOrSecond) :
2744
2753
  observableCatch([this, handlerOrSecond]);
2745
2754
  };
2746
2755
 
2747
- /**
2748
- * Continues an observable sequence that is terminated by an exception with the next observable sequence.
2749
- *
2750
- * @example
2751
- * 1 - res = Rx.Observable.catchException(xs, ys, zs);
2752
- * 2 - res = Rx.Observable.catchException([xs, ys, zs]);
2753
- * @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
2754
- */
2755
- var observableCatch = Observable.catchException = Observable['catch'] = function () {
2756
- var items = argsOrArray(arguments, 0);
2757
- return enumerableFor(items).catchException();
2758
- };
2756
+ /**
2757
+ * Continues an observable sequence that is terminated by an exception with the next observable sequence.
2758
+ * @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs.
2759
+ * @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
2760
+ */
2761
+ var observableCatch = Observable.catchException = Observable.catchError = Observable['catch'] = function () {
2762
+ return enumerableOf(argsOrArray(arguments, 0)).catchException();
2763
+ };
2759
2764
 
2760
2765
  /**
2761
2766
  * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
@@ -2764,7 +2769,7 @@ if (!Array.prototype.forEach) {
2764
2769
  * @example
2765
2770
  * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
2766
2771
  * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
2767
- * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2772
+ * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2768
2773
  */
2769
2774
  observableProto.combineLatest = function () {
2770
2775
  var args = slice.call(arguments);
@@ -2778,15 +2783,15 @@ if (!Array.prototype.forEach) {
2778
2783
 
2779
2784
  /**
2780
2785
  * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
2781
- *
2786
+ *
2782
2787
  * @example
2783
2788
  * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
2784
- * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
2789
+ * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
2785
2790
  * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2786
2791
  */
2787
2792
  var combineLatest = Observable.combineLatest = function () {
2788
2793
  var args = slice.call(arguments), resultSelector = args.pop();
2789
-
2794
+
2790
2795
  if (Array.isArray(args[0])) {
2791
2796
  args = args[0];
2792
2797
  }
@@ -2843,35 +2848,31 @@ if (!Array.prototype.forEach) {
2843
2848
 
2844
2849
  /**
2845
2850
  * Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate.
2846
- *
2851
+ *
2847
2852
  * @example
2848
2853
  * 1 - concatenated = xs.concat(ys, zs);
2849
2854
  * 2 - concatenated = xs.concat([ys, zs]);
2850
- * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
2851
- */
2855
+ * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
2856
+ */
2852
2857
  observableProto.concat = function () {
2853
2858
  var items = slice.call(arguments, 0);
2854
2859
  items.unshift(this);
2855
2860
  return observableConcat.apply(this, items);
2856
2861
  };
2857
2862
 
2858
- /**
2859
- * Concatenates all the observable sequences.
2860
- *
2861
- * @example
2862
- * 1 - res = Rx.Observable.concat(xs, ys, zs);
2863
- * 2 - res = Rx.Observable.concat([xs, ys, zs]);
2864
- * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
2865
- */
2866
- var observableConcat = Observable.concat = function () {
2867
- var sources = argsOrArray(arguments, 0);
2868
- return enumerableFor(sources).concat();
2869
- };
2863
+ /**
2864
+ * Concatenates all the observable sequences.
2865
+ * @param {Array | Arguments} args Arguments or an array to concat to the observable sequence.
2866
+ * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
2867
+ */
2868
+ var observableConcat = Observable.concat = function () {
2869
+ return enumerableOf(argsOrArray(arguments, 0)).concat();
2870
+ };
2870
2871
 
2871
2872
  /**
2872
2873
  * Concatenates an observable sequence of observable sequences.
2873
- * @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order.
2874
- */
2874
+ * @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order.
2875
+ */
2875
2876
  observableProto.concatObservable = observableProto.concatAll =function () {
2876
2877
  return this.merge(1);
2877
2878
  };
@@ -2879,13 +2880,13 @@ if (!Array.prototype.forEach) {
2879
2880
  /**
2880
2881
  * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.
2881
2882
  * Or merges two observable sequences into a single observable sequence.
2882
- *
2883
+ *
2883
2884
  * @example
2884
2885
  * 1 - merged = sources.merge(1);
2885
- * 2 - merged = source.merge(otherSource);
2886
+ * 2 - merged = source.merge(otherSource);
2886
2887
  * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence.
2887
- * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
2888
- */
2888
+ * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
2889
+ */
2889
2890
  observableProto.merge = function (maxConcurrentOrOther) {
2890
2891
  if (typeof maxConcurrentOrOther !== 'number') { return observableMerge(this, maxConcurrentOrOther); }
2891
2892
  var sources = this;
@@ -2925,16 +2926,16 @@ if (!Array.prototype.forEach) {
2925
2926
  };
2926
2927
 
2927
2928
  /**
2928
- * Merges all the observable sequences into a single observable sequence.
2929
+ * Merges all the observable sequences into a single observable sequence.
2929
2930
  * The scheduler is optional and if not specified, the immediate scheduler is used.
2930
- *
2931
+ *
2931
2932
  * @example
2932
2933
  * 1 - merged = Rx.Observable.merge(xs, ys, zs);
2933
2934
  * 2 - merged = Rx.Observable.merge([xs, ys, zs]);
2934
2935
  * 3 - merged = Rx.Observable.merge(scheduler, xs, ys, zs);
2935
- * 4 - merged = Rx.Observable.merge(scheduler, [xs, ys, zs]);
2936
- * @returns {Observable} The observable sequence that merges the elements of the observable sequences.
2937
- */
2936
+ * 4 - merged = Rx.Observable.merge(scheduler, [xs, ys, zs]);
2937
+ * @returns {Observable} The observable sequence that merges the elements of the observable sequences.
2938
+ */
2938
2939
  var observableMerge = Observable.merge = function () {
2939
2940
  var scheduler, sources;
2940
2941
  if (!arguments[0]) {
@@ -2951,13 +2952,13 @@ if (!Array.prototype.forEach) {
2951
2952
  sources = sources[0];
2952
2953
  }
2953
2954
  return observableFromArray(sources, scheduler).mergeObservable();
2954
- };
2955
+ };
2955
2956
 
2956
2957
  /**
2957
2958
  * Merges an observable sequence of observable sequences into an observable sequence.
2958
- * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
2959
- */
2960
- observableProto.mergeObservable = observableProto.mergeAll =function () {
2959
+ * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
2960
+ */
2961
+ observableProto.mergeObservable = observableProto.mergeAll = function () {
2961
2962
  var sources = this;
2962
2963
  return new AnonymousObservable(function (observer) {
2963
2964
  var group = new CompositeDisposable(),
@@ -2996,11 +2997,11 @@ if (!Array.prototype.forEach) {
2996
2997
 
2997
2998
  /**
2998
2999
  * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.
2999
- *
3000
+ *
3000
3001
  * @example
3001
3002
  * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs);
3002
3003
  * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]);
3003
- * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.
3004
+ * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.
3004
3005
  */
3005
3006
  var onErrorResumeNext = Observable.onErrorResumeNext = function () {
3006
3007
  var sources = argsOrArray(arguments, 0);
@@ -3025,7 +3026,7 @@ if (!Array.prototype.forEach) {
3025
3026
  /**
3026
3027
  * Returns the values from the source observable sequence only after the other observable sequence produces a value.
3027
3028
  * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence.
3028
- * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.
3029
+ * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.
3029
3030
  */
3030
3031
  observableProto.skipUntil = function (other) {
3031
3032
  var source = this;
@@ -3054,7 +3055,7 @@ if (!Array.prototype.forEach) {
3054
3055
 
3055
3056
  /**
3056
3057
  * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
3057
- * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.
3058
+ * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.
3058
3059
  */
3059
3060
  observableProto['switch'] = observableProto.switchLatest = function () {
3060
3061
  var sources = this;
@@ -3073,16 +3074,16 @@ if (!Array.prototype.forEach) {
3073
3074
  isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
3074
3075
 
3075
3076
  d.setDisposable(innerSource.subscribe(
3076
- function (x) { latest === id && observer.onNext(x); },
3077
- function (e) { latest === id && observer.onError(e); },
3077
+ function (x) { latest === id && observer.onNext(x); },
3078
+ function (e) { latest === id && observer.onError(e); },
3078
3079
  function () {
3079
3080
  if (latest === id) {
3080
3081
  hasLatest = false;
3081
3082
  isStopped && observer.onCompleted();
3082
3083
  }
3083
3084
  }));
3084
- },
3085
- observer.onError.bind(observer),
3085
+ },
3086
+ observer.onError.bind(observer),
3086
3087
  function () {
3087
3088
  isStopped = true;
3088
3089
  !hasLatest && observer.onCompleted();
@@ -3094,7 +3095,7 @@ if (!Array.prototype.forEach) {
3094
3095
  /**
3095
3096
  * Returns the values from the source observable sequence until the other observable sequence produces a value.
3096
3097
  * @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence.
3097
- * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
3098
+ * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
3098
3099
  */
3099
3100
  observableProto.takeUntil = function (other) {
3100
3101
  var source = this;
@@ -3126,7 +3127,7 @@ if (!Array.prototype.forEach) {
3126
3127
  }
3127
3128
  }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3128
3129
  });
3129
- }
3130
+ }
3130
3131
 
3131
3132
  /**
3132
3133
  * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
@@ -3134,9 +3135,9 @@ if (!Array.prototype.forEach) {
3134
3135
  *
3135
3136
  * @example
3136
3137
  * 1 - res = obs1.zip(obs2, fn);
3137
- * 1 - res = x1.zip([1,2,3], fn);
3138
- * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
3139
- */
3138
+ * 1 - res = x1.zip([1,2,3], fn);
3139
+ * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
3140
+ */
3140
3141
  observableProto.zip = function () {
3141
3142
  if (Array.isArray(arguments[0])) {
3142
3143
  return zipArray.apply(this, arguments);
@@ -3147,7 +3148,7 @@ if (!Array.prototype.forEach) {
3147
3148
  var n = sources.length,
3148
3149
  queues = arrayInitialize(n, function () { return []; }),
3149
3150
  isDone = arrayInitialize(n, function () { return false; });
3150
-
3151
+
3151
3152
  function next(i) {
3152
3153
  var res, queuedValues;
3153
3154
  if (queues.every(function (x) { return x.length > 0; })) {
@@ -3189,74 +3190,72 @@ if (!Array.prototype.forEach) {
3189
3190
  return new CompositeDisposable(subscriptions);
3190
3191
  });
3191
3192
  };
3192
- /**
3193
- * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
3194
- * @param arguments Observable sources.
3195
- * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
3196
- * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
3197
- */
3198
- Observable.zip = function () {
3199
- var args = slice.call(arguments, 0),
3200
- first = args.shift();
3201
- return first.zip.apply(first, args);
3202
- };
3203
3193
 
3204
- /**
3205
- * Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
3206
- * @param arguments Observable sources.
3207
- * @returns {Observable} An observable sequence containing lists of elements at corresponding indexes.
3208
- */
3209
- Observable.zipArray = function () {
3210
- var sources = argsOrArray(arguments, 0);
3211
- return new AnonymousObservable(function (observer) {
3212
- var n = sources.length,
3213
- queues = arrayInitialize(n, function () { return []; }),
3214
- isDone = arrayInitialize(n, function () { return false; });
3215
-
3216
- function next(i) {
3217
- if (queues.every(function (x) { return x.length > 0; })) {
3218
- var res = queues.map(function (x) { return x.shift(); });
3219
- observer.onNext(res);
3220
- } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
3221
- observer.onCompleted();
3222
- return;
3223
- }
3224
- };
3194
+ /**
3195
+ * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
3196
+ * @param arguments Observable sources.
3197
+ * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.
3198
+ * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
3199
+ */
3200
+ Observable.zip = function () {
3201
+ var args = slice.call(arguments, 0), first = args.shift();
3202
+ return first.zip.apply(first, args);
3203
+ };
3225
3204
 
3226
- function done(i) {
3227
- isDone[i] = true;
3228
- if (isDone.every(identity)) {
3229
- observer.onCompleted();
3230
- return;
3231
- }
3232
- }
3205
+ /**
3206
+ * Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
3207
+ * @param arguments Observable sources.
3208
+ * @returns {Observable} An observable sequence containing lists of elements at corresponding indexes.
3209
+ */
3210
+ Observable.zipArray = function () {
3211
+ var sources = argsOrArray(arguments, 0);
3212
+ return new AnonymousObservable(function (observer) {
3213
+ var n = sources.length,
3214
+ queues = arrayInitialize(n, function () { return []; }),
3215
+ isDone = arrayInitialize(n, function () { return false; });
3233
3216
 
3234
- var subscriptions = new Array(n);
3235
- for (var idx = 0; idx < n; idx++) {
3236
- (function (i) {
3237
- subscriptions[i] = new SingleAssignmentDisposable();
3238
- subscriptions[i].setDisposable(sources[i].subscribe(function (x) {
3239
- queues[i].push(x);
3240
- next(i);
3241
- }, observer.onError.bind(observer), function () {
3242
- done(i);
3243
- }));
3244
- })(idx);
3245
- }
3217
+ function next(i) {
3218
+ if (queues.every(function (x) { return x.length > 0; })) {
3219
+ var res = queues.map(function (x) { return x.shift(); });
3220
+ observer.onNext(res);
3221
+ } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
3222
+ observer.onCompleted();
3223
+ return;
3224
+ }
3225
+ };
3246
3226
 
3247
- var compositeDisposable = new CompositeDisposable(subscriptions);
3248
- compositeDisposable.add(disposableCreate(function () {
3249
- for (var qIdx = 0, qLen = queues.length; qIdx < qLen; qIdx++) {
3250
- queues[qIdx] = [];
3251
- }
3252
- }));
3253
- return compositeDisposable;
3254
- });
3255
- };
3227
+ function done(i) {
3228
+ isDone[i] = true;
3229
+ if (isDone.every(identity)) {
3230
+ observer.onCompleted();
3231
+ return;
3232
+ }
3233
+ }
3234
+
3235
+ var subscriptions = new Array(n);
3236
+ for (var idx = 0; idx < n; idx++) {
3237
+ (function (i) {
3238
+ subscriptions[i] = new SingleAssignmentDisposable();
3239
+ subscriptions[i].setDisposable(sources[i].subscribe(function (x) {
3240
+ queues[i].push(x);
3241
+ next(i);
3242
+ }, observer.onError.bind(observer), function () {
3243
+ done(i);
3244
+ }));
3245
+ })(idx);
3246
+ }
3247
+
3248
+ var compositeDisposable = new CompositeDisposable(subscriptions);
3249
+ compositeDisposable.add(disposableCreate(function () {
3250
+ for (var qIdx = 0, qLen = queues.length; qIdx < qLen; qIdx++) { queues[qIdx] = []; }
3251
+ }));
3252
+ return compositeDisposable;
3253
+ });
3254
+ };
3256
3255
 
3257
3256
  /**
3258
3257
  * Hides the identity of an observable sequence.
3259
- * @returns {Observable} An observable sequence that hides the identity of the source sequence.
3258
+ * @returns {Observable} An observable sequence that hides the identity of the source sequence.
3260
3259
  */
3261
3260
  observableProto.asObservable = function () {
3262
3261
  return new AnonymousObservable(this.subscribe.bind(this));
@@ -3264,13 +3263,13 @@ if (!Array.prototype.forEach) {
3264
3263
 
3265
3264
  /**
3266
3265
  * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
3267
- *
3266
+ *
3268
3267
  * @example
3269
3268
  * var res = xs.bufferWithCount(10);
3270
3269
  * var res = xs.bufferWithCount(10, 1);
3271
3270
  * @param {Number} count Length of each buffer.
3272
3271
  * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count.
3273
- * @returns {Observable} An observable sequence of buffers.
3272
+ * @returns {Observable} An observable sequence of buffers.
3274
3273
  */
3275
3274
  observableProto.bufferWithCount = function (count, skip) {
3276
3275
  if (typeof skip !== 'number') {
@@ -3286,7 +3285,7 @@ if (!Array.prototype.forEach) {
3286
3285
  /**
3287
3286
  * Dematerializes the explicit notification values of an observable sequence as implicit notifications.
3288
3287
  * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.
3289
- */
3288
+ */
3290
3289
  observableProto.dematerialize = function () {
3291
3290
  var source = this;
3292
3291
  return new AnonymousObservable(function (observer) {
@@ -3298,14 +3297,14 @@ if (!Array.prototype.forEach) {
3298
3297
 
3299
3298
  /**
3300
3299
  * Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
3301
- *
3300
+ *
3302
3301
  * var obs = observable.distinctUntilChanged();
3303
3302
  * var obs = observable.distinctUntilChanged(function (x) { return x.id; });
3304
3303
  * var obs = observable.distinctUntilChanged(function (x) { return x.id; }, function (x, y) { return x === y; });
3305
3304
  *
3306
3305
  * @param {Function} [keySelector] A function to compute the comparison key for each element. If not provided, it projects the value.
3307
3306
  * @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function.
3308
- * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.
3307
+ * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.
3309
3308
  */
3310
3309
  observableProto.distinctUntilChanged = function (keySelector, comparer) {
3311
3310
  var source = this;
@@ -3341,16 +3340,10 @@ if (!Array.prototype.forEach) {
3341
3340
  /**
3342
3341
  * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
3343
3342
  * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
3344
- *
3345
- * @example
3346
- * var res = observable.do(observer);
3347
- * var res = observable.do(onNext);
3348
- * var res = observable.do(onNext, onError);
3349
- * var res = observable.do(onNext, onError, onCompleted);
3350
3343
  * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an observer.
3351
3344
  * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
3352
3345
  * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
3353
- * @returns {Observable} The source sequence with the side-effecting behavior applied.
3346
+ * @returns {Observable} The source sequence with the side-effecting behavior applied.
3354
3347
  */
3355
3348
  observableProto['do'] = observableProto.doAction = observableProto.tap = function (observerOrOnNext, onError, onCompleted) {
3356
3349
  var source = this, onNextFunc;
@@ -3370,39 +3363,68 @@ if (!Array.prototype.forEach) {
3370
3363
  }
3371
3364
  observer.onNext(x);
3372
3365
  }, function (err) {
3373
- if (!onError) {
3374
- observer.onError(err);
3375
- } else {
3366
+ if (onError) {
3376
3367
  try {
3377
3368
  onError(err);
3378
3369
  } catch (e) {
3379
3370
  observer.onError(e);
3380
3371
  }
3381
- observer.onError(err);
3382
3372
  }
3373
+ observer.onError(err);
3383
3374
  }, function () {
3384
- if (!onCompleted) {
3385
- observer.onCompleted();
3386
- } else {
3375
+ if (onCompleted) {
3387
3376
  try {
3388
3377
  onCompleted();
3389
3378
  } catch (e) {
3390
3379
  observer.onError(e);
3391
3380
  }
3392
- observer.onCompleted();
3393
3381
  }
3382
+ observer.onCompleted();
3394
3383
  });
3395
3384
  });
3396
3385
  };
3397
3386
 
3387
+ /**
3388
+ * Invokes an action for each element in the observable sequence.
3389
+ * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
3390
+ * @param {Function} onNext Action to invoke for each element in the observable sequence.
3391
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3392
+ * @returns {Observable} The source sequence with the side-effecting behavior applied.
3393
+ */
3394
+ observableProto.doOnNext = observableProto.tapOnNext = function (onNext, thisArg) {
3395
+ return this.tap(arguments.length === 2 ? function (x) { onNext.call(thisArg, x); } : onNext);
3396
+ };
3397
+
3398
+ /**
3399
+ * Invokes an action upon exceptional termination of the observable sequence.
3400
+ * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
3401
+ * @param {Function} onError Action to invoke upon exceptional termination of the observable sequence.
3402
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3403
+ * @returns {Observable} The source sequence with the side-effecting behavior applied.
3404
+ */
3405
+ observableProto.doOnError = observableProto.tapOnError = function (onError, thisArg) {
3406
+ return this.tap(noop, arguments.length === 2 ? function (e) { onError.call(thisArg, e); } : onError);
3407
+ };
3408
+
3409
+ /**
3410
+ * Invokes an action upon graceful termination of the observable sequence.
3411
+ * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
3412
+ * @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence.
3413
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3414
+ * @returns {Observable} The source sequence with the side-effecting behavior applied.
3415
+ */
3416
+ observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) {
3417
+ return this.tap(noop, null, arguments.length === 2 ? function () { onCompleted.call(thisArg); } : onCompleted);
3418
+ };
3419
+
3398
3420
  /**
3399
3421
  * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
3400
- *
3422
+ *
3401
3423
  * @example
3402
3424
  * var res = observable.finallyAction(function () { console.log('sequence ended'; });
3403
3425
  * @param {Function} finallyAction Action to invoke after the source observable sequence terminates.
3404
- * @returns {Observable} Source sequence with the action-invoking termination behavior applied.
3405
- */
3426
+ * @returns {Observable} Source sequence with the action-invoking termination behavior applied.
3427
+ */
3406
3428
  observableProto['finally'] = observableProto.finallyAction = function (action) {
3407
3429
  var source = this;
3408
3430
  return new AnonymousObservable(function (observer) {
@@ -3416,8 +3438,8 @@ if (!Array.prototype.forEach) {
3416
3438
  return disposableCreate(function () {
3417
3439
  try {
3418
3440
  subscription.dispose();
3419
- } catch (e) {
3420
- throw e;
3441
+ } catch (e) {
3442
+ throw e;
3421
3443
  } finally {
3422
3444
  action();
3423
3445
  }
@@ -3427,7 +3449,7 @@ if (!Array.prototype.forEach) {
3427
3449
 
3428
3450
  /**
3429
3451
  * Ignores all elements in an observable sequence leaving only the termination messages.
3430
- * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.
3452
+ * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.
3431
3453
  */
3432
3454
  observableProto.ignoreElements = function () {
3433
3455
  var source = this;
@@ -3439,7 +3461,7 @@ if (!Array.prototype.forEach) {
3439
3461
  /**
3440
3462
  * Materializes the implicit notifications of an observable sequence as explicit notification values.
3441
3463
  * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.
3442
- */
3464
+ */
3443
3465
  observableProto.materialize = function () {
3444
3466
  var source = this;
3445
3467
  return new AnonymousObservable(function (observer) {
@@ -3457,12 +3479,12 @@ if (!Array.prototype.forEach) {
3457
3479
 
3458
3480
  /**
3459
3481
  * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.
3460
- *
3482
+ *
3461
3483
  * @example
3462
3484
  * var res = repeated = source.repeat();
3463
3485
  * var res = repeated = source.repeat(42);
3464
3486
  * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely.
3465
- * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.
3487
+ * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.
3466
3488
  */
3467
3489
  observableProto.repeat = function (repeatCount) {
3468
3490
  return enumerableRepeat(this, repeatCount).concat();
@@ -3471,12 +3493,12 @@ if (!Array.prototype.forEach) {
3471
3493
  /**
3472
3494
  * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely.
3473
3495
  * Note if you encounter an error and want it to retry once, then you must use .retry(2);
3474
- *
3496
+ *
3475
3497
  * @example
3476
3498
  * var res = retried = retry.repeat();
3477
3499
  * var res = retried = retry.repeat(2);
3478
3500
  * @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely.
3479
- * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
3501
+ * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
3480
3502
  */
3481
3503
  observableProto.retry = function (retryCount) {
3482
3504
  return enumerableRepeat(this, retryCount).catchException();
@@ -3497,7 +3519,7 @@ if (!Array.prototype.forEach) {
3497
3519
  if (arguments.length === 2) {
3498
3520
  hasSeed = true;
3499
3521
  seed = arguments[0];
3500
- accumulator = arguments[1];
3522
+ accumulator = arguments[1];
3501
3523
  } else {
3502
3524
  accumulator = arguments[0];
3503
3525
  }
@@ -3512,7 +3534,7 @@ if (!Array.prototype.forEach) {
3512
3534
  } else {
3513
3535
  accumulation = hasSeed ? accumulator(seed, x) : x;
3514
3536
  hasAccumulation = true;
3515
- }
3537
+ }
3516
3538
  } catch (e) {
3517
3539
  observer.onError(e);
3518
3540
  return;
@@ -3533,9 +3555,9 @@ if (!Array.prototype.forEach) {
3533
3555
  * Bypasses a specified number of elements at the end of an observable sequence.
3534
3556
  * @description
3535
3557
  * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are
3536
- * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
3558
+ * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
3537
3559
  * @param count Number of elements to bypass at the end of the source sequence.
3538
- * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.
3560
+ * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.
3539
3561
  */
3540
3562
  observableProto.skipLast = function (count) {
3541
3563
  var source = this;
@@ -3554,7 +3576,7 @@ if (!Array.prototype.forEach) {
3554
3576
  * var res = source.startWith(1, 2, 3);
3555
3577
  * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);
3556
3578
  * @param {Arguments} args The specified values to prepend to the observable sequence
3557
- * @returns {Observable} The source sequence prepended with the specified values.
3579
+ * @returns {Observable} The source sequence prepended with the specified values.
3558
3580
  */
3559
3581
  observableProto.startWith = function () {
3560
3582
  var values, scheduler, start = 0;
@@ -3565,7 +3587,7 @@ if (!Array.prototype.forEach) {
3565
3587
  scheduler = immediateScheduler;
3566
3588
  }
3567
3589
  values = slice.call(arguments, start);
3568
- return enumerableFor([observableFromArray(values, scheduler), this]).concat();
3590
+ return enumerableOf([observableFromArray(values, scheduler), this]).concat();
3569
3591
  };
3570
3592
 
3571
3593
  /**
@@ -3575,7 +3597,7 @@ if (!Array.prototype.forEach) {
3575
3597
  * the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
3576
3598
  * @param {Number} count Number of elements to take from the end of the source sequence.
3577
3599
  * @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence.
3578
- */
3600
+ */
3579
3601
  observableProto.takeLast = function (count) {
3580
3602
  var source = this;
3581
3603
  return new AnonymousObservable(function (observer) {
@@ -3592,10 +3614,10 @@ if (!Array.prototype.forEach) {
3592
3614
 
3593
3615
  /**
3594
3616
  * Returns an array with the specified number of contiguous elements from the end of an observable sequence.
3595
- *
3617
+ *
3596
3618
  * @description
3597
3619
  * This operator accumulates a buffer with a length enough to store count elements. Upon completion of the
3598
- * source sequence, this buffer is produced on the result sequence.
3620
+ * source sequence, this buffer is produced on the result sequence.
3599
3621
  * @param {Number} count Number of elements to take from the end of the source sequence.
3600
3622
  * @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence.
3601
3623
  */
@@ -3613,65 +3635,58 @@ if (!Array.prototype.forEach) {
3613
3635
  });
3614
3636
  };
3615
3637
 
3616
- /**
3617
- * Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
3618
- *
3619
- * var res = xs.windowWithCount(10);
3620
- * var res = xs.windowWithCount(10, 1);
3621
- * @param {Number} count Length of each window.
3622
- * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count.
3623
- * @returns {Observable} An observable sequence of windows.
3624
- */
3625
- observableProto.windowWithCount = function (count, skip) {
3626
- var source = this;
3627
- if (count <= 0) {
3628
- throw new Error(argumentOutOfRange);
3629
- }
3630
- if (arguments.length === 1) {
3631
- skip = count;
3632
- }
3633
- if (skip <= 0) {
3634
- throw new Error(argumentOutOfRange);
3638
+ /**
3639
+ * Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
3640
+ *
3641
+ * var res = xs.windowWithCount(10);
3642
+ * var res = xs.windowWithCount(10, 1);
3643
+ * @param {Number} count Length of each window.
3644
+ * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count.
3645
+ * @returns {Observable} An observable sequence of windows.
3646
+ */
3647
+ observableProto.windowWithCount = function (count, skip) {
3648
+ var source = this;
3649
+ +count || (count = 0);
3650
+ Math.abs(count) === Infinity && (count = 0);
3651
+ if (count <= 0) { throw new Error(argumentOutOfRange); }
3652
+ skip == null && (skip = count);
3653
+ +skip || (skip = 0);
3654
+ Math.abs(skip) === Infinity && (skip = 0);
3655
+
3656
+ if (skip <= 0) { throw new Error(argumentOutOfRange); }
3657
+ return new AnonymousObservable(function (observer) {
3658
+ var m = new SingleAssignmentDisposable(),
3659
+ refCountDisposable = new RefCountDisposable(m),
3660
+ n = 0,
3661
+ q = [];
3662
+
3663
+ function createWindow () {
3664
+ var s = new Subject();
3665
+ q.push(s);
3666
+ observer.onNext(addRef(s, refCountDisposable));
3667
+ }
3668
+
3669
+ createWindow();
3670
+
3671
+ m.setDisposable(source.subscribe(
3672
+ function (x) {
3673
+ for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }
3674
+ var c = n - count + 1;
3675
+ c >=0 && c % skip === 0 && q.shift().onCompleted();
3676
+ ++n % skip === 0 && createWindow();
3677
+ },
3678
+ function (e) {
3679
+ while (q.length > 0) { q.shift().onError(e); }
3680
+ observer.onError(e);
3681
+ },
3682
+ function () {
3683
+ while (q.length > 0) { q.shift().onCompleted(); }
3684
+ observer.onCompleted();
3635
3685
  }
3636
- return new AnonymousObservable(function (observer) {
3637
- var m = new SingleAssignmentDisposable(),
3638
- refCountDisposable = new RefCountDisposable(m),
3639
- n = 0,
3640
- q = [],
3641
- createWindow = function () {
3642
- var s = new Subject();
3643
- q.push(s);
3644
- observer.onNext(addRef(s, refCountDisposable));
3645
- };
3646
- createWindow();
3647
- m.setDisposable(source.subscribe(function (x) {
3648
- var s;
3649
- for (var i = 0, len = q.length; i < len; i++) {
3650
- q[i].onNext(x);
3651
- }
3652
- var c = n - count + 1;
3653
- if (c >= 0 && c % skip === 0) {
3654
- s = q.shift();
3655
- s.onCompleted();
3656
- }
3657
- n++;
3658
- if (n % skip === 0) {
3659
- createWindow();
3660
- }
3661
- }, function (exception) {
3662
- while (q.length > 0) {
3663
- q.shift().onError(exception);
3664
- }
3665
- observer.onError(exception);
3666
- }, function () {
3667
- while (q.length > 0) {
3668
- q.shift().onCompleted();
3669
- }
3670
- observer.onCompleted();
3671
- }));
3672
- return refCountDisposable;
3673
- });
3674
- };
3686
+ ));
3687
+ return refCountDisposable;
3688
+ });
3689
+ };
3675
3690
 
3676
3691
  function concatMap(source, selector, thisArg) {
3677
3692
  return source.map(function (x, i) {
@@ -3683,21 +3698,21 @@ if (!Array.prototype.forEach) {
3683
3698
  /**
3684
3699
  * One of the Following:
3685
3700
  * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
3686
- *
3701
+ *
3687
3702
  * @example
3688
3703
  * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });
3689
3704
  * Or:
3690
3705
  * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
3691
- *
3706
+ *
3692
3707
  * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
3693
3708
  * Or:
3694
3709
  * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
3695
- *
3710
+ *
3696
3711
  * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));
3697
- * @param selector A transform function to apply to each element or an observable sequence to project each element from the
3712
+ * @param selector A transform function to apply to each element or an observable sequence to project each element from the
3698
3713
  * source sequence onto which could be either an observable or Promise.
3699
3714
  * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
3700
- * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
3715
+ * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
3701
3716
  */
3702
3717
  observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
3703
3718
  if (resultSelector) {
@@ -3720,9 +3735,9 @@ if (!Array.prototype.forEach) {
3720
3735
  * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.
3721
3736
  * @param {Function} onError A transform function to apply when an error occurs in the source sequence.
3722
3737
  * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.
3723
- * @param {Any} [thisArg] An optional "this" to use to invoke each transform.
3738
+ * @param {Any} [thisArg] An optional "this" to use to invoke each transform.
3724
3739
  * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.
3725
- */
3740
+ */
3726
3741
  observableProto.concatMapObserver = observableProto.selectConcatObserver = function(onNext, onError, onCompleted, thisArg) {
3727
3742
  var source = this;
3728
3743
  return new AnonymousObservable(function (observer) {
@@ -3751,7 +3766,7 @@ if (!Array.prototype.forEach) {
3751
3766
  isPromise(result) && (result = observableFromPromise(result));
3752
3767
  observer.onNext(result);
3753
3768
  observer.onCompleted();
3754
- },
3769
+ },
3755
3770
  function () {
3756
3771
  var result;
3757
3772
  try {
@@ -3759,22 +3774,23 @@ if (!Array.prototype.forEach) {
3759
3774
  } catch (e) {
3760
3775
  observer.onError(e);
3761
3776
  return;
3762
- }
3763
- isPromise(result) && (result = observableFromPromise(result));
3777
+ }
3778
+ isPromise(result) && (result = observableFromPromise(result));
3764
3779
  observer.onNext(result);
3765
3780
  observer.onCompleted();
3766
3781
  });
3767
3782
  }).concatAll();
3768
3783
  };
3784
+
3769
3785
  /**
3770
3786
  * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.
3771
- *
3787
+ *
3772
3788
  * var res = obs = xs.defaultIfEmpty();
3773
3789
  * 2 - obs = xs.defaultIfEmpty(false);
3774
- *
3790
+ *
3775
3791
  * @memberOf Observable#
3776
3792
  * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null.
3777
- * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.
3793
+ * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.
3778
3794
  */
3779
3795
  observableProto.defaultIfEmpty = function (defaultValue) {
3780
3796
  var source = this;
@@ -3815,12 +3831,12 @@ if (!Array.prototype.forEach) {
3815
3831
 
3816
3832
  /**
3817
3833
  * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.
3818
- * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.
3819
- *
3834
+ * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.
3835
+ *
3820
3836
  * @example
3821
3837
  * var res = obs = xs.distinct();
3822
3838
  * 2 - obs = xs.distinct(function (x) { return x.id; });
3823
- * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; });
3839
+ * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; });
3824
3840
  * @param {Function} [keySelector] A function to compute the comparison key for each element.
3825
3841
  * @param {Function} [comparer] Used to compare items in the collection.
3826
3842
  * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.
@@ -3839,37 +3855,37 @@ if (!Array.prototype.forEach) {
3839
3855
  } catch (e) {
3840
3856
  observer.onError(e);
3841
3857
  return;
3842
- }
3858
+ }
3843
3859
  }
3844
3860
  hashSet.push(key) && observer.onNext(x);
3845
- },
3846
- observer.onError.bind(observer),
3861
+ },
3862
+ observer.onError.bind(observer),
3847
3863
  observer.onCompleted.bind(observer));
3848
3864
  });
3849
3865
  };
3850
3866
 
3851
- /**
3852
- * Projects each element of an observable sequence into a new form by incorporating the element's index.
3853
- * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
3854
- * @param {Any} [thisArg] Object to use as this when executing callback.
3855
- * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
3856
- */
3857
- observableProto.select = observableProto.map = function (selector, thisArg) {
3858
- var parent = this;
3859
- return new AnonymousObservable(function (observer) {
3860
- var count = 0;
3861
- return parent.subscribe(function (value) {
3862
- var result;
3863
- try {
3864
- result = selector.call(thisArg, value, count++, parent);
3865
- } catch (exception) {
3866
- observer.onError(exception);
3867
- return;
3868
- }
3869
- observer.onNext(result);
3870
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3871
- });
3872
- };
3867
+ /**
3868
+ * Projects each element of an observable sequence into a new form by incorporating the element's index.
3869
+ * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
3870
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3871
+ * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
3872
+ */
3873
+ observableProto.select = observableProto.map = function (selector, thisArg) {
3874
+ var parent = this;
3875
+ return new AnonymousObservable(function (observer) {
3876
+ var count = 0;
3877
+ return parent.subscribe(function (value) {
3878
+ var result;
3879
+ try {
3880
+ result = selector.call(thisArg, value, count++, parent);
3881
+ } catch (e) {
3882
+ observer.onError(e);
3883
+ return;
3884
+ }
3885
+ observer.onNext(result);
3886
+ }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3887
+ });
3888
+ };
3873
3889
 
3874
3890
  /**
3875
3891
  * Retrieves the value of a specified property from all elements in the Observable sequence.
@@ -3890,22 +3906,22 @@ if (!Array.prototype.forEach) {
3890
3906
  /**
3891
3907
  * One of the Following:
3892
3908
  * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
3893
- *
3909
+ *
3894
3910
  * @example
3895
3911
  * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });
3896
3912
  * Or:
3897
3913
  * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
3898
- *
3914
+ *
3899
3915
  * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });
3900
3916
  * Or:
3901
3917
  * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
3902
- *
3918
+ *
3903
3919
  * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));
3904
- * @param selector A transform function to apply to each element or an observable sequence to project each element from the
3920
+ * @param selector A transform function to apply to each element or an observable sequence to project each element from the
3905
3921
  * source sequence onto which could be either an observable or Promise.
3906
3922
  * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.
3907
3923
  * @param {Any} [thisArg] Object to use as this when executing callback.
3908
- * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
3924
+ * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.
3909
3925
  */
3910
3926
  observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
3911
3927
  if (resultSelector) {
@@ -3959,7 +3975,7 @@ if (!Array.prototype.forEach) {
3959
3975
  isPromise(result) && (result = observableFromPromise(result));
3960
3976
  observer.onNext(result);
3961
3977
  observer.onCompleted();
3962
- },
3978
+ },
3963
3979
  function () {
3964
3980
  var result;
3965
3981
  try {
@@ -3967,19 +3983,20 @@ if (!Array.prototype.forEach) {
3967
3983
  } catch (e) {
3968
3984
  observer.onError(e);
3969
3985
  return;
3970
- }
3971
- isPromise(result) && (result = observableFromPromise(result));
3986
+ }
3987
+ isPromise(result) && (result = observableFromPromise(result));
3972
3988
  observer.onNext(result);
3973
3989
  observer.onCompleted();
3974
3990
  });
3975
3991
  }).mergeAll();
3976
3992
  };
3993
+
3977
3994
  /**
3978
- * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
3995
+ * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then
3979
3996
  * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
3980
3997
  * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
3981
3998
  * @param {Any} [thisArg] Object to use as this when executing callback.
3982
- * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
3999
+ * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences
3983
4000
  * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
3984
4001
  */
3985
4002
  observableProto.selectSwitch = observableProto.flatMapLatest = observableProto.switchMap = function (selector, thisArg) {
@@ -3989,7 +4006,7 @@ if (!Array.prototype.forEach) {
3989
4006
  /**
3990
4007
  * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
3991
4008
  * @param {Number} count The number of elements to skip before returning the remaining elements.
3992
- * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
4009
+ * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.
3993
4010
  */
3994
4011
  observableProto.skip = function (count) {
3995
4012
  if (count < 0) { throw new Error(argumentOutOfRange); }
@@ -4009,12 +4026,12 @@ if (!Array.prototype.forEach) {
4009
4026
  /**
4010
4027
  * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
4011
4028
  * The element's index is used in the logic of the predicate function.
4012
- *
4029
+ *
4013
4030
  * var res = source.skipWhile(function (value) { return value < 10; });
4014
4031
  * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; });
4015
4032
  * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.
4016
- * @param {Any} [thisArg] Object to use as this when executing callback.
4017
- * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
4033
+ * @param {Any} [thisArg] Object to use as this when executing callback.
4034
+ * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
4018
4035
  */
4019
4036
  observableProto.skipWhile = function (predicate, thisArg) {
4020
4037
  var source = this;
@@ -4036,12 +4053,12 @@ if (!Array.prototype.forEach) {
4036
4053
 
4037
4054
  /**
4038
4055
  * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0).
4039
- *
4056
+ *
4040
4057
  * var res = source.take(5);
4041
4058
  * var res = source.take(0, Rx.Scheduler.timeout);
4042
4059
  * @param {Number} count The number of elements to return.
4043
4060
  * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case <paramref name="count count</paramref> is set to 0.
4044
- * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
4061
+ * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.
4045
4062
  */
4046
4063
  observableProto.take = function (count, scheduler) {
4047
4064
  if (count < 0) { throw new RangeError(argumentOutOfRange); }
@@ -4062,8 +4079,8 @@ if (!Array.prototype.forEach) {
4062
4079
  * Returns elements from an observable sequence as long as a specified condition is true.
4063
4080
  * The element's index is used in the logic of the predicate function.
4064
4081
  * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.
4065
- * @param {Any} [thisArg] Object to use as this when executing callback.
4066
- * @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.
4082
+ * @param {Any} [thisArg] Object to use as this when executing callback.
4083
+ * @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.
4067
4084
  */
4068
4085
  observableProto.takeWhile = function (predicate, thisArg) {
4069
4086
  var observable = this;
@@ -4087,34 +4104,32 @@ if (!Array.prototype.forEach) {
4087
4104
  });
4088
4105
  };
4089
4106
 
4090
- /**
4091
- * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
4092
- *
4093
- * @example
4094
- * var res = source.where(function (value) { return value < 10; });
4095
- * var res = source.where(function (value, index) { return value < 10 || index < 10; });
4096
- * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.
4097
- * @param {Any} [thisArg] Object to use as this when executing callback.
4098
- * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.
4099
- */
4100
- observableProto.where = observableProto.filter = function (predicate, thisArg) {
4101
- var parent = this;
4102
- return new AnonymousObservable(function (observer) {
4103
- var count = 0;
4104
- return parent.subscribe(function (value) {
4105
- var shouldRun;
4106
- try {
4107
- shouldRun = predicate.call(thisArg, value, count++, parent);
4108
- } catch (exception) {
4109
- observer.onError(exception);
4110
- return;
4111
- }
4112
- if (shouldRun) {
4113
- observer.onNext(value);
4114
- }
4115
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
4116
- });
4117
- };
4107
+ /**
4108
+ * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
4109
+ *
4110
+ * @example
4111
+ * var res = source.where(function (value) { return value < 10; });
4112
+ * var res = source.where(function (value, index) { return value < 10 || index < 10; });
4113
+ * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.
4114
+ * @param {Any} [thisArg] Object to use as this when executing callback.
4115
+ * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.
4116
+ */
4117
+ observableProto.where = observableProto.filter = function (predicate, thisArg) {
4118
+ var parent = this;
4119
+ return new AnonymousObservable(function (observer) {
4120
+ var count = 0;
4121
+ return parent.subscribe(function (value) {
4122
+ var shouldRun;
4123
+ try {
4124
+ shouldRun = predicate.call(thisArg, value, count++, parent);
4125
+ } catch (e) {
4126
+ observer.onError(e);
4127
+ return;
4128
+ }
4129
+ shouldRun && observer.onNext(value);
4130
+ }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
4131
+ });
4132
+ };
4118
4133
 
4119
4134
  /*
4120
4135
  * Performs a exclusive waiting for the first to finish before subscribing to another observable.
@@ -4135,7 +4150,7 @@ if (!Array.prototype.forEach) {
4135
4150
  function (innerSource) {
4136
4151
  if (!hasCurrent) {
4137
4152
  hasCurrent = true;
4138
-
4153
+
4139
4154
  isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
4140
4155
 
4141
4156
  var innerSubscription = new SingleAssignmentDisposable();
@@ -4156,7 +4171,7 @@ if (!Array.prototype.forEach) {
4156
4171
  observer.onError.bind(observer),
4157
4172
  function () {
4158
4173
  isStopped = true;
4159
- if (!hasCurrent && g.length === 1) {
4174
+ if (!hasCurrent && g.length === 1) {
4160
4175
  observer.onCompleted();
4161
4176
  }
4162
4177
  }));
@@ -4164,6 +4179,7 @@ if (!Array.prototype.forEach) {
4164
4179
  return g;
4165
4180
  });
4166
4181
  };
4182
+
4167
4183
  /*
4168
4184
  * Performs a exclusive map waiting for the first to finish before subscribing to another observable.
4169
4185
  * Observables that come in between subscriptions will be dropped on the floor.
@@ -4186,12 +4202,12 @@ if (!Array.prototype.forEach) {
4186
4202
  function (innerSource) {
4187
4203
 
4188
4204
  if (!hasCurrent) {
4189
- hasCurrent = true;
4205
+ hasCurrent = true;
4190
4206
 
4191
4207
  innerSubscription = new SingleAssignmentDisposable();
4192
4208
  g.add(innerSubscription);
4193
4209
 
4194
- isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
4210
+ isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
4195
4211
 
4196
4212
  innerSubscription.setDisposable(innerSource.subscribe(
4197
4213
  function (x) {
@@ -4215,7 +4231,7 @@ if (!Array.prototype.forEach) {
4215
4231
  }
4216
4232
  }));
4217
4233
  }
4218
- },
4234
+ },
4219
4235
  observer.onError.bind(observer),
4220
4236
  function () {
4221
4237
  isStopped = true;
@@ -4226,6 +4242,7 @@ if (!Array.prototype.forEach) {
4226
4242
  return g;
4227
4243
  });
4228
4244
  };
4245
+
4229
4246
  var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) {
4230
4247
  inherits(AnonymousObservable, __super__);
4231
4248
 
@@ -4250,7 +4267,7 @@ if (!Array.prototype.forEach) {
4250
4267
  } catch (e) {
4251
4268
  if (!autoDetachObserver.fail(e)) {
4252
4269
  throw e;
4253
- }
4270
+ }
4254
4271
  }
4255
4272
  };
4256
4273
 
@@ -4288,8 +4305,8 @@ if (!Array.prototype.forEach) {
4288
4305
  try {
4289
4306
  this.observer.onNext(value);
4290
4307
  noError = true;
4291
- } catch (e) {
4292
- throw e;
4308
+ } catch (e) {
4309
+ throw e;
4293
4310
  } finally {
4294
4311
  if (!noError) {
4295
4312
  this.dispose();
@@ -4300,8 +4317,8 @@ if (!Array.prototype.forEach) {
4300
4317
  AutoDetachObserverPrototype.error = function (exn) {
4301
4318
  try {
4302
4319
  this.observer.onError(exn);
4303
- } catch (e) {
4304
- throw e;
4320
+ } catch (e) {
4321
+ throw e;
4305
4322
  } finally {
4306
4323
  this.dispose();
4307
4324
  }
@@ -4310,8 +4327,8 @@ if (!Array.prototype.forEach) {
4310
4327
  AutoDetachObserverPrototype.completed = function () {
4311
4328
  try {
4312
4329
  this.observer.onCompleted();
4313
- } catch (e) {
4314
- throw e;
4330
+ } catch (e) {
4331
+ throw e;
4315
4332
  } finally {
4316
4333
  this.dispose();
4317
4334
  }
@@ -4332,23 +4349,23 @@ if (!Array.prototype.forEach) {
4332
4349
  return AutoDetachObserver;
4333
4350
  }(AbstractObserver));
4334
4351
 
4335
- /** @private */
4336
- var InnerSubscription = function (subject, observer) {
4337
- this.subject = subject;
4338
- this.observer = observer;
4339
- };
4340
-
4341
- /**
4342
- * @private
4343
- * @memberOf InnerSubscription
4344
- */
4345
- InnerSubscription.prototype.dispose = function () {
4346
- if (!this.subject.isDisposed && this.observer !== null) {
4347
- var idx = this.subject.observers.indexOf(this.observer);
4348
- this.subject.observers.splice(idx, 1);
4349
- this.observer = null;
4350
- }
4351
- };
4352
+ /** @private */
4353
+ var InnerSubscription = function (subject, observer) {
4354
+ this.subject = subject;
4355
+ this.observer = observer;
4356
+ };
4357
+
4358
+ /**
4359
+ * @private
4360
+ * @memberOf InnerSubscription
4361
+ */
4362
+ InnerSubscription.prototype.dispose = function () {
4363
+ if (!this.subject.isDisposed && this.observer !== null) {
4364
+ var idx = this.subject.observers.indexOf(this.observer);
4365
+ this.subject.observers.splice(idx, 1);
4366
+ this.observer = null;
4367
+ }
4368
+ };
4352
4369
 
4353
4370
  /**
4354
4371
  * Represents an object that is both an observable sequence as well as an observer.
@@ -4374,7 +4391,7 @@ if (!Array.prototype.forEach) {
4374
4391
  /**
4375
4392
  * Creates a subject.
4376
4393
  * @constructor
4377
- */
4394
+ */
4378
4395
  function Subject() {
4379
4396
  _super.call(this, subscribe);
4380
4397
  this.isDisposed = false,
@@ -4386,13 +4403,13 @@ if (!Array.prototype.forEach) {
4386
4403
  /**
4387
4404
  * Indicates whether the subject has observers subscribed to it.
4388
4405
  * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
4389
- */
4406
+ */
4390
4407
  hasObservers: function () {
4391
4408
  return this.observers.length > 0;
4392
4409
  },
4393
4410
  /**
4394
4411
  * Notifies all subscribed observers about the end of the sequence.
4395
- */
4412
+ */
4396
4413
  onCompleted: function () {
4397
4414
  checkDisposed.call(this);
4398
4415
  if (!this.isStopped) {
@@ -4408,7 +4425,7 @@ if (!Array.prototype.forEach) {
4408
4425
  /**
4409
4426
  * Notifies all subscribed observers about the exception.
4410
4427
  * @param {Mixed} error The exception to send to all observers.
4411
- */
4428
+ */
4412
4429
  onError: function (exception) {
4413
4430
  checkDisposed.call(this);
4414
4431
  if (!this.isStopped) {
@@ -4425,7 +4442,7 @@ if (!Array.prototype.forEach) {
4425
4442
  /**
4426
4443
  * Notifies all subscribed observers about the arrival of the specified element in the sequence.
4427
4444
  * @param {Mixed} value The value to send to all observers.
4428
- */
4445
+ */
4429
4446
  onNext: function (value) {
4430
4447
  checkDisposed.call(this);
4431
4448
  if (!this.isStopped) {
@@ -4437,7 +4454,7 @@ if (!Array.prototype.forEach) {
4437
4454
  },
4438
4455
  /**
4439
4456
  * Unsubscribe all observers and release resources.
4440
- */
4457
+ */
4441
4458
  dispose: function () {
4442
4459
  this.isDisposed = true;
4443
4460
  this.observers = null;
@@ -4460,12 +4477,12 @@ if (!Array.prototype.forEach) {
4460
4477
  /**
4461
4478
  * Represents the result of an asynchronous operation.
4462
4479
  * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.
4463
- */
4480
+ */
4464
4481
  var AsyncSubject = Rx.AsyncSubject = (function (__super__) {
4465
4482
 
4466
4483
  function subscribe(observer) {
4467
4484
  checkDisposed.call(this);
4468
-
4485
+
4469
4486
  if (!this.isStopped) {
4470
4487
  this.observers.push(observer);
4471
4488
  return new InnerSubscription(this, observer);
@@ -4492,7 +4509,7 @@ if (!Array.prototype.forEach) {
4492
4509
  /**
4493
4510
  * Creates a subject that can only receive one value and that value is cached for all future observations.
4494
4511
  * @constructor
4495
- */
4512
+ */
4496
4513
  function AsyncSubject() {
4497
4514
  __super__.call(this, subscribe);
4498
4515
 
@@ -4508,14 +4525,14 @@ if (!Array.prototype.forEach) {
4508
4525
  /**
4509
4526
  * Indicates whether the subject has observers subscribed to it.
4510
4527
  * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
4511
- */
4528
+ */
4512
4529
  hasObservers: function () {
4513
4530
  checkDisposed.call(this);
4514
4531
  return this.observers.length > 0;
4515
4532
  },
4516
4533
  /**
4517
4534
  * Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any).
4518
- */
4535
+ */
4519
4536
  onCompleted: function () {
4520
4537
  var o, i, len;
4521
4538
  checkDisposed.call(this);
@@ -4543,7 +4560,7 @@ if (!Array.prototype.forEach) {
4543
4560
  /**
4544
4561
  * Notifies all subscribed observers about the error.
4545
4562
  * @param {Mixed} error The Error to send to all observers.
4546
- */
4563
+ */
4547
4564
  onError: function (error) {
4548
4565
  checkDisposed.call(this);
4549
4566
  if (!this.isStopped) {
@@ -4561,7 +4578,7 @@ if (!Array.prototype.forEach) {
4561
4578
  /**
4562
4579
  * Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers.
4563
4580
  * @param {Mixed} value The value to store in the subject.
4564
- */
4581
+ */
4565
4582
  onNext: function (value) {
4566
4583
  checkDisposed.call(this);
4567
4584
  if (this.isStopped) { return; }
@@ -4582,45 +4599,46 @@ if (!Array.prototype.forEach) {
4582
4599
  return AsyncSubject;
4583
4600
  }(Observable));
4584
4601
 
4585
- var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) {
4586
- inherits(AnonymousSubject, __super__);
4587
-
4588
- function AnonymousSubject(observer, observable) {
4589
- this.observer = observer;
4590
- this.observable = observable;
4591
- __super__.call(this, this.observable.subscribe.bind(this.observable));
4592
- }
4593
-
4594
- addProperties(AnonymousSubject.prototype, Observer, {
4595
- onCompleted: function () {
4596
- this.observer.onCompleted();
4597
- },
4598
- onError: function (exception) {
4599
- this.observer.onError(exception);
4600
- },
4601
- onNext: function (value) {
4602
- this.observer.onNext(value);
4603
- }
4604
- });
4605
-
4606
- return AnonymousSubject;
4607
- }(Observable));
4608
-
4609
- if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
4610
- root.Rx = Rx;
4611
-
4612
- define(function() {
4613
- return Rx;
4614
- });
4615
- } else if (freeExports && freeModule) {
4616
- // in Node.js or RingoJS
4617
- if (moduleExports) {
4618
- (freeModule.exports = Rx).Rx = Rx;
4619
- } else {
4620
- freeExports.Rx = Rx;
4621
- }
4622
- } else {
4623
- // in a browser or Rhino
4624
- root.Rx = Rx;
4602
+ var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) {
4603
+ inherits(AnonymousSubject, __super__);
4604
+
4605
+ function AnonymousSubject(observer, observable) {
4606
+ this.observer = observer;
4607
+ this.observable = observable;
4608
+ __super__.call(this, this.observable.subscribe.bind(this.observable));
4625
4609
  }
4626
- }.call(this));
4610
+
4611
+ addProperties(AnonymousSubject.prototype, Observer, {
4612
+ onCompleted: function () {
4613
+ this.observer.onCompleted();
4614
+ },
4615
+ onError: function (exception) {
4616
+ this.observer.onError(exception);
4617
+ },
4618
+ onNext: function (value) {
4619
+ this.observer.onNext(value);
4620
+ }
4621
+ });
4622
+
4623
+ return AnonymousSubject;
4624
+ }(Observable));
4625
+
4626
+ if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
4627
+ root.Rx = Rx;
4628
+
4629
+ define(function() {
4630
+ return Rx;
4631
+ });
4632
+ } else if (freeExports && freeModule) {
4633
+ // in Node.js or RingoJS
4634
+ if (moduleExports) {
4635
+ (freeModule.exports = Rx).Rx = Rx;
4636
+ } else {
4637
+ freeExports.Rx = Rx;
4638
+ }
4639
+ } else {
4640
+ // in a browser or Rhino
4641
+ root.Rx = Rx;
4642
+ }
4643
+
4644
+ }.call(this));