1 line
2.1 KiB
Plaintext
Executable File
1 line
2.1 KiB
Plaintext
Executable File
{"version":3,"file":"min.js","sourceRoot":"","sources":["../../src/operators/min.ts"],"names":[],"mappings":";AAAA,uBAAuB,UAAU,CAAC,CAAA;AAGlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,aAAuB,QAAiC;IACtD,IAAM,GAAG,GAAsB,CAAC,OAAO,QAAQ,KAAK,UAAU,CAAC;UAC3D,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAA1B,CAA0B;UACpC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAb,CAAa,CAAC;IAC5B,MAAM,CAAC,eAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC;AALe,WAAG,MAKlB,CAAA","sourcesContent":["import { reduce } from './reduce';\nimport { MonoTypeOperatorFunction } from '../interfaces';\n\n/**\n * The Min operator operates on an Observable that emits numbers (or items that can be compared with a provided function),\n * and when source Observable completes it emits a single item: the item with the smallest value.\n *\n * <img src=\"./img/min.png\" width=\"100%\">\n *\n * @example <caption>Get the minimal value of a series of numbers</caption>\n * Rx.Observable.of(5, 4, 7, 2, 8)\n * .min()\n * .subscribe(x => console.log(x)); // -> 2\n *\n * @example <caption>Use a comparer function to get the minimal item</caption>\n * interface Person {\n * age: number,\n * name: string\n * }\n * Observable.of<Person>({age: 7, name: 'Foo'},\n * {age: 5, name: 'Bar'},\n * {age: 9, name: 'Beer'})\n * .min<Person>( (a: Person, b: Person) => a.age < b.age ? -1 : 1)\n * .subscribe((x: Person) => console.log(x.name)); // -> 'Bar'\n * }\n *\n * @see {@link max}\n *\n * @param {Function} [comparer] - Optional comparer function that it will use instead of its default to compare the\n * value of two items.\n * @return {Observable<R>} An Observable that emits item with the smallest value.\n * @method min\n * @owner Observable\n */\nexport function min<T>(comparer?: (x: T, y: T) => number): MonoTypeOperatorFunction<T> {\n const min: (x: T, y: T) => T = (typeof comparer === 'function')\n ? (x, y) => comparer(x, y) < 0 ? x : y\n : (x, y) => x < y ? x : y;\n return reduce(min);\n}\n"]} |