rxjs-rails 2.2.15 → 2.2.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,26 +23,33 @@
23
23
 
24
24
  var Rx = { internals: {}, config: {} };
25
25
 
26
- // Defaults
27
- function noop() { }
28
- function identity(x) { return x; }
29
- var defaultNow = (function () { return !!Date.now ? Date.now : function () { return +new Date; }; }());
30
- function defaultComparer(x, y) { return isEqual(x, y); }
31
- function defaultSubComparer(x, y) { return x - y; }
32
- function defaultKeySerializer(x) { return x.toString(); }
33
- function defaultError(err) { throw err; }
34
- function isPromise(p) { return typeof p.then === 'function'; }
35
-
36
- // Errors
37
- var sequenceContainsNoElements = 'Sequence contains no elements.';
38
- var argumentOutOfRange = 'Argument out of range';
39
- var objectDisposed = 'Object has been disposed';
40
- function checkDisposed() {
41
- if (this.isDisposed) {
42
- throw new Error(objectDisposed);
43
- }
44
- }
45
-
26
+ // Defaults
27
+ function noop() { }
28
+ function identity(x) { return x; }
29
+ var defaultNow = (function () { return !!Date.now ? Date.now : function () { return +new Date; }; }());
30
+ function defaultComparer(x, y) { return isEqual(x, y); }
31
+ function defaultSubComparer(x, y) { return x - y; }
32
+ function defaultKeySerializer(x) { return x.toString(); }
33
+ function defaultError(err) { throw err; }
34
+ function isPromise(p) { return typeof p.then === 'function' && typeof p.subscribe === 'undefined'; }
35
+
36
+ // Errors
37
+ var sequenceContainsNoElements = 'Sequence contains no elements.';
38
+ var argumentOutOfRange = 'Argument out of range';
39
+ var objectDisposed = 'Object has been disposed';
40
+ function checkDisposed() { if (this.isDisposed) { throw new Error(objectDisposed); } }
41
+
42
+ // Shim in iterator support
43
+ var $iterator$ = (typeof Symbol === 'object' && Symbol.iterator) ||
44
+ '_es6shim_iterator_';
45
+ // Firefox ships a partial implementation using the name @@iterator.
46
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=907077#c14
47
+ // So use that name if we detect it.
48
+ if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {
49
+ $iterator$ = '@@iterator';
50
+ }
51
+ var doneEnumerator = { done: true, value: undefined };
52
+
46
53
  /** `Object#toString` result shortcuts */
47
54
  var argsClass = '[object Arguments]',
48
55
  arrayClass = '[object Array]',
@@ -1519,155 +1526,143 @@
1519
1526
  };
1520
1527
  }());
1521
1528
 
1522
- /**
1523
- * @constructor
1524
- * @private
1525
- */
1526
- var Enumerator = Rx.internals.Enumerator = function (moveNext, getCurrent) {
1527
- this.moveNext = moveNext;
1528
- this.getCurrent = getCurrent;
1529
- };
1529
+ var Enumerator = Rx.internals.Enumerator = function (next) {
1530
+ this._next = next;
1531
+ };
1530
1532
 
1531
- /**
1532
- * @static
1533
- * @memberOf Enumerator
1534
- * @private
1535
- */
1536
- var enumeratorCreate = Enumerator.create = function (moveNext, getCurrent) {
1537
- var done = false;
1538
- return new Enumerator(function () {
1539
- if (done) {
1540
- return false;
1541
- }
1542
- var result = moveNext();
1543
- if (!result) {
1544
- done = true;
1545
- }
1546
- return result;
1547
- }, function () { return getCurrent(); });
1548
- };
1549
-
1550
- var Enumerable = Rx.internals.Enumerable = function (getEnumerator) {
1551
- this.getEnumerator = getEnumerator;
1552
- };
1533
+ Enumerator.prototype.next = function () {
1534
+ return this._next();
1535
+ };
1553
1536
 
1554
- Enumerable.prototype.concat = function () {
1555
- var sources = this;
1556
- return new AnonymousObservable(function (observer) {
1557
- var e = sources.getEnumerator(), isDisposed, subscription = new SerialDisposable();
1558
- var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1559
- var current, hasNext;
1560
- if (isDisposed) { return; }
1537
+ Enumerator.prototype[$iterator$] = function () { return this; }
1561
1538
 
1562
- try {
1563
- hasNext = e.moveNext();
1564
- if (hasNext) {
1565
- current = e.getCurrent();
1566
- }
1567
- } catch (ex) {
1568
- observer.onError(ex);
1569
- return;
1570
- }
1539
+ var Enumerable = Rx.internals.Enumerable = function (iterator) {
1540
+ this._iterator = iterator;
1541
+ };
1571
1542
 
1572
- if (!hasNext) {
1573
- observer.onCompleted();
1574
- return;
1575
- }
1543
+ Enumerable.prototype[$iterator$] = function () {
1544
+ return this._iterator();
1545
+ };
1576
1546
 
1577
- var d = new SingleAssignmentDisposable();
1578
- subscription.setDisposable(d);
1579
- d.setDisposable(current.subscribe(
1580
- observer.onNext.bind(observer),
1581
- observer.onError.bind(observer),
1582
- function () { self(); })
1583
- );
1584
- });
1585
- return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1586
- isDisposed = true;
1587
- }));
1588
- });
1589
- };
1547
+ Enumerable.prototype.concat = function () {
1548
+ var sources = this;
1549
+ return new AnonymousObservable(function (observer) {
1550
+ var e;
1551
+ try {
1552
+ e = sources[$iterator$]();
1553
+ } catch(err) {
1554
+ observer.onError();
1555
+ return;
1556
+ }
1590
1557
 
1591
- Enumerable.prototype.catchException = function () {
1592
- var sources = this;
1593
- return new AnonymousObservable(function (observer) {
1594
- var e = sources.getEnumerator(), isDisposed, lastException;
1595
- var subscription = new SerialDisposable();
1596
- var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1597
- var current, hasNext;
1598
- if (isDisposed) { return; }
1558
+ var isDisposed,
1559
+ subscription = new SerialDisposable();
1560
+ var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1561
+ var currentItem;
1562
+ if (isDisposed) { return; }
1599
1563
 
1600
- try {
1601
- hasNext = e.moveNext();
1602
- if (hasNext) {
1603
- current = e.getCurrent();
1604
- }
1605
- } catch (ex) {
1606
- observer.onError(ex);
1607
- return;
1608
- }
1564
+ try {
1565
+ currentItem = e.next();
1566
+ } catch (ex) {
1567
+ observer.onError(ex);
1568
+ return;
1569
+ }
1609
1570
 
1610
- if (!hasNext) {
1611
- if (lastException) {
1612
- observer.onError(lastException);
1613
- } else {
1614
- observer.onCompleted();
1615
- }
1616
- return;
1617
- }
1571
+ if (currentItem.done) {
1572
+ observer.onCompleted();
1573
+ return;
1574
+ }
1618
1575
 
1619
- var d = new SingleAssignmentDisposable();
1620
- subscription.setDisposable(d);
1621
- d.setDisposable(current.subscribe(
1622
- observer.onNext.bind(observer),
1623
- function (exn) {
1624
- lastException = exn;
1625
- self();
1626
- },
1627
- observer.onCompleted.bind(observer)));
1628
- });
1629
- return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1630
- isDisposed = true;
1631
- }));
1576
+ var d = new SingleAssignmentDisposable();
1577
+ subscription.setDisposable(d);
1578
+ d.setDisposable(currentItem.value.subscribe(
1579
+ observer.onNext.bind(observer),
1580
+ observer.onError.bind(observer),
1581
+ function () { self(); })
1582
+ );
1632
1583
  });
1633
- };
1634
1584
 
1585
+ return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1586
+ isDisposed = true;
1587
+ }));
1588
+ });
1589
+ };
1635
1590
 
1636
- var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {
1637
- if (arguments.length === 1) {
1638
- repeatCount = -1;
1591
+ Enumerable.prototype.catchException = function () {
1592
+ var sources = this;
1593
+ return new AnonymousObservable(function (observer) {
1594
+ var e;
1595
+ try {
1596
+ e = sources[$iterator$]();
1597
+ } catch(err) {
1598
+ observer.onError();
1599
+ return;
1600
+ }
1601
+
1602
+ var isDisposed,
1603
+ lastException,
1604
+ subscription = new SerialDisposable();
1605
+ var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1606
+ if (isDisposed) { return; }
1607
+
1608
+ var currentItem;
1609
+ try {
1610
+ currentItem = e.next();
1611
+ } catch (ex) {
1612
+ observer.onError(ex);
1613
+ return;
1639
1614
  }
1640
- return new Enumerable(function () {
1641
- var current, left = repeatCount;
1642
- return enumeratorCreate(function () {
1643
- if (left === 0) {
1644
- return false;
1645
- }
1646
- if (left > 0) {
1647
- left--;
1648
- }
1649
- current = value;
1650
- return true;
1651
- }, function () { return current; });
1652
- });
1653
- };
1654
1615
 
1655
- var enumerableFor = Enumerable.forEach = function (source, selector, thisArg) {
1656
- selector || (selector = identity);
1657
- return new Enumerable(function () {
1658
- var current, index = -1;
1659
- return enumeratorCreate(
1660
- function () {
1661
- if (++index < source.length) {
1662
- current = selector.call(thisArg, source[index], index, source);
1663
- return true;
1664
- }
1665
- return false;
1666
- },
1667
- function () { return current; }
1668
- );
1616
+ if (currentItem.done) {
1617
+ if (lastException) {
1618
+ observer.onError(lastException);
1619
+ } else {
1620
+ observer.onCompleted();
1621
+ }
1622
+ return;
1623
+ }
1624
+
1625
+ var d = new SingleAssignmentDisposable();
1626
+ subscription.setDisposable(d);
1627
+ d.setDisposable(currentItem.value.subscribe(
1628
+ observer.onNext.bind(observer),
1629
+ function (exn) {
1630
+ lastException = exn;
1631
+ self();
1632
+ },
1633
+ observer.onCompleted.bind(observer)));
1634
+ });
1635
+ return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1636
+ isDisposed = true;
1637
+ }));
1638
+ });
1639
+ };
1640
+
1641
+
1642
+ var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {
1643
+ if (repeatCount == null) { repeatCount = -1; }
1644
+ return new Enumerable(function () {
1645
+ var left = repeatCount;
1646
+ return new Enumerator(function () {
1647
+ if (left === 0) { return doneEnumerator; }
1648
+ if (left > 0) { left--; }
1649
+ return { done: false, value: value };
1650
+ });
1651
+ });
1652
+ };
1653
+
1654
+ var enumerableFor = Enumerable.forEach = function (source, selector, thisArg) {
1655
+ selector || (selector = identity);
1656
+ return new Enumerable(function () {
1657
+ var index = -1;
1658
+ return new Enumerator(
1659
+ function () {
1660
+ return ++index < source.length ?
1661
+ { done: false, value: selector.call(thisArg, source[index], index, source) } :
1662
+ doneEnumerator;
1669
1663
  });
1670
- };
1664
+ });
1665
+ };
1671
1666
 
1672
1667
  /**
1673
1668
  * Supports push-style iteration over an observable sequence.
@@ -2072,37 +2067,44 @@
2072
2067
  });
2073
2068
  };
2074
2069
 
2075
- /**
2076
- * Converts a generator function to an observable sequence, using an optional scheduler to enumerate the generator.
2077
- *
2078
- * @example
2079
- * var res = Rx.Observable.fromGenerator(function* () { yield 42; });
2080
- * var res = Rx.Observable.fromArray(function* () { yield 42; }, Rx.Scheduler.timeout);
2081
- * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
2082
- * @returns {Observable} The observable sequence whose elements are pulled from the given generator sequence.
2083
- */
2084
- observableProto.fromGenerator = function (genFn, scheduler) {
2085
- scheduler || (scheduler = currentThreadScheduler);
2086
- return new AnonymousObservable(function (observer) {
2087
- var gen;
2088
- try {
2089
- gen = genFn();
2090
- } catch (e) {
2091
- observer.onError(e);
2092
- return;
2093
- }
2070
+ /**
2071
+ * Converts an iterable into an Observable sequence
2072
+ *
2073
+ * @example
2074
+ * var res = Rx.Observable.fromIterable(new Map());
2075
+ * var res = Rx.Observable.fromIterable(new Set(), Rx.Scheduler.timeout);
2076
+ * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
2077
+ * @returns {Observable} The observable sequence whose elements are pulled from the given generator sequence.
2078
+ */
2079
+ Observable.fromIterable = function (iterable, scheduler) {
2080
+ scheduler || (scheduler = currentThreadScheduler);
2081
+ return new AnonymousObservable(function (observer) {
2082
+ var iterator;
2083
+ try {
2084
+ iterator = iterable[$iterator$]();
2085
+ } catch (e) {
2086
+ observer.onError(e);
2087
+ return;
2088
+ }
2094
2089
 
2095
- return scheduler.scheduleRecursive(function (self) {
2096
- var next = gen.next();
2097
- if (next.done) {
2098
- observer.onCompleted();
2099
- } else {
2100
- observer.onNext(next.value);
2101
- self();
2102
- }
2103
- });
2104
- });
2105
- };
2090
+ return scheduler.scheduleRecursive(function (self) {
2091
+ var next;
2092
+ try {
2093
+ next = iterator.next();
2094
+ } catch (err) {
2095
+ observer.onError(err);
2096
+ return;
2097
+ }
2098
+
2099
+ if (next.done) {
2100
+ observer.onCompleted();
2101
+ } else {
2102
+ observer.onNext(next.value);
2103
+ self();
2104
+ }
2105
+ });
2106
+ });
2107
+ };
2106
2108
 
2107
2109
  /**
2108
2110
  * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.