UNPKG

2.05 kBSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/min.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG,CACjB,MAAyB,EACzB,OAA0C;IAE1C,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,gBAAgB,EAAE,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,GACpF,OAAO,IAAI,EAAE,CAAC;IAEhB,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACrC,IAAI,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IAErB,IAAI,IAAI,CAAC,IAAI,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IAED,IAAI,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEpC,OAAO,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QAC/B,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE;YACnC,QAAQ,GAAG,OAAO,CAAC;SACpB;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","file":"min.js","sourcesContent":["import { equalityComparer } from '../util/comparer';\nimport { identity } from '../util/identity';\nimport { ExtremaOptions } from './extremaoptions';\n\n/**\n * * Returns the minimum element with the optional selector.\n *\n * @export\n * @template TSource The type of the elements in the source sequence.\n * @param {Iterable<TSource>} source An iterable sequence to determine the minimum element of.\n * @param {ExtremaByOptions<TKey>} [options] The options which include an optional comparer.\n * @returns {TResult} The minimum element.\n */\nexport function min<TSource, TResult = TSource>(\n source: Iterable<TSource>,\n options?: ExtremaOptions<TSource, TResult>\n): TResult {\n const { ['comparer']: comparer = equalityComparer, ['selector']: selector = identity } =\n options || {};\n\n const it = source[Symbol.iterator]();\n let next = it.next();\n\n if (next.done) {\n throw new Error('Sequence contains no elements');\n }\n\n let minValue = selector(next.value);\n\n while (!(next = it.next()).done) {\n const current = selector(next.value);\n if (comparer(current, minValue) < 0) {\n minValue = current;\n }\n }\n\n return minValue;\n}\n"]}
\No newline at end of file