12345678910111213141516171819202122232425262728293031323334
  1. import { MonoTypeOperatorFunction } from '../interfaces';
  2. /**
  3. * The Max operator operates on an Observable that emits numbers (or items that can be compared with a provided function),
  4. * and when source Observable completes it emits a single item: the item with the largest value.
  5. *
  6. * <img src="./img/max.png" width="100%">
  7. *
  8. * @example <caption>Get the maximal value of a series of numbers</caption>
  9. * Rx.Observable.of(5, 4, 7, 2, 8)
  10. * .max()
  11. * .subscribe(x => console.log(x)); // -> 8
  12. *
  13. * @example <caption>Use a comparer function to get the maximal item</caption>
  14. * interface Person {
  15. * age: number,
  16. * name: string
  17. * }
  18. * Observable.of<Person>({age: 7, name: 'Foo'},
  19. * {age: 5, name: 'Bar'},
  20. * {age: 9, name: 'Beer'})
  21. * .max<Person>((a: Person, b: Person) => a.age < b.age ? -1 : 1)
  22. * .subscribe((x: Person) => console.log(x.name)); // -> 'Beer'
  23. * }
  24. *
  25. * @see {@link min}
  26. *
  27. * @param {Function} [comparer] - Optional comparer function that it will use instead of its default to compare the
  28. * value of two items.
  29. * @return {Observable} An Observable that emits item with the largest value.
  30. * @method max
  31. * @owner Observable
  32. */
  33. export declare function max<T>(comparer?: (x: T, y: T) => number): MonoTypeOperatorFunction<T>;