1.0.11 • Published 7 years ago
@kingjs/linq.average v1.0.11
@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:
0API
declare function average(
this: Enumerable,
selector?: function(x): number
): numberInterfaces
Enumerable: See @kingjs/enumerable.define.
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.averageSee Also
Like Enumerable.Average
License
MIT