This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/rxjs/_esm2015/internal/operators/map.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-08-11 18:48:02 +00:00
import { Subscriber } from '../Subscriber';
export function map(project, thisArg) {
return function mapOperation(source) {
if (typeof project !== 'function') {
throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
}
return source.lift(new MapOperator(project, thisArg));
};
}
export class MapOperator {
constructor(project, thisArg) {
this.project = project;
this.thisArg = thisArg;
}
call(subscriber, source) {
return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
}
}
class MapSubscriber extends Subscriber {
constructor(destination, project, thisArg) {
super(destination);
this.project = project;
this.count = 0;
this.thisArg = thisArg || this;
}
_next(value) {
let result;
try {
result = this.project.call(this.thisArg, value, this.count++);
}
catch (err) {
this.destination.error(err);
return;
}
this.destination.next(result);
}
}
//# sourceMappingURL=map.js.map