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

findIndex.d.ts 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { Observable } from '../Observable';
  2. import { OperatorFunction } from '../types';
  3. /**
  4. * Emits only the index of the first value emitted by the source Observable that
  5. * meets some condition.
  6. *
  7. * <span class="informal">It's like {@link find}, but emits the index of the
  8. * found value, not the value itself.</span>
  9. *
  10. * ![](findIndex.png)
  11. *
  12. * `findIndex` searches for the first item in the source Observable that matches
  13. * the specified condition embodied by the `predicate`, and returns the
  14. * (zero-based) index of the first occurrence in the source. Unlike
  15. * {@link first}, the `predicate` is required in `findIndex`, and does not emit
  16. * an error if a valid value is not found.
  17. *
  18. * ## Example
  19. * Emit the index of first click that happens on a DIV element
  20. * ```ts
  21. * import { fromEvent } from 'rxjs';
  22. * import { findIndex } from 'rxjs/operators';
  23. *
  24. * const clicks = fromEvent(document, 'click');
  25. * const result = clicks.pipe(findIndex(ev => ev.target.tagName === 'DIV'));
  26. * result.subscribe(x => console.log(x));
  27. * ```
  28. *
  29. * @see {@link filter}
  30. * @see {@link find}
  31. * @see {@link first}
  32. * @see {@link take}
  33. *
  34. * @param {function(value: T, index: number, source: Observable<T>): boolean} predicate
  35. * A function called with each item to test for condition matching.
  36. * @param {any} [thisArg] An optional argument to determine the value of `this`
  37. * in the `predicate` function.
  38. * @return {Observable} An Observable of the index of the first item that
  39. * matches the condition.
  40. * @method find
  41. * @owner Observable
  42. */
  43. export declare function findIndex<T>(predicate: (value: T, index: number, source: Observable<T>) => boolean, thisArg?: any): OperatorFunction<T, number>;