source: trip-planner-front/node_modules/rxjs/_esm2015/internal/operators/map.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1import { Subscriber } from '../Subscriber';
2export function map(project, thisArg) {
3 return function mapOperation(source) {
4 if (typeof project !== 'function') {
5 throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
6 }
7 return source.lift(new MapOperator(project, thisArg));
8 };
9}
10export class MapOperator {
11 constructor(project, thisArg) {
12 this.project = project;
13 this.thisArg = thisArg;
14 }
15 call(subscriber, source) {
16 return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
17 }
18}
19class MapSubscriber extends Subscriber {
20 constructor(destination, project, thisArg) {
21 super(destination);
22 this.project = project;
23 this.count = 0;
24 this.thisArg = thisArg || this;
25 }
26 _next(value) {
27 let result;
28 try {
29 result = this.project.call(this.thisArg, value, this.count++);
30 }
31 catch (err) {
32 this.destination.error(err);
33 return;
34 }
35 this.destination.next(result);
36 }
37}
38//# sourceMappingURL=map.js.map
Note: See TracBrowser for help on using the repository browser.