@kingjs/linq.max
v1.0.6
Published
Returns the maximum value in a sequence of values projected from elements of a sequence.
Downloads
12
Readme
@kingjs/linq.max
Returns the maximum value in a sequence of values projected from elements of a sequence.
Usage
Return the maximum value of 1
, 2
, 3
like this:
var max = require('@kingjs/linq.max');
var sequence = require('@kingjs/enumerable.create');
max.call(sequence(1, 2, 3));
result:
3
Return the oldest person like this:
var max = require('@kingjs/linq.max');
var sequence = require('@kingjs/enumerable.create');
var compareAge = function(l, r) { return l.age < r.age; }
max.call(sequence(
{ name: 'Alice', age: 18 },
{ name: 'Bob', age: 19 },
{ name: 'Chris', age: 19 },
), compareAge);
result:
{ name: 'Bob', age: 19 }
API
declare function max(
this: Enumerable,
lessThan?: (l, r) => boolean
)
Interfaces
Enumerable
: See @kingjs/enumerable.define.
Parameters
this
: Sequence to search for max element.lessThan
: Optional element comparison function.
Return Value
The maximum element.
Install
With npm installed, run
$ npm install @kingjs/linq.max
Acknowledgments
Like Enumerable.Max.
License
MIT