Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Commit 0b442f2

Browse files
Closing Issue #319
1 parent 3dff8bb commit 0b442f2

34 files changed

+1669
-775
lines changed

dist/rx.all.compat.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,14 +1562,14 @@ if (!Array.prototype.forEach) {
15621562
function _acceptObservable(observer) { return observer.onError(this.exception); }
15631563
function toString () { return 'OnError(' + this.exception + ')'; }
15641564

1565-
return function (exception) {
1565+
return function (e) {
15661566
var notification = new Notification('E');
1567-
notification.exception = exception;
1567+
notification.exception = e;
15681568
notification._accept = _accept;
15691569
notification._acceptObservable = _acceptObservable;
15701570
notification.toString = toString;
15711571
return notification;
1572-
};
1572+
};
15731573
}());
15741574

15751575
/**
@@ -1578,17 +1578,17 @@ if (!Array.prototype.forEach) {
15781578
*/
15791579
var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {
15801580

1581-
function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1582-
function _acceptObservable(observer) { return observer.onCompleted(); }
1583-
function toString () { return 'OnCompleted()'; }
1581+
function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1582+
function _acceptObservable(observer) { return observer.onCompleted(); }
1583+
function toString () { return 'OnCompleted()'; }
15841584

1585-
return function () {
1586-
var notification = new Notification('C');
1587-
notification._accept = _accept;
1588-
notification._acceptObservable = _acceptObservable;
1589-
notification.toString = toString;
1590-
return notification;
1591-
};
1585+
return function () {
1586+
var notification = new Notification('C');
1587+
notification._accept = _accept;
1588+
notification._acceptObservable = _acceptObservable;
1589+
notification.toString = toString;
1590+
return notification;
1591+
};
15921592
}());
15931593

15941594
var Enumerator = Rx.internals.Enumerator = function (next) {
@@ -2340,7 +2340,13 @@ if (!Array.prototype.forEach) {
23402340
if (i < len || objIsIterable) {
23412341
var result;
23422342
if (objIsIterable) {
2343-
var next = it.next();
2343+
var next;
2344+
try {
2345+
next = it.next();
2346+
} catch (e) {
2347+
observer.onError(e);
2348+
return;
2349+
}
23442350
if (next.done) {
23452351
observer.onCompleted();
23462352
return;
@@ -3632,7 +3638,7 @@ if (!Array.prototype.forEach) {
36323638

36333639
function concatMap(source, selector, thisArg) {
36343640
return source.map(function (x, i) {
3635-
var result = selector.call(thisArg, x, i);
3641+
var result = selector.call(thisArg, x, i, source);
36363642
isPromise(result) && (result = observableFromPromise(result));
36373643
(Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
36383644
return result;
@@ -3659,7 +3665,7 @@ if (!Array.prototype.forEach) {
36593665
* @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.
36603666
*/
36613667
observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
3662-
if (resultSelector) {
3668+
if (typeof selector === 'function' && typeof resultSelector === 'function') {
36633669
return this.concatMap(function (x, i) {
36643670
var selectorResult = selector(x, i);
36653671
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
@@ -3957,7 +3963,7 @@ if (!Array.prototype.forEach) {
39573963

39583964
function flatMap(source, selector, thisArg) {
39593965
return source.map(function (x, i) {
3960-
var result = selector.call(thisArg, x, i);
3966+
var result = selector.call(thisArg, x, i, source);
39613967
isPromise(result) && (result = observableFromPromise(result));
39623968
(Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
39633969
return result;
@@ -3984,7 +3990,7 @@ if (!Array.prototype.forEach) {
39843990
* @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.
39853991
*/
39863992
observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
3987-
if (resultSelector) {
3993+
if (typeof selector === 'function' && typeof resultSelector === 'function') {
39883994
return this.flatMap(function (x, i) {
39893995
var selectorResult = selector(x, i);
39903996
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));

dist/rx.all.compat.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.compat.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,14 +1411,14 @@
14111411
function _acceptObservable(observer) { return observer.onError(this.exception); }
14121412
function toString () { return 'OnError(' + this.exception + ')'; }
14131413

1414-
return function (exception) {
1414+
return function (e) {
14151415
var notification = new Notification('E');
1416-
notification.exception = exception;
1416+
notification.exception = e;
14171417
notification._accept = _accept;
14181418
notification._acceptObservable = _acceptObservable;
14191419
notification.toString = toString;
14201420
return notification;
1421-
};
1421+
};
14221422
}());
14231423

14241424
/**
@@ -1427,17 +1427,17 @@
14271427
*/
14281428
var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {
14291429

1430-
function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1431-
function _acceptObservable(observer) { return observer.onCompleted(); }
1432-
function toString () { return 'OnCompleted()'; }
1430+
function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1431+
function _acceptObservable(observer) { return observer.onCompleted(); }
1432+
function toString () { return 'OnCompleted()'; }
14331433

1434-
return function () {
1435-
var notification = new Notification('C');
1436-
notification._accept = _accept;
1437-
notification._acceptObservable = _acceptObservable;
1438-
notification.toString = toString;
1439-
return notification;
1440-
};
1434+
return function () {
1435+
var notification = new Notification('C');
1436+
notification._accept = _accept;
1437+
notification._acceptObservable = _acceptObservable;
1438+
notification.toString = toString;
1439+
return notification;
1440+
};
14411441
}());
14421442

14431443
var Enumerator = Rx.internals.Enumerator = function (next) {
@@ -2189,7 +2189,13 @@
21892189
if (i < len || objIsIterable) {
21902190
var result;
21912191
if (objIsIterable) {
2192-
var next = it.next();
2192+
var next;
2193+
try {
2194+
next = it.next();
2195+
} catch (e) {
2196+
observer.onError(e);
2197+
return;
2198+
}
21932199
if (next.done) {
21942200
observer.onCompleted();
21952201
return;
@@ -3481,7 +3487,7 @@
34813487

34823488
function concatMap(source, selector, thisArg) {
34833489
return source.map(function (x, i) {
3484-
var result = selector.call(thisArg, x, i);
3490+
var result = selector.call(thisArg, x, i, source);
34853491
isPromise(result) && (result = observableFromPromise(result));
34863492
(Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
34873493
return result;
@@ -3508,7 +3514,7 @@
35083514
* @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.
35093515
*/
35103516
observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
3511-
if (resultSelector) {
3517+
if (typeof selector === 'function' && typeof resultSelector === 'function') {
35123518
return this.concatMap(function (x, i) {
35133519
var selectorResult = selector(x, i);
35143520
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
@@ -3806,7 +3812,7 @@
38063812

38073813
function flatMap(source, selector, thisArg) {
38083814
return source.map(function (x, i) {
3809-
var result = selector.call(thisArg, x, i);
3815+
var result = selector.call(thisArg, x, i, source);
38103816
isPromise(result) && (result = observableFromPromise(result));
38113817
(Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
38123818
return result;
@@ -3833,7 +3839,7 @@
38333839
* @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.
38343840
*/
38353841
observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
3836-
if (resultSelector) {
3842+
if (typeof selector === 'function' && typeof resultSelector === 'function') {
38373843
return this.flatMap(function (x, i) {
38383844
var selectorResult = selector(x, i);
38393845
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));

dist/rx.all.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.compat.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,14 +1562,14 @@ if (!Array.prototype.forEach) {
15621562
function _acceptObservable(observer) { return observer.onError(this.exception); }
15631563
function toString () { return 'OnError(' + this.exception + ')'; }
15641564

1565-
return function (exception) {
1565+
return function (e) {
15661566
var notification = new Notification('E');
1567-
notification.exception = exception;
1567+
notification.exception = e;
15681568
notification._accept = _accept;
15691569
notification._acceptObservable = _acceptObservable;
15701570
notification.toString = toString;
15711571
return notification;
1572-
};
1572+
};
15731573
}());
15741574

15751575
/**
@@ -1578,17 +1578,17 @@ if (!Array.prototype.forEach) {
15781578
*/
15791579
var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {
15801580

1581-
function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1582-
function _acceptObservable(observer) { return observer.onCompleted(); }
1583-
function toString () { return 'OnCompleted()'; }
1581+
function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1582+
function _acceptObservable(observer) { return observer.onCompleted(); }
1583+
function toString () { return 'OnCompleted()'; }
15841584

1585-
return function () {
1586-
var notification = new Notification('C');
1587-
notification._accept = _accept;
1588-
notification._acceptObservable = _acceptObservable;
1589-
notification.toString = toString;
1590-
return notification;
1591-
};
1585+
return function () {
1586+
var notification = new Notification('C');
1587+
notification._accept = _accept;
1588+
notification._acceptObservable = _acceptObservable;
1589+
notification.toString = toString;
1590+
return notification;
1591+
};
15921592
}());
15931593

15941594
var Enumerator = Rx.internals.Enumerator = function (next) {
@@ -2340,7 +2340,13 @@ if (!Array.prototype.forEach) {
23402340
if (i < len || objIsIterable) {
23412341
var result;
23422342
if (objIsIterable) {
2343-
var next = it.next();
2343+
var next;
2344+
try {
2345+
next = it.next();
2346+
} catch (e) {
2347+
observer.onError(e);
2348+
return;
2349+
}
23442350
if (next.done) {
23452351
observer.onCompleted();
23462352
return;
@@ -3632,7 +3638,7 @@ if (!Array.prototype.forEach) {
36323638

36333639
function concatMap(source, selector, thisArg) {
36343640
return source.map(function (x, i) {
3635-
var result = selector.call(thisArg, x, i);
3641+
var result = selector.call(thisArg, x, i, source);
36363642
isPromise(result) && (result = observableFromPromise(result));
36373643
(Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
36383644
return result;
@@ -3659,7 +3665,7 @@ if (!Array.prototype.forEach) {
36593665
* @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.
36603666
*/
36613667
observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
3662-
if (resultSelector) {
3668+
if (typeof selector === 'function' && typeof resultSelector === 'function') {
36633669
return this.concatMap(function (x, i) {
36643670
var selectorResult = selector(x, i);
36653671
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
@@ -3843,7 +3849,7 @@ if (!Array.prototype.forEach) {
38433849

38443850
function flatMap(source, selector, thisArg) {
38453851
return source.map(function (x, i) {
3846-
var result = selector.call(thisArg, x, i);
3852+
var result = selector.call(thisArg, x, i, source);
38473853
isPromise(result) && (result = observableFromPromise(result));
38483854
(Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
38493855
return result;
@@ -3870,7 +3876,7 @@ if (!Array.prototype.forEach) {
38703876
* @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.
38713877
*/
38723878
observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
3873-
if (resultSelector) {
3879+
if (typeof selector === 'function' && typeof resultSelector === 'function') {
38743880
return this.flatMap(function (x, i) {
38753881
var selectorResult = selector(x, i);
38763882
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));

dist/rx.compat.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.compat.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,14 +1411,14 @@
14111411
function _acceptObservable(observer) { return observer.onError(this.exception); }
14121412
function toString () { return 'OnError(' + this.exception + ')'; }
14131413

1414-
return function (exception) {
1414+
return function (e) {
14151415
var notification = new Notification('E');
1416-
notification.exception = exception;
1416+
notification.exception = e;
14171417
notification._accept = _accept;
14181418
notification._acceptObservable = _acceptObservable;
14191419
notification.toString = toString;
14201420
return notification;
1421-
};
1421+
};
14221422
}());
14231423

14241424
/**
@@ -1427,17 +1427,17 @@
14271427
*/
14281428
var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {
14291429

1430-
function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1431-
function _acceptObservable(observer) { return observer.onCompleted(); }
1432-
function toString () { return 'OnCompleted()'; }
1430+
function _accept (onNext, onError, onCompleted) { return onCompleted(); }
1431+
function _acceptObservable(observer) { return observer.onCompleted(); }
1432+
function toString () { return 'OnCompleted()'; }
14331433

1434-
return function () {
1435-
var notification = new Notification('C');
1436-
notification._accept = _accept;
1437-
notification._acceptObservable = _acceptObservable;
1438-
notification.toString = toString;
1439-
return notification;
1440-
};
1434+
return function () {
1435+
var notification = new Notification('C');
1436+
notification._accept = _accept;
1437+
notification._acceptObservable = _acceptObservable;
1438+
notification.toString = toString;
1439+
return notification;
1440+
};
14411441
}());
14421442

14431443
var Enumerator = Rx.internals.Enumerator = function (next) {
@@ -2189,7 +2189,13 @@
21892189
if (i < len || objIsIterable) {
21902190
var result;
21912191
if (objIsIterable) {
2192-
var next = it.next();
2192+
var next;
2193+
try {
2194+
next = it.next();
2195+
} catch (e) {
2196+
observer.onError(e);
2197+
return;
2198+
}
21932199
if (next.done) {
21942200
observer.onCompleted();
21952201
return;
@@ -3481,7 +3487,7 @@
34813487

34823488
function concatMap(source, selector, thisArg) {
34833489
return source.map(function (x, i) {
3484-
var result = selector.call(thisArg, x, i);
3490+
var result = selector.call(thisArg, x, i, source);
34853491
isPromise(result) && (result = observableFromPromise(result));
34863492
(Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
34873493
return result;
@@ -3508,7 +3514,7 @@
35083514
* @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.
35093515
*/
35103516
observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {
3511-
if (resultSelector) {
3517+
if (typeof selector === 'function' && typeof resultSelector === 'function') {
35123518
return this.concatMap(function (x, i) {
35133519
var selectorResult = selector(x, i);
35143520
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));
@@ -3744,7 +3750,7 @@
37443750

37453751
function flatMap(source, selector, thisArg) {
37463752
return source.map(function (x, i) {
3747-
var result = selector.call(thisArg, x, i);
3753+
var result = selector.call(thisArg, x, i, source);
37483754
isPromise(result) && (result = observableFromPromise(result));
37493755
(Array.isArray(result) || isIterable(result)) && (result = observableFrom(result));
37503756
return result;
@@ -3771,7 +3777,7 @@
37713777
* @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.
37723778
*/
37733779
observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {
3774-
if (resultSelector) {
3780+
if (typeof selector === 'function' && typeof resultSelector === 'function') {
37753781
return this.flatMap(function (x, i) {
37763782
var selectorResult = selector(x, i);
37773783
isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));

0 commit comments

Comments
 (0)