@kingjs/linq.average

Returns the average value of a sequence of numbers projected from elements of a sequence.

Stats

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

Readme

@kingjs/linq.average

Returns the average value of a sequence of numbers projected from elements of a sequence.

Usage

Compute the average of [-2, 0, 2] like this:

var average = require('@kingjs/linq.average');
var sequence = require('@kingjs/enumerable.create');

average.call(sequence(-2, 0, 2));

result:

0

API

declare function average(
  this: Enumerable,
  selector?: function(x): number
): number

Interfaces

Parameters

  • this: The sequence of numbers to average.
  • selector: A function to select a number from each element.

Return Value

The average value of the sequence of numbers. Returns NaN if the sequence is empty.

Remarks

Elements are summed using the + operator.

Average of an empty sequence is NaN.

Install

With npm installed, run

$ npm install @kingjs/linq.average

See Also

Like Enumerable.Average

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.