min.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var operators_1 = require("rxjs/operators");
  4. /**
  5. * The Min operator operates on an Observable that emits numbers (or items that can be compared with a provided function),
  6. * and when source Observable completes it emits a single item: the item with the smallest value.
  7. *
  8. * <img src="./img/min.png" width="100%">
  9. *
  10. * @example <caption>Get the minimal value of a series of numbers</caption>
  11. * Rx.Observable.of(5, 4, 7, 2, 8)
  12. * .min()
  13. * .subscribe(x => console.log(x)); // -> 2
  14. *
  15. * @example <caption>Use a comparer function to get the minimal item</caption>
  16. * interface Person {
  17. * age: number,
  18. * name: string
  19. * }
  20. * Observable.of<Person>({age: 7, name: 'Foo'},
  21. * {age: 5, name: 'Bar'},
  22. * {age: 9, name: 'Beer'})
  23. * .min<Person>( (a: Person, b: Person) => a.age < b.age ? -1 : 1)
  24. * .subscribe((x: Person) => console.log(x.name)); // -> 'Bar'
  25. * }
  26. *
  27. * @see {@link max}
  28. *
  29. * @param {Function} [comparer] - Optional comparer function that it will use instead of its default to compare the
  30. * value of two items.
  31. * @return {Observable<R>} An Observable that emits item with the smallest value.
  32. * @method min
  33. * @owner Observable
  34. */
  35. function min(comparer) {
  36. return operators_1.min(comparer)(this);
  37. }
  38. exports.min = min;
  39. //# sourceMappingURL=min.js.map