Quantcast
Channel: jsinq Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7

Created Issue: Bug in aggregate function if array is empty [2936]

$
0
0
There is a bug in the aggregate function in jsinq-enumerable.js . If you pass to the function a seed argument the function shouldn't throw with an empty array. It should return the seed.

My proposed fix:
aggregate: function() {
var enumerator = this.getEnumerator();

var running;
var func;
var resultSelector = identity;
if (arguments.length >= 2) {
running = arguments[0];
func = arguments[1];
if (arguments.length >= 3) {
resultSelector = arguments[2];
}
} else {
if (!enumerator.moveNext()) {
throw new InvalidOperationException();
}

func = arguments[0];
running = enumerator.current();
}
while (enumerator.moveNext()) {
running = func(running, enumerator.current());
}
return resultSelector(running);
},

Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>