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.

findIndex.d.ts 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. * ```javascript
  21. * const clicks = fromEvent(document, 'click');
  22. * const result = clicks.pipe(findIndex(ev => ev.target.tagName === 'DIV'));
  23. * result.subscribe(x => console.log(x));
  24. * ```
  25. *
  26. * @see {@link filter}
  27. * @see {@link find}
  28. * @see {@link first}
  29. * @see {@link take}
  30. *
  31. * @param {function(value: T, index: number, source: Observable<T>): boolean} predicate
  32. * A function called with each item to test for condition matching.
  33. * @param {any} [thisArg] An optional argument to determine the value of `this`
  34. * in the `predicate` function.
  35. * @return {Observable} An Observable of the index of the first item that
  36. * matches the condition.
  37. * @method find
  38. * @owner Observable
  39. */
  40. export declare function findIndex<T>(predicate: (value: T, index: number, source: Observable<T>) => boolean, thisArg?: any): OperatorFunction<T, number>;