Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

map.d.ts 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. * ```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. */
  43. export declare function map<T, R>(project: (value: T, index: number) => R, thisArg?: any): OperatorFunction<T, R>;
  44. export 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. }