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,25 +23,32 @@
23
23
 
24
24
  var Rx = { internals: {}, config: {} };
25
25
 
26
- // Defaults
27
- function noop() { }
28
- function identity(x) { return x; }
29
- var defaultNow = Date.now;
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
- }
26
+ // Defaults
27
+ function noop() { }
28
+ function identity(x) { return x; }
29
+ var defaultNow = Date.now;
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 };
45
52
 
46
53
  /** `Object#toString` result shortcuts */
47
54
  var argsClass = '[object Arguments]',
@@ -1401,155 +1408,143 @@
1401
1408
  };
1402
1409
  }());
1403
1410
 
1404
- /**
1405
- * @constructor
1406
- * @private
1407
- */
1408
- var Enumerator = Rx.internals.Enumerator = function (moveNext, getCurrent) {
1409
- this.moveNext = moveNext;
1410
- this.getCurrent = getCurrent;
1411
- };
1411
+ var Enumerator = Rx.internals.Enumerator = function (next) {
1412
+ this._next = next;
1413
+ };
1412
1414
 
1413
- /**
1414
- * @static
1415
- * @memberOf Enumerator
1416
- * @private
1417
- */
1418
- var enumeratorCreate = Enumerator.create = function (moveNext, getCurrent) {
1419
- var done = false;
1420
- return new Enumerator(function () {
1421
- if (done) {
1422
- return false;
1423
- }
1424
- var result = moveNext();
1425
- if (!result) {
1426
- done = true;
1427
- }
1428
- return result;
1429
- }, function () { return getCurrent(); });
1430
- };
1431
-
1432
- var Enumerable = Rx.internals.Enumerable = function (getEnumerator) {
1433
- this.getEnumerator = getEnumerator;
1434
- };
1415
+ Enumerator.prototype.next = function () {
1416
+ return this._next();
1417
+ };
1435
1418
 
1436
- Enumerable.prototype.concat = function () {
1437
- var sources = this;
1438
- return new AnonymousObservable(function (observer) {
1439
- var e = sources.getEnumerator(), isDisposed, subscription = new SerialDisposable();
1440
- var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1441
- var current, hasNext;
1442
- if (isDisposed) { return; }
1419
+ Enumerator.prototype[$iterator$] = function () { return this; }
1443
1420
 
1444
- try {
1445
- hasNext = e.moveNext();
1446
- if (hasNext) {
1447
- current = e.getCurrent();
1448
- }
1449
- } catch (ex) {
1450
- observer.onError(ex);
1451
- return;
1452
- }
1421
+ var Enumerable = Rx.internals.Enumerable = function (iterator) {
1422
+ this._iterator = iterator;
1423
+ };
1453
1424
 
1454
- if (!hasNext) {
1455
- observer.onCompleted();
1456
- return;
1457
- }
1425
+ Enumerable.prototype[$iterator$] = function () {
1426
+ return this._iterator();
1427
+ };
1458
1428
 
1459
- var d = new SingleAssignmentDisposable();
1460
- subscription.setDisposable(d);
1461
- d.setDisposable(current.subscribe(
1462
- observer.onNext.bind(observer),
1463
- observer.onError.bind(observer),
1464
- function () { self(); })
1465
- );
1466
- });
1467
- return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1468
- isDisposed = true;
1469
- }));
1470
- });
1471
- };
1429
+ Enumerable.prototype.concat = function () {
1430
+ var sources = this;
1431
+ return new AnonymousObservable(function (observer) {
1432
+ var e;
1433
+ try {
1434
+ e = sources[$iterator$]();
1435
+ } catch(err) {
1436
+ observer.onError();
1437
+ return;
1438
+ }
1472
1439
 
1473
- Enumerable.prototype.catchException = function () {
1474
- var sources = this;
1475
- return new AnonymousObservable(function (observer) {
1476
- var e = sources.getEnumerator(), isDisposed, lastException;
1477
- var subscription = new SerialDisposable();
1478
- var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1479
- var current, hasNext;
1480
- if (isDisposed) { return; }
1440
+ var isDisposed,
1441
+ subscription = new SerialDisposable();
1442
+ var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1443
+ var currentItem;
1444
+ if (isDisposed) { return; }
1481
1445
 
1482
- try {
1483
- hasNext = e.moveNext();
1484
- if (hasNext) {
1485
- current = e.getCurrent();
1486
- }
1487
- } catch (ex) {
1488
- observer.onError(ex);
1489
- return;
1490
- }
1446
+ try {
1447
+ currentItem = e.next();
1448
+ } catch (ex) {
1449
+ observer.onError(ex);
1450
+ return;
1451
+ }
1491
1452
 
1492
- if (!hasNext) {
1493
- if (lastException) {
1494
- observer.onError(lastException);
1495
- } else {
1496
- observer.onCompleted();
1497
- }
1498
- return;
1499
- }
1453
+ if (currentItem.done) {
1454
+ observer.onCompleted();
1455
+ return;
1456
+ }
1500
1457
 
1501
- var d = new SingleAssignmentDisposable();
1502
- subscription.setDisposable(d);
1503
- d.setDisposable(current.subscribe(
1504
- observer.onNext.bind(observer),
1505
- function (exn) {
1506
- lastException = exn;
1507
- self();
1508
- },
1509
- observer.onCompleted.bind(observer)));
1510
- });
1511
- return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1512
- isDisposed = true;
1513
- }));
1458
+ var d = new SingleAssignmentDisposable();
1459
+ subscription.setDisposable(d);
1460
+ d.setDisposable(currentItem.value.subscribe(
1461
+ observer.onNext.bind(observer),
1462
+ observer.onError.bind(observer),
1463
+ function () { self(); })
1464
+ );
1514
1465
  });
1515
- };
1516
1466
 
1467
+ return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1468
+ isDisposed = true;
1469
+ }));
1470
+ });
1471
+ };
1472
+
1473
+ Enumerable.prototype.catchException = function () {
1474
+ var sources = this;
1475
+ return new AnonymousObservable(function (observer) {
1476
+ var e;
1477
+ try {
1478
+ e = sources[$iterator$]();
1479
+ } catch(err) {
1480
+ observer.onError();
1481
+ return;
1482
+ }
1517
1483
 
1518
- var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {
1519
- if (arguments.length === 1) {
1520
- repeatCount = -1;
1484
+ var isDisposed,
1485
+ lastException,
1486
+ subscription = new SerialDisposable();
1487
+ var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1488
+ if (isDisposed) { return; }
1489
+
1490
+ var currentItem;
1491
+ try {
1492
+ currentItem = e.next();
1493
+ } catch (ex) {
1494
+ observer.onError(ex);
1495
+ return;
1521
1496
  }
1522
- return new Enumerable(function () {
1523
- var current, left = repeatCount;
1524
- return enumeratorCreate(function () {
1525
- if (left === 0) {
1526
- return false;
1527
- }
1528
- if (left > 0) {
1529
- left--;
1530
- }
1531
- current = value;
1532
- return true;
1533
- }, function () { return current; });
1534
- });
1535
- };
1536
1497
 
1537
- var enumerableFor = Enumerable.forEach = function (source, selector, thisArg) {
1538
- selector || (selector = identity);
1539
- return new Enumerable(function () {
1540
- var current, index = -1;
1541
- return enumeratorCreate(
1542
- function () {
1543
- if (++index < source.length) {
1544
- current = selector.call(thisArg, source[index], index, source);
1545
- return true;
1546
- }
1547
- return false;
1548
- },
1549
- function () { return current; }
1550
- );
1498
+ if (currentItem.done) {
1499
+ if (lastException) {
1500
+ observer.onError(lastException);
1501
+ } else {
1502
+ observer.onCompleted();
1503
+ }
1504
+ return;
1505
+ }
1506
+
1507
+ var d = new SingleAssignmentDisposable();
1508
+ subscription.setDisposable(d);
1509
+ d.setDisposable(currentItem.value.subscribe(
1510
+ observer.onNext.bind(observer),
1511
+ function (exn) {
1512
+ lastException = exn;
1513
+ self();
1514
+ },
1515
+ observer.onCompleted.bind(observer)));
1516
+ });
1517
+ return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1518
+ isDisposed = true;
1519
+ }));
1520
+ });
1521
+ };
1522
+
1523
+
1524
+ var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {
1525
+ if (repeatCount == null) { repeatCount = -1; }
1526
+ return new Enumerable(function () {
1527
+ var left = repeatCount;
1528
+ return new Enumerator(function () {
1529
+ if (left === 0) { return doneEnumerator; }
1530
+ if (left > 0) { left--; }
1531
+ return { done: false, value: value };
1532
+ });
1533
+ });
1534
+ };
1535
+
1536
+ var enumerableFor = Enumerable.forEach = function (source, selector, thisArg) {
1537
+ selector || (selector = identity);
1538
+ return new Enumerable(function () {
1539
+ var index = -1;
1540
+ return new Enumerator(
1541
+ function () {
1542
+ return ++index < source.length ?
1543
+ { done: false, value: selector.call(thisArg, source[index], index, source) } :
1544
+ doneEnumerator;
1551
1545
  });
1552
- };
1546
+ });
1547
+ };
1553
1548
 
1554
1549
  /**
1555
1550
  * Supports push-style iteration over an observable sequence.
@@ -1954,37 +1949,44 @@
1954
1949
  });
1955
1950
  };
1956
1951
 
1957
- /**
1958
- * Converts a generator function to an observable sequence, using an optional scheduler to enumerate the generator.
1959
- *
1960
- * @example
1961
- * var res = Rx.Observable.fromGenerator(function* () { yield 42; });
1962
- * var res = Rx.Observable.fromArray(function* () { yield 42; }, Rx.Scheduler.timeout);
1963
- * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
1964
- * @returns {Observable} The observable sequence whose elements are pulled from the given generator sequence.
1965
- */
1966
- observableProto.fromGenerator = function (genFn, scheduler) {
1967
- scheduler || (scheduler = currentThreadScheduler);
1968
- return new AnonymousObservable(function (observer) {
1969
- var gen;
1970
- try {
1971
- gen = genFn();
1972
- } catch (e) {
1973
- observer.onError(e);
1974
- return;
1975
- }
1952
+ /**
1953
+ * Converts an iterable into an Observable sequence
1954
+ *
1955
+ * @example
1956
+ * var res = Rx.Observable.fromIterable(new Map());
1957
+ * var res = Rx.Observable.fromIterable(new Set(), Rx.Scheduler.timeout);
1958
+ * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
1959
+ * @returns {Observable} The observable sequence whose elements are pulled from the given generator sequence.
1960
+ */
1961
+ Observable.fromIterable = function (iterable, scheduler) {
1962
+ scheduler || (scheduler = currentThreadScheduler);
1963
+ return new AnonymousObservable(function (observer) {
1964
+ var iterator;
1965
+ try {
1966
+ iterator = iterable[$iterator$]();
1967
+ } catch (e) {
1968
+ observer.onError(e);
1969
+ return;
1970
+ }
1976
1971
 
1977
- return scheduler.scheduleRecursive(function (self) {
1978
- var next = gen.next();
1979
- if (next.done) {
1980
- observer.onCompleted();
1981
- } else {
1982
- observer.onNext(next.value);
1983
- self();
1984
- }
1985
- });
1986
- });
1987
- };
1972
+ return scheduler.scheduleRecursive(function (self) {
1973
+ var next;
1974
+ try {
1975
+ next = iterator.next();
1976
+ } catch (err) {
1977
+ observer.onError(err);
1978
+ return;
1979
+ }
1980
+
1981
+ if (next.done) {
1982
+ observer.onCompleted();
1983
+ } else {
1984
+ observer.onNext(next.value);
1985
+ self();
1986
+ }
1987
+ });
1988
+ });
1989
+ };
1988
1990
 
1989
1991
  /**
1990
1992
  * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.