source: trip-planner-front/node_modules/rxjs/internal/operators/map.d.ts@ 8d391a1

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

initial commit

  • Property mode set to 100644
File size: 2.0 KB
Line 
1import { Operator } from '../Operator';
2import { Subscriber } from '../Subscriber';
3import { OperatorFunction } from '../types';
4/**
5 * Applies a given `project` function to each value emitted by the source
6 * Observable, and emits the resulting values as an Observable.
7 *
8 * <span class="informal">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),
9 * it passes each source value through a transformation function to get
10 * corresponding output values.</span>
11 *
12 * ![](map.png)
13 *
14 * Similar to the well known `Array.prototype.map` function, this operator
15 * applies a projection to each value and emits that projection in the output
16 * Observable.
17 *
18 * ## Example
19 * Map every click to the clientX position of that click
20 * ```ts
21 * import { fromEvent } from 'rxjs';
22 * import { map } from 'rxjs/operators';
23 *
24 * const clicks = fromEvent(document, 'click');
25 * const positions = clicks.pipe(map(ev => ev.clientX));
26 * positions.subscribe(x => console.log(x));
27 * ```
28 *
29 * @see {@link mapTo}
30 * @see {@link pluck}
31 *
32 * @param {function(value: T, index: number): R} project The function to apply
33 * to each `value` emitted by the source Observable. The `index` parameter is
34 * the number `i` for the i-th emission that has happened since the
35 * subscription, starting from the number `0`.
36 * @param {any} [thisArg] An optional argument to define what `this` is in the
37 * `project` function.
38 * @return {Observable<R>} An Observable that emits the values from the source
39 * Observable transformed by the given `project` function.
40 * @method map
41 * @owner Observable
42 */
43export declare function map<T, R>(project: (value: T, index: number) => R, thisArg?: any): OperatorFunction<T, R>;
44export declare class MapOperator<T, R> implements Operator<T, R> {
45 private project;
46 private thisArg;
47 constructor(project: (value: T, index: number) => R, thisArg: any);
48 call(subscriber: Subscriber<R>, source: any): any;
49}
Note: See TracBrowser for help on using the repository browser.