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

max.d.ts 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { MonoTypeOperatorFunction } from '../types';
  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. * ![](max.png)
  7. *
  8. * ## Examples
  9. * Get the maximal value of a series of numbers
  10. * ```ts
  11. * import { of } from 'rxjs';
  12. * import { max } from 'rxjs/operators';
  13. *
  14. * of(5, 4, 7, 2, 8).pipe(
  15. * max(),
  16. * )
  17. * .subscribe(x => console.log(x)); // -> 8
  18. * ```
  19. *
  20. * Use a comparer function to get the maximal item
  21. * ```typescript
  22. * import { of } from 'rxjs';
  23. * import { max } from 'rxjs/operators';
  24. *
  25. * interface Person {
  26. * age: number,
  27. * name: string
  28. * }
  29. * of<Person>(
  30. * {age: 7, name: 'Foo'},
  31. * {age: 5, name: 'Bar'},
  32. * {age: 9, name: 'Beer'},
  33. * ).pipe(
  34. * max<Person>((a: Person, b: Person) => a.age < b.age ? -1 : 1),
  35. * )
  36. * .subscribe((x: Person) => console.log(x.name)); // -> 'Beer'
  37. * ```
  38. *
  39. * @see {@link min}
  40. *
  41. * @param {Function} [comparer] - Optional comparer function that it will use instead of its default to compare the
  42. * value of two items.
  43. * @return {Observable} An Observable that emits item with the largest value.
  44. * @method max
  45. * @owner Observable
  46. */
  47. export declare function max<T>(comparer?: (x: T, y: T) => number): MonoTypeOperatorFunction<T>;