@kingjs/linq.max

Returns the maximum value in a sequence of values projected from elements of a sequence.

Stats

StarsIssuesVersionUpdatedCreatedSize
@kingjs/linq.max
1.0.63 years ago3 years agoMinified + gzip package size for @kingjs/linq.max in KB

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

Analytics

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.