UNPKG

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