feat: map operator correction
This commit is contained in:
parent
346bbd851a
commit
44f4a97b95
@ -2,7 +2,22 @@ import { Observable } from '../Observable';
|
|||||||
import { OperatorFunction } from './types';
|
import { OperatorFunction } from './types';
|
||||||
|
|
||||||
export function map<T, R>(project: (value: T) => R): OperatorFunction<T, R> {
|
export function map<T, R>(project: (value: T) => R): OperatorFunction<T, R> {
|
||||||
void Observable;
|
return source => {
|
||||||
void project;
|
return new Observable(observer => {
|
||||||
throw new Error('TODO');
|
const next = (value: T) => {
|
||||||
|
try {
|
||||||
|
const result = project(value);
|
||||||
|
observer.next(result);
|
||||||
|
} catch (e) {
|
||||||
|
observer.error(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return source.subscribe({
|
||||||
|
next,
|
||||||
|
error: err => observer.error(err),
|
||||||
|
complete: () => observer.complete(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user