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);
},
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);
},