UNPKG

1.25 kBTypeScriptView Raw
1import { MonoTypeOperatorFunction } from '../types';
2/**
3 * The Min 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 smallest value.
5 *
6 * ![](min.png)
7 *
8 * ## Examples
9 *
10 * Get the minimal value of a series of numbers
11 *
12 * ```ts
13 * import { of, min } from 'rxjs';
14 *
15 * of(5, 4, 7, 2, 8)
16 * .pipe(min())
17 * .subscribe(x => console.log(x));
18 *
19 * // Outputs
20 * // 2
21 * ```
22 *
23 * Use a comparer function to get the minimal item
24 *
25 * ```ts
26 * import { of, min } from 'rxjs';
27 *
28 * of(
29 * { age: 7, name: 'Foo' },
30 * { age: 5, name: 'Bar' },
31 * { age: 9, name: 'Beer' }
32 * ).pipe(
33 * min((a, b) => a.age < b.age ? -1 : 1)
34 * )
35 * .subscribe(x => console.log(x.name));
36 *
37 * // Outputs
38 * // 'Bar'
39 * ```
40 *
41 * @see {@link max}
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 * smallest value.
47 */
48export declare function min<T>(comparer?: (x: T, y: T) => number): MonoTypeOperatorFunction<T>;
49//# sourceMappingURL=min.d.ts.map
\No newline at end of file