@kingjs/linq.average

1.0.11 • Public • Published

@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

Readme

Keywords

none

Package Sidebar

Install

npm i @kingjs/linq.average

Weekly Downloads

0

Version

1.0.11

License

MIT

Unpacked Size

3.38 kB

Total Files

4

Last publish

Collaborators

  • kingces95