npm.io
1.0.21 • Published 7 years ago

@kingjs/linq.aggregate

Licence
MIT
Version
1.0.21
Deps
3
Size
5 kB
Vulns
0
Weekly
0

@kingjs/linq.aggregate

Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.

Usage

require('kingjs');
var assert = require('assert');
var Aggregate = require('@kingjs/linq.aggregate');

var sequence = [2, 3, 4];

var result = sequence[Aggregate](1, function(x) {
  return this + x; 
}, o => String(o));

assert(result === '10');

API

aggregate(this, seed, aggregator, selector)
Parameters
  • this: An IEnumerable over which to aggregate.
  • seed: The initial accumulator value.
  • aggregator: An accumulator function to be invoked on each element.
  • selector: A function to transform the final accumulator value into the result value.
Returns

The transformed final accumulator value.

Install

With npm installed, run

$ npm install @kingjs/linq.aggregate

Dependencies

Package Version
@kingjs/i-enumerable ^1.0.6
@kingjs/i-enumerator ^1.0.7
@kingjs/reflect.export-extension ^1.0.1

Source

https://repository.kingjs.net/linq/aggregate

License

MIT

Analytics