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

Commit 8added4

Browse files
Fixing pairs documentation
1 parent b241e17 commit 8added4

4 files changed

Lines changed: 57 additions & 0 deletions

File tree

doc/libraries/rx.complete.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ NuGet Packages:
4949
- [`ofObjectChanges`](../api/core/operators/ofobjectchanges.md)
5050
- [`ofWithScheduler`](../api/core/operators/ofwithscheduler.md)
5151
- [`onErrorResumeNext`](../api/core/operators/onerrorresumenext.md)
52+
- [`pairs`](../api/core/operators/pairs.md)
5253
- [`range`](../api/core/operators/range.md)
5354
- [`repeat`](../api/core/operators/repeat.md)
5455
- [`return`](../api/core/operators/return.md)

doc/libraries/rx.lite.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ NuGet Packages:
3838
- [`never`](../api/core/operators/never.md)
3939
- [`of`](../api/core/operators/of.md)
4040
- [`ofWithScheduler`](../api/core/operators/ofwithscheduler.md)
41+
- [`pairs`](../api/core/operators/pairs.md)
4142
- [`range`](../api/core/operators/range.md)
4243
- [`repeat`](../api/core/operators/repeat.md)
4344
- [`return | returnValue`](../api/core/operators/return.md)

doc/libraries/rx.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ NuGet Packages:
3535
- [`of`](../api/core/operators/of.md)
3636
- [`ofWithScheduler`](../api/core/operators/ofwithscheduler.md)
3737
- [`onErrorResumeNext`](../api/core/operators/onerrorresumenext.md)
38+
- [`pairs`](../api/core/operators/pairs.md)
3839
- [`range`](../api/core/operators/range.md)
3940
- [`repeat`](../api/core/operators/repeat.md)
4041
- [`return | returnValue`](../api/core/operators/return.md)

src/core/perf/operators/map2.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
var MapObservable = (function (__super__) {
2+
inherits(MapObservable, __super__);
3+
4+
function MapObservable(source, selector, thisArg) {
5+
this.source = source;
6+
this.selector = bindCallback(selector, thisArg, 3);
7+
__super__.call(this);
8+
}
9+
10+
MapObservable.prototype.internalMap = function (selector, thisArg) {
11+
var self = this;
12+
return new MapObservable(this.source, function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }, thisArg)
13+
};
14+
15+
MapObservable.prototype.subscribeCore = function (observer) {
16+
return this.source.subscribe(onNext(observer, this.selector, this), onError(observer), onCompleted(observer));
17+
};
18+
19+
function onNext(observer, selector, source) {
20+
var i = 0;
21+
return function (x) {
22+
var result = tryCatch(selector)(x, i++, source);
23+
if (result === errorObj) {
24+
observer.onError(result.e);
25+
} else {
26+
observer.onNext(result);
27+
}
28+
}
29+
};
30+
31+
function onError(observer) {
32+
return function (err) { observer.onError(err); };
33+
}
34+
35+
function onCompleted(observer) {
36+
return function () { observer.onCompleted(); };
37+
}
38+
39+
return MapObservable;
40+
41+
}(ObservableBase));
42+
43+
/**
44+
* Projects each element of an observable sequence into a new form by incorporating the element's index.
45+
* @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.
46+
* @param {Any} [thisArg] Object to use as this when executing callback.
47+
* @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
48+
*/
49+
observableProto.map = observableProto.select = function (selector, thisArg) {
50+
var selectorFn = typeof selector === 'function' ? selector : function () { return selector; };
51+
return this instanceof MapObservable ?
52+
this.internalMap(selectorFn, thisArg) :
53+
new MapObservable(this, selectorFn, thisArg);
54+
};

0 commit comments

Comments
 (0)