Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

map.d.ts 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { Operator } from '../Operator';
  2. import { Subscriber } from '../Subscriber';
  3. import { 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. * ```javascript
  21. * const clicks = fromEvent(document, 'click');
  22. * const positions = clicks.pipe(map(ev => ev.clientX));
  23. * positions.subscribe(x => console.log(x));
  24. * ```
  25. *
  26. * @see {@link mapTo}
  27. * @see {@link pluck}
  28. *
  29. * @param {function(value: T, index: number): R} project The function to apply
  30. * to each `value` emitted by the source Observable. The `index` parameter is
  31. * the number `i` for the i-th emission that has happened since the
  32. * subscription, starting from the number `0`.
  33. * @param {any} [thisArg] An optional argument to define what `this` is in the
  34. * `project` function.
  35. * @return {Observable<R>} An Observable that emits the values from the source
  36. * Observable transformed by the given `project` function.
  37. * @method map
  38. * @owner Observable
  39. */
  40. export declare function map<T, R>(project: (value: T, index: number) => R, thisArg?: any): OperatorFunction<T, R>;
  41. export declare class MapOperator<T, R> implements Operator<T, R> {
  42. private project;
  43. private thisArg;
  44. constructor(project: (value: T, index: number) => R, thisArg: any);
  45. call(subscriber: Subscriber<R>, source: any): any;
  46. }