UNPKG

@reactivex/ix-es2015-cjs

Version:

The Interactive Extensions for JavaScript

22 lines (20 loc) 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.maxBy = void 0; const _extremaby_js_1 = require("./_extremaby.js"); const comparer_js_1 = require("../util/comparer.js"); /** * Returns the elements in an async-iterable sequence with the maximum key value. * * @template TSource The type of the elements in the source sequence. * @template TKey The type of the key computed for each element in the source sequence. * @param {AsyncIterable<TSource>} source An async-iterable sequence to get the maximum elements for. * @param {ExtremaOptions<TSource, TKey>} [options] The options which include an optional comparer and abort signal. * @returns {Promise<TSource[]>} A promise containing a list of zero or more elements that have a maximum key value. */ function maxBy(source, options) { const { ['comparer']: comparer = comparer_js_1.equalityComparerAsync, ['selector']: selector, ['signal']: signal, } = options || {}; return (0, _extremaby_js_1.extremaBy)(source, selector, comparer, signal); } exports.maxBy = maxBy; //# sourceMappingURL=maxby.js.map